* [PATCH] autofs4 - avoid panic on bind mount of autofs owned directory (fwd)
@ 2005-06-04 6:10 raven
0 siblings, 0 replies; only message in thread
From: raven @ 2005-06-04 6:10 UTC (permalink / raw)
To: linux-fsdevel, Kernel Mailing List
---------- Forwarded message ----------
Date: Sat, 4 Jun 2005 14:02:36 +0800 (WST)
From: raven@themaw.net
To: Andrew Morton <akpm@osdl.org>
Cc: Dan@Merillat.org, Steinar H. Gunderson <sgunderson@bigfoot.com>,
Michael Blandford <michael@kmaclub.com>, Jeff Moyer <jmoyer@redhat.com>
Subject: [PATCH] autofs4 - avoid panic on bind mount of autofs owned directory
While this is not a solution to bind and move mounts on autofs owned
directories it is necessary to fix the trady error handling.
At least it avoids the kernel panic I observed checking out bug #4589.
Signed-off-by: Ian Kent <raven@themaw.net>
diff -Nurp linux-2.6.12-rc5-mm1.orig/fs/autofs4/autofs_i.h linux-2.6.12-rc5-mm1/fs/autofs4/autofs_i.h
--- linux-2.6.12-rc5-mm1.orig/fs/autofs4/autofs_i.h 2005-05-29 14:37:27.000000000 +0800
+++ linux-2.6.12-rc5-mm1/fs/autofs4/autofs_i.h 2005-05-29 14:32:35.000000000 +0800
@@ -185,6 +185,19 @@ int autofs4_wait(struct autofs_sb_info *
int autofs4_wait_release(struct autofs_sb_info *,autofs_wqt_t,int);
void autofs4_catatonic_mode(struct autofs_sb_info *);
+static inline int autofs4_follow_mount(struct vfsmount **mnt, struct dentry **dentry)
+{
+ int res = 0;
+
+ while (d_mountpoint(*dentry)) {
+ int followed = follow_down(mnt, dentry);
+ if (!followed)
+ break;
+ res = 1;
+ }
+ return res;
+}
+
static inline int simple_positive(struct dentry *dentry)
{
return dentry->d_inode && !d_unhashed(dentry);
diff -Nurp linux-2.6.12-rc5-mm1.orig/fs/autofs4/expire.c linux-2.6.12-rc5-mm1/fs/autofs4/expire.c
--- linux-2.6.12-rc5-mm1.orig/fs/autofs4/expire.c 2005-05-29 14:37:27.000000000 +0800
+++ linux-2.6.12-rc5-mm1/fs/autofs4/expire.c 2005-05-29 14:32:35.000000000 +0800
@@ -56,12 +56,9 @@ static int autofs4_check_mount(struct vf
mntget(mnt);
dget(dentry);
- if (!follow_down(&mnt, &dentry))
+ if (!autofs4_follow_mount(&mnt, &dentry))
goto done;
- while (d_mountpoint(dentry) && follow_down(&mnt, &dentry))
- ;
-
/* This is an autofs submount, we can't expire it */
if (is_autofs4_dentry(dentry))
goto done;
diff -Nurp linux-2.6.12-rc5-mm1.orig/fs/autofs4/root.c linux-2.6.12-rc5-mm1/fs/autofs4/root.c
--- linux-2.6.12-rc5-mm1.orig/fs/autofs4/root.c 2005-05-29 14:37:27.000000000 +0800
+++ linux-2.6.12-rc5-mm1/fs/autofs4/root.c 2005-05-29 14:32:35.000000000 +0800
@@ -205,7 +205,11 @@ static int autofs4_dir_open(struct inode
struct vfsmount *fp_mnt = mntget(mnt);
struct dentry *fp_dentry = dget(dentry);
- while (follow_down(&fp_mnt, &fp_dentry) && d_mountpoint(fp_dentry));
+ if (!autofs4_follow_mount(&fp_mnt, &fp_dentry)) {
+ dput(fp_dentry);
+ mntput(fp_mnt);
+ return -ENOENT;
+ }
fp = dentry_open(fp_dentry, fp_mnt, file->f_flags);
status = PTR_ERR(fp);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-06-04 6:19 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-04 6:10 [PATCH] autofs4 - avoid panic on bind mount of autofs owned directory (fwd) raven
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).