提交 033a666c 编写于 作者: D David Howells 提交者: J. Bruce Fields

NFSD: Don't hold unrefcounted creds over call to nfsd_setuser()

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.

Possibly fh_verify() should return the creds to use.

This is a regression introduced by
745ca247 "CRED: Pass credentials through
dentry_open()".
Signed-off-by: NDavid Howells <dhowells@redhat.com>
Tested-and-Verified-By: NSteve Dickson <steved@redhat.com>
Cc: stable@kernel.org
Signed-off-by: NJ. Bruce Fields <bfields@citi.umich.edu>
上级 28d0325c
...@@ -678,7 +678,6 @@ __be32 ...@@ -678,7 +678,6 @@ __be32
nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, int type,
int access, struct file **filp) int access, struct file **filp)
{ {
const struct cred *cred = current_cred();
struct dentry *dentry; struct dentry *dentry;
struct inode *inode; struct inode *inode;
int flags = O_RDONLY|O_LARGEFILE; int flags = O_RDONLY|O_LARGEFILE;
...@@ -733,7 +732,7 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, int type, ...@@ -733,7 +732,7 @@ nfsd_open(struct svc_rqst *rqstp, struct svc_fh *fhp, int type,
vfs_dq_init(inode); vfs_dq_init(inode);
} }
*filp = dentry_open(dget(dentry), mntget(fhp->fh_export->ex_path.mnt), *filp = dentry_open(dget(dentry), mntget(fhp->fh_export->ex_path.mnt),
flags, cred); flags, current_cred());
if (IS_ERR(*filp)) if (IS_ERR(*filp))
host_err = PTR_ERR(*filp); host_err = PTR_ERR(*filp);
else else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册