lkml.org 
[lkml]   [2009]   [Jul]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] NFSD: Don't hold unrefcounted creds over call to nfsd_setuser()
From
On Thu, Jul 02, 2009 at 02:35:32PM +0100, David Howells wrote:
> nfsd_open() gets an unrefcounted pointer to the current process's effective
> credentials at the top of the function, then calls nfsd_setuser() via
> fh_verify() - which may replace and destroy the current process's effective
> credentials - and then passes the unrefcounted pointer to dentry_open() - but
> the credentials may have been destroyed by this point.
>
> Instead, the value from current_cred() should be passed directly to
> dentry_open() as one of its arguments, rather than being cached in a variable.

Got it, thanks. How easy is it to hit this case? (Just wondering
whether to submit for stable.)

--b.

>
> Possibly fh_verify() should return the creds to use.
>
> Signed-off-by: David Howells <dhowells@redhat.com>
> ---
>
> fs/nfsd/vfs.c | 3 +--
> 1 files changed, 1 insertions(+), 2 deletions(-)
>
>
> diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
> index 4145083..23341c1 100644
> --- a/fs/nfsd/vfs.c
> +++ b/fs/nfsd/vfs.c
> @@ -678,7 +678,6 @@ __be32
> nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, int type,
> int access, struct file **filp)
> {
> - const struct cred *cred = current_cred();
> struct dentry *dentry;
> struct inode *inode;
> int flags = O_RDONLY|O_LARGEFILE;
> @@ -733,7 +732,7 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, int type,
> vfs_dq_init(inode);
> }
> *filp = dentry_open(dget(dentry), mntget(fhp->fh_export->ex_path.mnt),
> - flags, cred);
> + flags, current_cred());
> if (IS_ERR(*filp))
> host_err = PTR_ERR(*filp);
> else
>


\
 
 \ /
  Last update: 2009-07-02 22:43    [W:0.057 / U:0.476 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site