Bug 1584443

Summary: Unexpected results from mount --rbind and --make-rslave
Product: [Fedora] Fedora Reporter: Iestyn Elfick <isedev>
Component: util-linuxAssignee: Karel Zak <kzak>
Status: CLOSED UPSTREAM QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 28CC: jonathan, kzak
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-07-18 13:17:08 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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.