FreeBSD Bugzilla – Attachment 237865 Details for
Bug 255047
race bug with mount generating same fsid for different mount points
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
script to reproduce the bug
fsidbug.sh (text/plain), 1.76 KB, created by
Olivier Cochard
on 2022-11-04 21:26:48 UTC
(
hide
)
Description:
script to reproduce the bug
Filename:
MIME Type:
Creator:
Olivier Cochard
Created:
2022-11-04 21:26:48 UTC
Size:
1.76 KB
patch
obsolete
>#!/bin/sh ># Reproduce duplicate fsid race triggering umounting wrong directory > >set -euo pipefail > >mount_race () { > # Mounting the raw disk image, writing 4M into it and umounting it > n=$1 > echo "[$n] Copying /tmp/mount_bug into /tmp/$n..." > cp /tmp/mount_bug /tmp/$n > echo "[$n] Creating md device..." > MD=$(mdconfig -a -t vnode -f /tmp/$1) > echo "[$n] mount ${MD} into /tmp/$n.mnt..." > mkdir -p /tmp/$n.mnt > mount /dev/${MD} /tmp/$n.mnt > FSID=$(dumpfs /tmp/$n.mnt | grep -w id) > echo "[$n] fsid of the mount point /tmp/$n.mnt/: ${FSID}" > echo "[$n] Creating a file into it /tmp/$n.mnt/..." > truncate -s +4M /tmp/$n.mnt/dummy > echo "[$n] umount /tmp/$n.mnt..." > if ! umount /tmp/$n.mnt; then > echo "[$n] umount of /tmp/$n.mnt failed because:" > echo "[$n] 1) it umounted the wrong mount point (same fsid as the 'other') used by the other process" > echo "[$n] 2) or it was already wrongly umounted by the other process" > else > echo "[$n] umount sucessfull, destroying md device $MD..." > if ! mdconfig -d -u ${MD}; then > echo "[$n] destroying md device ${MD} failed (because still mounted, the previous umount did it on the wrong directory)" > fi > fi > echo "[$n] cleaning up..." > # Those will fails, then the set -e will stop full script > rm -rf /tmp/$n.mnt > rm /tmp/$n >} > >init_disk_image () { > echo "[init] Creating 6MB raw UFS disk file in /tmp/mount_bug..." > rm -rf /tmp/mount_bug > truncate -s +6M /tmp/mount_bug > MD=$(mdconfig -a -t vnode -f /tmp/mount_bug) > newfs /dev/$MD > /dev/null > mdconfig -d -u ${MD} > return 0 >} > >main () { > if [ "$(id -u)" != "0" ]; then > echo "Need to be root (mdconfig, mount)" > exit 1 > fi > > pid="" > init_disk_image > > while true; do > mount_race 1 & > pid=$! > mount_race 2 > wait $pid > echo "Failed to trigger it, restarting..." > done > > rm /tmp/mount_bug >} > >main
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 255047
:
224098
| 237865