/dev/shm permission change after node reboot

Shared memory is a way to shared state between process. Shared memory, as its name implies, is a method to “share” data between processes. Both processes define the same memory area as “shared”, and they can then exchange information simply by writing into it. This (used to be, and still is somewhat) faster than the alternative of sending network or pipe-based messages between processes.

If you see the memory as a mean of storing data, a file on a file system can be seen as shared memory (ie shared file). It is difficult to account for shared memory. Does it belong to one process? Both? Neither? If we naively sum the memory belonging to multiple processes, we grossly “over-count”.

As the name implies, the Shared (Virtual) Memory refers to virtual memory that are shared by more than one process and then can be used by multiple programs simultaneously. Although virtual memory allows processes to have separate (virtual) address spaces, there are times when you need processes to share memory. Shared memory (SHM) is another method of interprocess communication (IPC) whereby several processes share a single chunk of memory to communicate.

Shared memory provides the fastest way for processes to pass large amounts of data to one another. /dev/shm is nothing but implementation of traditional shared memory concept. It is an efficient means of passing data between programs. One program will create a memory portion, which other processes (if permitted) can access. This will result into speeding up things on Linux.

The Problem

On every reboot of the server, the /dev/shm permission changes:

$ ls -alrt /dev/ | grep shm
drwxr-xr-t. 2 root root 60 jul 6 11:14 shm 

Original Permission(1777):

# ls -ld /dev/shm
drwxrwxrwt. 2 root root 200 Aug 20 03:44 /dev/shm

Existing Permission(1754):

$ ls -alrt /dev/ | grep shm
drwxr-xr-t. 2 root root 60 jul 6 11:14 shm

The Solution

The cause of the issue is with the existing initscripts package [initscripts-9.49.37-1.0.1.el7_3.1.x86_64].

Workaround

Step 1: Mask the service( rhel-import-state):

# systemctl mask rhel-import-state

Step 2: Check the status of the service. It will look similar to below:

rhel-import-state.service
  Loaded: masked (/dev/null; bad) 

Step 3: Reboot the machine and confirm whether the same issue reoccurs or not.

Note: This is the workaround action plan. For a permanent resolution, upgrade the initscripts package version to 9.49.39-1.0.1, which is included in CentOS/RHEL7 update 4.

Reverting the Changes

You can also revert the changes by executing the below command to unmask the masked service.

# systemctl unmask rhel-import-state.service
# systemctl status rhel-import-state.service
Related Post