[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <165751053430.210556.5634228273667507299.stgit@donald.themaw.net>
Date: Mon, 11 Jul 2022 11:37:35 +0800
From: Ian Kent <raven@...maw.net>
To: Al Viro <viro@...IV.linux.org.uk>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
David Howells <dhowells@...hat.com>,
Miklos Szeredi <miklos@...redi.hu>,
linux-fsdevel <linux-fsdevel@...r.kernel.org>,
Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: [PATCH 0/3] autofs: fix may_umount_tree()
The function used by autofs to check if a tree of mounts may be umounted
doesn't work with mount namespaces.
Some time ago an attempt to fix it, appart from the implementation being
wrong, failed to take advantage of cases that allowed the check to
terminate early and so was too inefficient to be considered for merge.
This series utilizes cases for which the check can be terminated early
as best it can.
The patches in this series are prefixed with vfs becuase they are
changes to the VFS code but the only caller of the may_umount_tree()
function is the autofs file system.
For the interested here is a procedure that can be used to reproduce
the problem on a current kernel:
- Add this line to /etc/auto.master:
/- /etc/auto.test -t 5
- create the map /etc/auto.test as:
/test -fstype=tmpfs :tmpfs
- Enable debug logging in automount:
sed -i '/^#logging =/c logging = debug' /etc/autofs.conf
systemctl restart autofs.service
The autofs debug logging output can be observed in another terminal
using "journalctl -f".
Use the following script to run the two tests below.
$ cat /usr/local/bin/test.sh
#!/bin/sh
set -e
exec > >(logger --id=$$) 2>&1
echo Starting test
# Change to the /test directory to keep the mount active
cd /test
grep /test /proc/self/mountinfo
sleep 10
echo Ending test
1. Run the test script as root from the root mount namespace.
- observe that automount reports "expire_proc_direct: 1 remaining in /-"
until after the script exits.
- correct behaviour.
2. Run the test script as root from a new mount namespace by using:
# unshare -m --propagation unchanged test.sh
- Observe that automount reports "expiring path /test" before the
script has exited and tries to unmount /test.
This fails with ">> umount: /test: target is busy." until the script
exits.
- incorrect behaviour.
Signed-off-by: Ian Kent <raven@...maw.net>
---
Ian Kent (3):
vfs: track count of child mounts
vfs: add propagate_mount_tree_busy() helper
vfs: make may_umount_tree() mount namespace aware
fs/autofs/expire.c | 14 ++++++++--
fs/mount.h | 1 +
fs/namespace.c | 40 +++++++++++++++++++---------
fs/pnode.c | 61 +++++++++++++++++++++++++++++++++++++++++++
fs/pnode.h | 1 +
include/linux/mount.h | 5 +++-
6 files changed, 107 insertions(+), 15 deletions(-)
--
Ian
Powered by blists - more mailing lists