Package: initscripts
Version: 2.93-5
Severity: normal
Tags: patch

I haven't actually confirmed the bug, but just reading the code I
think there's a problem. After 2.93-4 resolved #851427 by reversing
the /dev/shm -> /run/shm symlink to /run/shm -> /dev/shm, on a system
running a static /dev, the following /lib/init/mount-functions.sh
mount_shm() code should hit the previous /dev/shm symlink:

>         if [ ! -d "$SHMDIR" ]
>         then
>                 mkdir --mode=755 "$SHMDIR"
>                 [ -x /sbin/restorecon ] && /sbin/restorecon "$SHMDIR"
>         fi

There is no clean-up so mkdir will fail. Then mounting on /dev/shm will
also fail because it's a dangling symlink. Then run_migrate() will
symlink /run/shm to /dev/shm. There will be a symlink loop and no shm
tmpfs.

Perhaps the attached patch removing stale $SHMDIR symlinks could be an
appropriate trade-off.

-- System Information:
Debian Release: buster/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)

Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)

Versions of packages initscripts depends on:
ii  coreutils       8.30-1
ii  debianutils     4.8.6.1
ii  lsb-base        10.2018112800
ii  mount           2.33.1-0.1
ii  sysv-rc         2.93-1
ii  sysvinit-utils  2.93-1

Versions of packages initscripts recommends:
ii  e2fsprogs  1.44.5-1
ii  psmisc     23.2-1

initscripts suggests no packages.

-- Configuration Files:
/etc/default/rcS changed [not included]
/etc/default/tmpfs changed [not included]

-- no debconf information
--- sysvinit-2.93/debian/src/initscripts/lib/init/mount-functions.sh	2019-01-19 22:28:14.000000000 +0100
+++ sysvinit-2.93/debian/src/initscripts/lib/init/mount-functions.sh	2019-01-24 07:14:18.734999072 +0100
@@ -579,6 +579,10 @@
 
 	if [ ! -d "$SHMDIR" ]
 	then
+		# Remove possible previous reverse symlink.
+		if [ -h "$SHMDIR" ] ; then
+			rm -f "$SHMDIR"
+		fi
 		mkdir --mode=755 "$SHMDIR"
 		[ -x /sbin/restorecon ] && /sbin/restorecon "$SHMDIR"
 	fi

Reply via email to