Skip to content

Validate mountpoint on path-based unmount using statx #17481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ixhamza
Copy link
Member

@ixhamza ixhamza commented Jun 23, 2025

Motivation and Context

Use statx to verify that path-based unmounts proceed only if the mountpoint reported by statx matches the MNTTAB entry reported by libzfs, aborting the operation if they differ. Align zfs umount /path behavior with zfs umount dataset.

Supersedes: #17421

Description

When zfs umount /path is run on a bind mount, it silently unmounts the underlying dataset. This patch uses statx to detect bind mounts accurately and validate the specified path against the MNTTAB entry reported by libzfs before performing the unmount.

How Has This Been Tested?

Before

buildroot@root:~# zpool create -O mountpoint=/mnt/tank tank nvme0n1
buildroot@root:~# mkdir -p /mnt/tank-bind
buildroot@root:~# mount --bind /mnt/tank /mnt/tank-bind
buildroot@root:~# zfs umount /mnt/tank-bind
buildroot@root:~# mount | grep tank
tank on /mnt/tank-bind type zfs (rw,relatime,xattr,noacl,casesensitive)

After

buildroot@root:~# zpool create -O mountpoint=/mnt/tank tank nvme0n1
buildroot@root:~# mkdir -p /mnt/tank-bind
buildroot@root:~# mount --bind /mnt/tank /mnt/tank-bind
buildroot@root:~# zfs umount /mnt/tank-bind
cannot unmount '/mnt/tank-bind': not a original mountpoint
buildroot@root:~# mount | grep tank
tank on /mnt/tank type zfs (rw,relatime,xattr,noacl,casesensitive)
tank on /mnt/tank-bind type zfs (rw,relatime,xattr,noacl,casesensitive)
buildroot@root:~# umount /mnt/tank-bind
buildroot@root:~# mount | grep tank
tank on /mnt/tank type zfs (rw,relatime,xattr,noacl,casesensitive)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Quality assurance (non-breaking change which makes the code more robust against bugs)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

@amotin amotin added the Status: Code Review Needed Ready for review and testing label Jun 23, 2025
@ixhamza ixhamza force-pushed the NAS-136078 branch 2 times, most recently from c58c7a2 to 9cd47e4 Compare June 24, 2025 13:04
Use statx to verify that path-based unmounts proceed only if the
mountpoint reported by statx matches the MNTTAB entry reported by
libzfs, aborting the operation if they differ. Align
`zfs umount /path` behavior with `zfs umount dataset`.

Signed-off-by: Ameer Hamza <ahamza@ixsystems.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Code Review Needed Ready for review and testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants