Re: [PATCH 2/2] autofs: dont trigger mount if it cant succeed
Christian Brauner <[email protected]> Tue, 11 Nov 2025 11:19:59 +0100
| Newsgroups | org.kernel.vger.autofs,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <20251111-zunahm-endeffekt-c8fb3f90a365@brauner> |
On Tue, Nov 11, 2025 at 02:04:39PM +0800, Ian Kent wrote: > If a mount namespace contains autofs mounts, and they are propagation > private, and there is no namespace specific automount daemon to handle > possible automounting then attempted path resolution will loop until > MAXSYMLINKS is reached before failing causing quite a bit of noise in > the log. > > Add a check for this in autofs ->d_automount() so that the VFS can > immediately return an error in this case. Since the mount is propagation > private an EPERM return seems most appropriate. > > Signed-off-by: Ian Kent <[email protected]> > --- > fs/autofs/autofs_i.h | 4 ++++ > fs/autofs/inode.c | 1 + > fs/autofs/root.c | 8 ++++++++ > fs/namespace.c | 6 ++++++ > include/linux/fs.h | 1 + > 5 files changed, 20 insertions(+) > > diff --git a/fs/autofs/autofs_i.h b/fs/autofs/autofs_i.h > index 23cea74f9933..34533587c66b 100644 > --- a/fs/autofs/autofs_i.h > +++ b/fs/autofs/autofs_i.h > @@ -16,6 +16,7 @@ > #include <linux/wait.h> > #include <linux/sched.h> > #include <linux/sched/signal.h> > +#include <uapi/linux/mount.h> > #include <linux/mount.h> > #include <linux/namei.h> > #include <linux/uaccess.h> > @@ -109,11 +110,14 @@ struct autofs_wait_queue { > #define AUTOFS_SBI_STRICTEXPIRE 0x0002 > #define AUTOFS_SBI_IGNORE 0x0004 > > +struct mnt_namespace; > + > struct autofs_sb_info { > u32 magic; > int pipefd; > struct file *pipe; > struct pid *oz_pgrp; > + struct mnt_namespace *owner; > int version; > int sub_version; > int min_proto; > diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c > index f5c16ffba013..0a29761f39c0 100644 > --- a/fs/autofs/inode.c > +++ b/fs/autofs/inode.c > @@ -251,6 +251,7 @@ static struct autofs_sb_info *autofs_alloc_sbi(void) > sbi->min_proto = AUTOFS_MIN_PROTO_VERSION; > sbi->max_proto = AUTOFS_MAX_PROTO_VERSION; > sbi->pipefd = -1; > + sbi->owner = current->nsproxy->mnt_ns; ns_ref_get() Can be called directly on the mount namespace.