Bug 1584443 - Unexpected results from mount --rbind and --make-rslave
Summary: Unexpected results from mount --rbind and --make-rslave
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Fedora
Classification: Fedora
Component: util-linux
Version: 28
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Karel Zak
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-05-30 23:23 UTC by Iestyn Elfick
Modified: 2018-07-18 13:17 UTC (History)
2 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2018-07-18 13:17:08 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Iestyn Elfick 2018-05-30 23:23:19 UTC
Description of problem:
'mount --rbind --make-rslave <src> <dst>' does not behave the same as 'mount --rbind <src> <dst>; mount --make-rslave <dst>'

Version-Release number of selected component (if applicable):
2.32.2.fc28

How reproducible:
Consistently

Steps to Reproduce:
1. mkdir -p /sysroot/dev
2. mount --rbind --make-rslave /dev /sysroot/dev
   mount | grep sysroot
   umount -l /sysroot/dev
3. mount --rbind /dev /sysroot/dev
   mount --make-rslave /sysroot/dev
   mount | grep sysroot
   umount -l /sysroot/dev

Actual results for step 2:
devtmpfs on /sysroot/dev type devtmpfs (rw,nosuid,seclabel,size=4063476k,nr_inodes=1015869,mode=755)

Expected results for step 2:
devtmpfs on /sysroot/dev type devtmpfs (rw,nosuid,seclabel,size=4063476k,nr_inodes=1015869,mode=755)
tmpfs on /sysroot/dev/shm type tmpfs (rw,nosuid,nodev,seclabel)
devpts on /sysroot/dev/pts type devpts (rw,nosuid,noexec,relatime,seclabel,gid=5,mode=620,ptmxmode=000)
hugetlbfs on /sysroot/dev/hugepages type hugetlbfs (rw,relatime,seclabel,pagesize=2M)
mqueue on /sysroot/dev/mqueue type mqueue (rw,relatime,seclabel)

Additional info:
The difference in behaviour does not strike me as obvious. It would be less surprising if both sequences had the same effect. If working as designed, I would be interested in knowing the rationale.

Comment 1 Karel Zak 2018-06-01 10:23:54 UTC
Good catch. It's bug. 

Fixed by upstream commits:

 4ebea84bb1ca6b0fa817588aba13de26c8d5e5a0
 816773b475900909d42c2c8282a6ac50252cac22


 # strace -e mount mount --rbind --make-rslave /mnt/A /mnt/B
  
Old version:  
  
 mount("/mnt/A", "/mnt/B", 0x13ecac0, MS_MGC_VAL|MS_BIND, NULL) = 0
 mount("none", "/mnt/B", NULL, MS_REC|MS_SLAVE, NULL) = 0
  
Fixed version:
  
 mount("/mnt/A", "/mnt/B", 0x1f22ac0, MS_MGC_VAL|MS_BIND|MS_REC, NULL) = 0
 mount("none", "/mnt/B", NULL, MS_REC|MS_SLAVE, NULL) = 0

Comment 2 Karel Zak 2018-07-18 13:17:08 UTC
The change will be available in v2.33.


Note You need to log in before you can comment on or make changes to this bug.