* [PATCH] NFSD: Don't hold unrefcounted creds over call to nfsd_setuser()
@ 2009-07-02 13:35 David Howells
[not found] ` <20090702133532.28297.89635.stgit-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>
0 siblings, 1 reply; 8+ messages in thread
From: David Howells @ 2009-07-02 13:35 UTC (permalink / raw)
To: bfields, steved, rasmus-tUP8e6pgWdNlY7y4Fx5NiA
Cc: linux-nfs, linux-kernel, dhowells
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.
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
^ permalink raw reply related [flat|nested] 8+ messages in thread[parent not found: <20090702133532.28297.89635.stgit-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>]
* Re: [PATCH] NFSD: Don't hold unrefcounted creds over call to nfsd_setuser() [not found] ` <20090702133532.28297.89635.stgit-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org> @ 2009-07-02 13:59 ` Steve Dickson 2009-07-02 20:39 ` J. Bruce Fields 1 sibling, 0 replies; 8+ messages in thread From: Steve Dickson @ 2009-07-02 13:59 UTC (permalink / raw) To: David Howells Cc: bfields, rasmus-tUP8e6pgWdNlY7y4Fx5NiA, linux-nfs, linux-kernel On 07/02/2009 09:35 AM, 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. > > Possibly fh_verify() should return the creds to use. > > Signed-off-by: David Howells <dhowells@redhat.com> Tested-and-Verified-By: Steve Dickson <steved@redhat.com> ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] NFSD: Don't hold unrefcounted creds over call to nfsd_setuser() [not found] ` <20090702133532.28297.89635.stgit-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org> 2009-07-02 13:59 ` Steve Dickson @ 2009-07-02 20:39 ` J. Bruce Fields 2009-07-02 21:31 ` David Howells 1 sibling, 1 reply; 8+ messages in thread From: J. Bruce Fields @ 2009-07-02 20:39 UTC (permalink / raw) To: David Howells Cc: steved, rasmus-tUP8e6pgWdNlY7y4Fx5NiA, linux-nfs, linux-kernel 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 > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] NFSD: Don't hold unrefcounted creds over call to nfsd_setuser() 2009-07-02 20:39 ` J. Bruce Fields @ 2009-07-02 21:31 ` David Howells 2009-07-02 23:09 ` J. Bruce Fields 0 siblings, 1 reply; 8+ messages in thread From: David Howells @ 2009-07-02 21:31 UTC (permalink / raw) To: J. Bruce Fields Cc: dhowells, steved, rasmus-tUP8e6pgWdNlY7y4Fx5NiA, linux-nfs, linux-kernel J. Bruce Fields <bfields@fieldses.org> wrote: > Got it, thanks. How easy is it to hit this case? (Just wondering > whether to submit for stable.) Actually, one of the problems with it is that the file is opened using the old creds, cached across the call to nfsd_setuser(). David ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] NFSD: Don't hold unrefcounted creds over call to nfsd_setuser() 2009-07-02 21:31 ` David Howells @ 2009-07-02 23:09 ` J. Bruce Fields 2009-07-03 14:22 ` J. Bruce Fields 0 siblings, 1 reply; 8+ messages in thread From: J. Bruce Fields @ 2009-07-02 23:09 UTC (permalink / raw) To: David Howells Cc: steved, rasmus-tUP8e6pgWdNlY7y4Fx5NiA, linux-nfs, linux-kernel On Thu, Jul 02, 2009 at 10:31:33PM +0100, David Howells wrote: > J. Bruce Fields <bfields@fieldses.org> wrote: > > > Got it, thanks. How easy is it to hit this case? (Just wondering > > whether to submit for stable.) > > Actually, one of the problems with it is that the file is opened using the old > creds, cached across the call to nfsd_setuser(). Oops, got it. That answers that question.... --b. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] NFSD: Don't hold unrefcounted creds over call to nfsd_setuser() 2009-07-02 23:09 ` J. Bruce Fields @ 2009-07-03 14:22 ` J. Bruce Fields 2009-07-03 14:41 ` David Howells 0 siblings, 1 reply; 8+ messages in thread From: J. Bruce Fields @ 2009-07-03 14:22 UTC (permalink / raw) To: David Howells Cc: steved, rasmus-tUP8e6pgWdNlY7y4Fx5NiA, linux-nfs, linux-kernel On Thu, Jul 02, 2009 at 07:09:55PM -0400, bfields wrote: > On Thu, Jul 02, 2009 at 10:31:33PM +0100, David Howells wrote: > > J. Bruce Fields <bfields@fieldses.org> wrote: > > > > > Got it, thanks. How easy is it to hit this case? (Just wondering > > > whether to submit for stable.) > > > > Actually, one of the problems with it is that the file is opened using the old > > creds, cached across the call to nfsd_setuser(). > > Oops, got it. That answers that question.... Also: the problem was introduced by 745ca2475a6ac596e3d8d37c2759c0fbe2586227, right? Or does it not actually manifest till a little later? --b. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] NFSD: Don't hold unrefcounted creds over call to nfsd_setuser() 2009-07-03 14:22 ` J. Bruce Fields @ 2009-07-03 14:41 ` David Howells 2009-07-03 15:47 ` J. Bruce Fields 0 siblings, 1 reply; 8+ messages in thread From: David Howells @ 2009-07-03 14:41 UTC (permalink / raw) To: J. Bruce Fields Cc: dhowells, steved, rasmus-tUP8e6pgWdNlY7y4Fx5NiA, linux-nfs, linux-kernel J. Bruce Fields <bfields@fieldses.org> wrote: > Also: the problem was introduced by > 745ca2475a6ac596e3d8d37c2759c0fbe2586227, right? Yes. David ^ permalink raw reply [flat|nested] 8+ messages in thread
* NFSD: Don't hold unrefcounted creds over call to nfsd_setuser() 2009-07-03 14:41 ` David Howells @ 2009-07-03 15:47 ` J. Bruce Fields 0 siblings, 0 replies; 8+ messages in thread From: J. Bruce Fields @ 2009-07-03 15:47 UTC (permalink / raw) To: Linus Torvalds Cc: David Howells, steved, rasmus-tUP8e6pgWdNlY7y4Fx5NiA, linux-nfs, linux-kernel The following patch is appropriate for 2.6.31 (and stable), and is also available from git://linux-nfs.org/~bfields/linux.git for-2.6.31 --b. commit 033a666ccb842ab4134fcd0c861d5ba9f5d6bf3a Author: David Howells <dhowells@redhat.com> Date: Thu Jul 2 14:35:32 2009 +0100 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 745ca2475a6ac596e3d8d37c2759c0fbe2586227 "CRED: Pass credentials through dentry_open()". Signed-off-by: David Howells <dhowells@redhat.com> Tested-and-Verified-By: Steve Dickson <steved@redhat.com> Cc: stable@kernel.org Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu> 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 ^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2009-07-03 15:48 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-02 13:35 [PATCH] NFSD: Don't hold unrefcounted creds over call to nfsd_setuser() David Howells
[not found] ` <20090702133532.28297.89635.stgit-S6HVgzuS8uM4Awkfq6JHfwNdhmdF6hFW@public.gmane.org>
2009-07-02 13:59 ` Steve Dickson
2009-07-02 20:39 ` J. Bruce Fields
2009-07-02 21:31 ` David Howells
2009-07-02 23:09 ` J. Bruce Fields
2009-07-03 14:22 ` J. Bruce Fields
2009-07-03 14:41 ` David Howells
2009-07-03 15:47 ` J. Bruce Fields
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox