Re: [patch-2.3.99-pre7-8] BUGfix - proc_pid_readlink() and mnt_count

From: Alexander Viro (viro@math.psu.edu)
Date: Tue May 09 2000 - 10:35:52 EST


On Tue, 9 May 2000, Tigran Aivazian wrote:

> Hi Alexander,
>
> Are you sure that proc_pid_readlink() needs those dput()/mntput(), since
> sys_readlink() does dput()/mntput() them anyway?

HUH? It does, but for completely different object.

> This patch fixes the old "lsof(8) causes oops in 2.3.99-pre7-8" problem
> but I was not 100% sure in its correctness (i.e. there must have been some
> reason for dput/mntput in proc_pid_readlink?) so I did not send it to
> Linus. Comments, please?

It's incorrect. However, there actually _is_ a problem in proc_pid_readlink()
and I wonder how came that it didn't bite us before. Try the following
and see if it helps:

--- ../../../2.3.99-pre7-8/fs/proc/base.c Tue May 9 11:27:28 2000
+++ base.c Tue May 9 11:34:04 2000
@@ -446,18 +446,19 @@
 {
        int error;
        struct inode *inode = dentry->d_inode;
+ struct dentry *de;
        struct vfsmount *mnt;

        error = proc_permission(inode, MAY_EXEC);
        if (error)
                goto out;

- error = inode->u.proc_i.op.proc_get_link(inode, &dentry, &mnt);
+ error = inode->u.proc_i.op.proc_get_link(inode, &de, &mnt);
        if (error)
                goto out;

- error = do_proc_readlink(dentry, mnt, buffer, buflen);
- dput(dentry);
+ error = do_proc_readlink(de, mnt, buffer, buflen);
+ dput(de);
        mntput(mnt);
 out:

... and yes, I feel myself like an idiot, why are you asking?
                                                                Al
>
> Also, although lsof now works, /proc still (with or without patch ) cannot
> be umounted (even without any apparent references to it) so one should
> still investigate a bit further and see what keeps it busy.. (I will try
> and look into it now, unless you confirm that the reasons are known and
> elsewhere)
>
> Regards,
> Tigran
>
> --- linux/fs/proc/base.c Tue May 9 08:40:26 2000
> +++ work/fs/proc/base.c Tue May 9 16:06:05 2000
> @@ -457,8 +457,6 @@
> goto out;
>
> error = do_proc_readlink(dentry, mnt, buffer, buflen);
> - dput(dentry);
> - mntput(mnt);
> out:
> return error;
> }
>
>
>
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.rutgers.edu
> Please read the FAQ at http://www.tux.org/lkml/
>

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon May 15 2000 - 21:00:13 EST