* Re: NFS/credentials leak in 2.6.29-rc1
2009-01-21 12:23 ` David Howells
@ 2009-01-21 12:37 ` Evgeniy Polyakov
2009-01-21 22:39 ` J. Bruce Fields
` (2 more replies)
2009-01-21 13:17 ` David Howells
` (2 subsequent siblings)
3 siblings, 3 replies; 27+ messages in thread
From: Evgeniy Polyakov @ 2009-01-21 12:37 UTC (permalink / raw)
To: David Howells; +Cc: J. Bruce Fields, Trond Myklebust, linux-fsdevel
On Wed, Jan 21, 2009 at 12:23:09PM +0000, David Howells (dhowells@redhat.com) wrote:
> J. Bruce Fields <bfields@fieldses.org> wrote:
>
> > - Finally, we put_cred(override_creds(new)). That modifies
> > current->cred again, putting the old value and getting the
> > new.
> >
> > Hm. But that last part's not OK; aren't we still holding our own
> > reference to new, in addition to the one that override_creds() just
> > took? So I think we need the following?
>
> Yes, you're right. override_creds() takes an extra ref on the argument it is
> passed, thus leaving the caller with their original reference intact.
>
> So really, you don't want to call override_creds() as that will cost you an
> extra atomic_inc() and atomic_dec_and_test(). I recommend you replace:
>
> put_cred(override_creds(new));
>
> with:
>
> revert_creds(new);
>
> I think that should do the right thing. It may look a bit odd, but it'll be
> quicker. If you object to using revert_creds)( because of the name, we can
> come up with an alternative name.
With additional put_cred, i.e.:
put_cred(override_creds(new));
put_cred(new);
return 0;
I got following fun tcpdump and failed mount (it stuck, but can be interrupted):
15:34:41.253911 IP 77.88.20.183.1835336279 > 77.88.20.182.2049: 44 null
15:34:41.253916 IP 77.88.20.182.2049 > 77.88.20.183.728: . ack 44 win 88 <nop,nop,timestamp 125462 37402358>
15:34:41.254103 IP 77.88.20.182.2049 > 77.88.20.183.1835336279: reply ok 28 null
15:34:41.254229 IP 77.88.20.183.728 > 77.88.20.182.2049: . ack 29 win 89 <nop,nop,timestamp 37402358 125463>
15:34:41.254238 IP 77.88.20.183.1852113495 > 77.88.20.182.2049: 44 null
15:34:41.254271 IP 77.88.20.182.2049 > 77.88.20.183.1852113495: reply ok 28 null
15:34:41.254378 IP 77.88.20.183.1868890711 > 77.88.20.182.2049: 100 fsinfo [|nfs]
15:34:41.254411 IP 77.88.20.182.2049 > 77.88.20.183.1868890711: reply ok 36 fsinfo [|nfs]
15:34:41.254528 IP 77.88.20.183.1885667927 > 77.88.20.182.2049: 100 fsinfo [|nfs]
15:34:41.254555 IP 77.88.20.182.2049 > 77.88.20.183.1885667927: reply ok 36 fsinfo [|nfs]
But no corruption in the dmesg (like oops or bug).
--
Evgeniy Polyakov
^ permalink raw reply [flat|nested] 27+ messages in thread* Re: NFS/credentials leak in 2.6.29-rc1
2009-01-21 12:37 ` Evgeniy Polyakov
@ 2009-01-21 22:39 ` J. Bruce Fields
2009-01-21 22:46 ` Evgeniy Polyakov
2009-01-27 0:49 ` J. Bruce Fields
2009-02-05 13:22 ` David Howells
2 siblings, 1 reply; 27+ messages in thread
From: J. Bruce Fields @ 2009-01-21 22:39 UTC (permalink / raw)
To: Evgeniy Polyakov; +Cc: David Howells, Trond Myklebust, linux-fsdevel
On Wed, Jan 21, 2009 at 03:37:28PM +0300, Evgeniy Polyakov wrote:
> On Wed, Jan 21, 2009 at 12:23:09PM +0000, David Howells (dhowells@redhat.com) wrote:
> > J. Bruce Fields <bfields@fieldses.org> wrote:
> >
> > > - Finally, we put_cred(override_creds(new)). That modifies
> > > current->cred again, putting the old value and getting the
> > > new.
> > >
> > > Hm. But that last part's not OK; aren't we still holding our own
> > > reference to new, in addition to the one that override_creds() just
> > > took? So I think we need the following?
> >
> > Yes, you're right. override_creds() takes an extra ref on the argument it is
> > passed, thus leaving the caller with their original reference intact.
> >
> > So really, you don't want to call override_creds() as that will cost you an
> > extra atomic_inc() and atomic_dec_and_test(). I recommend you replace:
> >
> > put_cred(override_creds(new));
> >
> > with:
> >
> > revert_creds(new);
> >
> > I think that should do the right thing. It may look a bit odd, but it'll be
> > quicker. If you object to using revert_creds)( because of the name, we can
> > come up with an alternative name.
>
> With additional put_cred, i.e.:
>
> put_cred(override_creds(new));
> put_cred(new);
> return 0;
>
> I got following fun tcpdump and failed mount (it stuck, but can be interrupted):
I'm really bad at reading tcpdump. Where's the problem here? It looks
like every call gets a reply.
--b.
>
> 15:34:41.253911 IP 77.88.20.183.1835336279 > 77.88.20.182.2049: 44 null
> 15:34:41.253916 IP 77.88.20.182.2049 > 77.88.20.183.728: . ack 44 win 88 <nop,nop,timestamp 125462 37402358>
> 15:34:41.254103 IP 77.88.20.182.2049 > 77.88.20.183.1835336279: reply ok 28 null
> 15:34:41.254229 IP 77.88.20.183.728 > 77.88.20.182.2049: . ack 29 win 89 <nop,nop,timestamp 37402358 125463>
> 15:34:41.254238 IP 77.88.20.183.1852113495 > 77.88.20.182.2049: 44 null
> 15:34:41.254271 IP 77.88.20.182.2049 > 77.88.20.183.1852113495: reply ok 28 null
> 15:34:41.254378 IP 77.88.20.183.1868890711 > 77.88.20.182.2049: 100 fsinfo [|nfs]
> 15:34:41.254411 IP 77.88.20.182.2049 > 77.88.20.183.1868890711: reply ok 36 fsinfo [|nfs]
> 15:34:41.254528 IP 77.88.20.183.1885667927 > 77.88.20.182.2049: 100 fsinfo [|nfs]
> 15:34:41.254555 IP 77.88.20.182.2049 > 77.88.20.183.1885667927: reply ok 36 fsinfo [|nfs]
>
> But no corruption in the dmesg (like oops or bug).
>
> --
> Evgeniy Polyakov
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: NFS/credentials leak in 2.6.29-rc1
2009-01-21 22:39 ` J. Bruce Fields
@ 2009-01-21 22:46 ` Evgeniy Polyakov
2009-01-21 23:18 ` J. Bruce Fields
0 siblings, 1 reply; 27+ messages in thread
From: Evgeniy Polyakov @ 2009-01-21 22:46 UTC (permalink / raw)
To: J. Bruce Fields; +Cc: David Howells, Trond Myklebust, linux-fsdevel
On Wed, Jan 21, 2009 at 05:39:19PM -0500, J. Bruce Fields (bfields@fieldses.org) wrote:
> > I got following fun tcpdump and failed mount (it stuck, but can be interrupted):
>
> I'm really bad at reading tcpdump. Where's the problem here? It looks
> like every call gets a reply.
Port fields are fun
> > 15:34:41.253911 IP addr1.1835336279 > addr2.2049: 44 null
^^^^^^^^^^ vs ^^^^
It is likely copied skb corruption, ports change, but acks correspond
sometimes.
> > 15:34:41.253916 IP addr2.2049 > addr1.728: . ack 44 win 88 <nop,nop,timestamp 125462 37402358>
> > 15:34:41.254103 IP addr2.2049 > addr1.1835336279: reply ok 28 null
> > 15:34:41.254229 IP addr1.728 > addr2.2049: . ack 29 win 89 <nop,nop,timestamp 37402358 125463>
> > 15:34:41.254238 IP addr1.1852113495 > addr2.2049: 44 null
> > 15:34:41.254271 IP addr2.2049 > addr1.1852113495: reply ok 28 null
> > 15:34:41.254378 IP addr1.1868890711 > addr2.2049: 100 fsinfo [|nfs]
> > 15:34:41.254411 IP addr2.2049 > addr1.1868890711: reply ok 36 fsinfo [|nfs]
> > 15:34:41.254528 IP addr1.1885667927 > addr2.2049: 100 fsinfo [|nfs]
> > 15:34:41.254555 IP addr2.2049 > addr1.1885667927: reply ok 36 fsinfo [|nfs]
--
Evgeniy Polyakov
^ permalink raw reply [flat|nested] 27+ messages in thread* Re: NFS/credentials leak in 2.6.29-rc1
2009-01-21 22:46 ` Evgeniy Polyakov
@ 2009-01-21 23:18 ` J. Bruce Fields
2009-01-21 23:31 ` Evgeniy Polyakov
0 siblings, 1 reply; 27+ messages in thread
From: J. Bruce Fields @ 2009-01-21 23:18 UTC (permalink / raw)
To: Evgeniy Polyakov; +Cc: David Howells, Trond Myklebust, linux-fsdevel
On Thu, Jan 22, 2009 at 01:46:59AM +0300, Evgeniy Polyakov wrote:
> On Wed, Jan 21, 2009 at 05:39:19PM -0500, J. Bruce Fields (bfields@fieldses.org) wrote:
> > > I got following fun tcpdump and failed mount (it stuck, but can be interrupted):
> >
> > I'm really bad at reading tcpdump. Where's the problem here? It looks
> > like every call gets a reply.
>
> Port fields are fun
>
> > > 15:34:41.253911 IP addr1.1835336279 > addr2.2049: 44 null
> ^^^^^^^^^^ vs ^^^^
>
> It is likely copied skb corruption, ports change, but acks correspond
> sometimes.
Obviously it's normal that the client- and server- side ports would
differ, so I assume you meant to point out the variation in the client
port number? (1835336279, 728, 1852113495, 1868890711, 1885667927).
--b.
>
> > > 15:34:41.253916 IP addr2.2049 > addr1.728: . ack 44 win 88 <nop,nop,timestamp 125462 37402358>
> > > 15:34:41.254103 IP addr2.2049 > addr1.1835336279: reply ok 28 null
> > > 15:34:41.254229 IP addr1.728 > addr2.2049: . ack 29 win 89 <nop,nop,timestamp 37402358 125463>
> > > 15:34:41.254238 IP addr1.1852113495 > addr2.2049: 44 null
> > > 15:34:41.254271 IP addr2.2049 > addr1.1852113495: reply ok 28 null
> > > 15:34:41.254378 IP addr1.1868890711 > addr2.2049: 100 fsinfo [|nfs]
> > > 15:34:41.254411 IP addr2.2049 > addr1.1868890711: reply ok 36 fsinfo [|nfs]
> > > 15:34:41.254528 IP addr1.1885667927 > addr2.2049: 100 fsinfo [|nfs]
> > > 15:34:41.254555 IP addr2.2049 > addr1.1885667927: reply ok 36 fsinfo [|nfs]
>
> --
> Evgeniy Polyakov
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: NFS/credentials leak in 2.6.29-rc1
2009-01-21 23:18 ` J. Bruce Fields
@ 2009-01-21 23:31 ` Evgeniy Polyakov
0 siblings, 0 replies; 27+ messages in thread
From: Evgeniy Polyakov @ 2009-01-21 23:31 UTC (permalink / raw)
To: J. Bruce Fields; +Cc: David Howells, Trond Myklebust, linux-fsdevel
On Wed, Jan 21, 2009 at 06:18:11PM -0500, J. Bruce Fields (bfields@fieldses.org) wrote:
> > Port fields are fun
> >
> > > > 15:34:41.253911 IP addr1.1835336279 > addr2.2049: 44 null
> > ^^^^^^^^^^ vs ^^^^
> >
> > It is likely copied skb corruption, ports change, but acks correspond
> > sometimes.
>
> Obviously it's normal that the client- and server- side ports would
> differ, so I assume you meant to point out the variation in the client
> port number? (1835336279, 728, 1852113495, 1868890711, 1885667927).
I meant that ack still comes to the fun port, not only to correct one.
And some ports are obviously incorrect like 4 above.
--
Evgeniy Polyakov
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: NFS/credentials leak in 2.6.29-rc1
2009-01-21 12:37 ` Evgeniy Polyakov
2009-01-21 22:39 ` J. Bruce Fields
@ 2009-01-27 0:49 ` J. Bruce Fields
2009-01-27 9:26 ` Evgeniy Polyakov
2009-02-05 13:22 ` David Howells
2 siblings, 1 reply; 27+ messages in thread
From: J. Bruce Fields @ 2009-01-27 0:49 UTC (permalink / raw)
To: Evgeniy Polyakov; +Cc: David Howells, Trond Myklebust, linux-fsdevel
On Wed, Jan 21, 2009 at 03:37:28PM +0300, Evgeniy Polyakov wrote:
> With additional put_cred, i.e.:
>
> put_cred(override_creds(new));
> put_cred(new);
> return 0;
>
> I got following fun tcpdump and failed mount (it stuck, but can be interrupted):
I'm not able to reproduce this.
Have you been able to reproduce this consistently? Any further results?
If not, I'm tempted to assume you're seeing some unrelated bug.
David, can you ACK the additional put_cred()?
--b.
>
> 15:34:41.253911 IP 77.88.20.183.1835336279 > 77.88.20.182.2049: 44 null
> 15:34:41.253916 IP 77.88.20.182.2049 > 77.88.20.183.728: . ack 44 win 88 <nop,nop,timestamp 125462 37402358>
> 15:34:41.254103 IP 77.88.20.182.2049 > 77.88.20.183.1835336279: reply ok 28 null
> 15:34:41.254229 IP 77.88.20.183.728 > 77.88.20.182.2049: . ack 29 win 89 <nop,nop,timestamp 37402358 125463>
> 15:34:41.254238 IP 77.88.20.183.1852113495 > 77.88.20.182.2049: 44 null
> 15:34:41.254271 IP 77.88.20.182.2049 > 77.88.20.183.1852113495: reply ok 28 null
> 15:34:41.254378 IP 77.88.20.183.1868890711 > 77.88.20.182.2049: 100 fsinfo [|nfs]
> 15:34:41.254411 IP 77.88.20.182.2049 > 77.88.20.183.1868890711: reply ok 36 fsinfo [|nfs]
> 15:34:41.254528 IP 77.88.20.183.1885667927 > 77.88.20.182.2049: 100 fsinfo [|nfs]
> 15:34:41.254555 IP 77.88.20.182.2049 > 77.88.20.183.1885667927: reply ok 36 fsinfo [|nfs]
>
> But no corruption in the dmesg (like oops or bug).
>
> --
> Evgeniy Polyakov
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: NFS/credentials leak in 2.6.29-rc1
2009-01-27 0:49 ` J. Bruce Fields
@ 2009-01-27 9:26 ` Evgeniy Polyakov
2009-01-27 22:07 ` J. Bruce Fields
0 siblings, 1 reply; 27+ messages in thread
From: Evgeniy Polyakov @ 2009-01-27 9:26 UTC (permalink / raw)
To: J. Bruce Fields; +Cc: David Howells, Trond Myklebust, linux-fsdevel
On Mon, Jan 26, 2009 at 07:49:55PM -0500, J. Bruce Fields (bfields@fieldses.org) wrote:
> > With additional put_cred, i.e.:
> >
> > put_cred(override_creds(new));
> > put_cred(new);
> > return 0;
> >
> > I got following fun tcpdump and failed mount (it stuck, but can be interrupted):
>
> I'm not able to reproduce this.
>
> Have you been able to reproduce this consistently? Any further results?
Yes, I can easily reproduce it with the tree I work with.
But I will update to the latest git soon (likely today) and rerun the
tests, so it may happen that rc1-rc2 frame fixed the issue at least
partially. I can also turn on some debugging options if needed.
> If not, I'm tempted to assume you're seeing some unrelated bug.
>
> David, can you ACK the additional put_cred()?
--
Evgeniy Polyakov
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: NFS/credentials leak in 2.6.29-rc1
2009-01-27 9:26 ` Evgeniy Polyakov
@ 2009-01-27 22:07 ` J. Bruce Fields
2009-01-29 14:37 ` Evgeniy Polyakov
0 siblings, 1 reply; 27+ messages in thread
From: J. Bruce Fields @ 2009-01-27 22:07 UTC (permalink / raw)
To: Evgeniy Polyakov; +Cc: David Howells, Trond Myklebust, linux-fsdevel
On Tue, Jan 27, 2009 at 12:26:59PM +0300, Evgeniy Polyakov wrote:
> On Mon, Jan 26, 2009 at 07:49:55PM -0500, J. Bruce Fields (bfields@fieldses.org) wrote:
> > > With additional put_cred, i.e.:
> > >
> > > put_cred(override_creds(new));
> > > put_cred(new);
> > > return 0;
> > >
> > > I got following fun tcpdump and failed mount (it stuck, but can be interrupted):
> >
> > I'm not able to reproduce this.
> >
> > Have you been able to reproduce this consistently? Any further results?
>
> Yes, I can easily reproduce it with the tree I work with.
> But I will update to the latest git soon (likely today) and rerun the
> tests, so it may happen that rc1-rc2 frame fixed the issue at least
> partially. I can also turn on some debugging options if needed.
I took a closer look at the tcpdump output. Those numbers aren't port
numbers, they're rpc xid's: see "NFS Requests and Replies" in the
"OUTPUT FORMAT" section of the tcpdump man page. Or compare the output
of tcpdump with wireshark's output.
That still doesn't explain why you were seeing a mount hang--but some
network or other configuration problem may be the most likely
explanation.
--b.
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: NFS/credentials leak in 2.6.29-rc1
2009-01-27 22:07 ` J. Bruce Fields
@ 2009-01-29 14:37 ` Evgeniy Polyakov
2009-01-29 18:52 ` J. Bruce Fields
0 siblings, 1 reply; 27+ messages in thread
From: Evgeniy Polyakov @ 2009-01-29 14:37 UTC (permalink / raw)
To: J. Bruce Fields; +Cc: David Howells, Trond Myklebust, linux-fsdevel
On Tue, Jan 27, 2009 at 05:07:35PM -0500, J. Bruce Fields (bfields@fieldses.org) wrote:
> I took a closer look at the tcpdump output. Those numbers aren't port
> numbers, they're rpc xid's: see "NFS Requests and Replies" in the
> "OUTPUT FORMAT" section of the tcpdump man page. Or compare the output
> of tcpdump with wireshark's output.
Yup, they are definitely not network ports :)
> That still doesn't explain why you were seeing a mount hang--but some
> network or other configuration problem may be the most likely
> explanation.
I've rerun the tests with the latest git to date and I do not observe
neither leak (with credential patch applied) nor mount fail, so please
put the patch into the tree.
Feel free to add my signed/acked/tested/whatevered if needed :)
--
Evgeniy Polyakov
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: NFS/credentials leak in 2.6.29-rc1
2009-01-29 14:37 ` Evgeniy Polyakov
@ 2009-01-29 18:52 ` J. Bruce Fields
2009-01-29 19:00 ` Evgeniy Polyakov
0 siblings, 1 reply; 27+ messages in thread
From: J. Bruce Fields @ 2009-01-29 18:52 UTC (permalink / raw)
To: Evgeniy Polyakov; +Cc: David Howells, Trond Myklebust, linux-fsdevel
On Thu, Jan 29, 2009 at 05:37:53PM +0300, Evgeniy Polyakov wrote:
> On Tue, Jan 27, 2009 at 05:07:35PM -0500, J. Bruce Fields (bfields@fieldses.org) wrote:
> > I took a closer look at the tcpdump output. Those numbers aren't port
> > numbers, they're rpc xid's: see "NFS Requests and Replies" in the
> > "OUTPUT FORMAT" section of the tcpdump man page. Or compare the output
> > of tcpdump with wireshark's output.
>
> Yup, they are definitely not network ports :)
>
> > That still doesn't explain why you were seeing a mount hang--but some
> > network or other configuration problem may be the most likely
> > explanation.
>
> I've rerun the tests with the latest git to date and I do not observe
> neither leak (with credential patch applied) nor mount fail, so please
> put the patch into the tree.
Thanks for the confirmation--but I jumped the gun and already submitted
them...
> Feel free to add my signed/acked/tested/whatevered if needed :)
... and forgot to credit you--sorry, I should have. Thanks again for
catching the problem!
--b.
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: NFS/credentials leak in 2.6.29-rc1
2009-01-29 18:52 ` J. Bruce Fields
@ 2009-01-29 19:00 ` Evgeniy Polyakov
0 siblings, 0 replies; 27+ messages in thread
From: Evgeniy Polyakov @ 2009-01-29 19:00 UTC (permalink / raw)
To: J. Bruce Fields; +Cc: David Howells, Trond Myklebust, linux-fsdevel
On Thu, Jan 29, 2009 at 01:52:53PM -0500, J. Bruce Fields (bfields@fieldses.org) wrote:
> > I've rerun the tests with the latest git to date and I do not observe
> > neither leak (with credential patch applied) nor mount fail, so please
> > put the patch into the tree.
>
> Thanks for the confirmation--but I jumped the gun and already submitted
> them...
>
> > Feel free to add my signed/acked/tested/whatevered if needed :)
>
> ... and forgot to credit you--sorry, I should have. Thanks again for
> catching the problem!
No problem.
--
Evgeniy Polyakov
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: NFS/credentials leak in 2.6.29-rc1
2009-01-21 12:37 ` Evgeniy Polyakov
2009-01-21 22:39 ` J. Bruce Fields
2009-01-27 0:49 ` J. Bruce Fields
@ 2009-02-05 13:22 ` David Howells
2009-02-05 17:21 ` J. Bruce Fields
2 siblings, 1 reply; 27+ messages in thread
From: David Howells @ 2009-02-05 13:22 UTC (permalink / raw)
To: J. Bruce Fields
Cc: dhowells, Evgeniy Polyakov, Trond Myklebust, linux-fsdevel
Sorry for not replying earlier, but I've been in Australia and my home DSL
line has been down for the last two weeks.
J. Bruce Fields <bfields@fieldses.org> wrote:
> David, can you ACK the additional put_cred()?
Feel free to add my Acked-by.
David
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: NFS/credentials leak in 2.6.29-rc1
2009-02-05 13:22 ` David Howells
@ 2009-02-05 17:21 ` J. Bruce Fields
0 siblings, 0 replies; 27+ messages in thread
From: J. Bruce Fields @ 2009-02-05 17:21 UTC (permalink / raw)
To: David Howells; +Cc: Evgeniy Polyakov, Trond Myklebust, linux-fsdevel
On Thu, Feb 05, 2009 at 01:22:37PM +0000, David Howells wrote:
>
> Sorry for not replying earlier, but I've been in Australia and my home DSL
> line has been down for the last two weeks.
>
> J. Bruce Fields <bfields@fieldses.org> wrote:
>
> > David, can you ACK the additional put_cred()?
>
> Feel free to add my Acked-by.
I was impatient and already sent it upstream--but thanks for the
confirmation.--b.
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: NFS/credentials leak in 2.6.29-rc1
2009-01-21 12:23 ` David Howells
2009-01-21 12:37 ` Evgeniy Polyakov
@ 2009-01-21 13:17 ` David Howells
2009-01-21 13:18 ` Evgeniy Polyakov
2009-01-21 22:37 ` J. Bruce Fields
2009-01-22 7:08 ` David Howells
3 siblings, 1 reply; 27+ messages in thread
From: David Howells @ 2009-01-21 13:17 UTC (permalink / raw)
To: Evgeniy Polyakov
Cc: dhowells, J. Bruce Fields, Trond Myklebust, linux-fsdevel
Evgeniy Polyakov <zbr@ioremap.net> wrote:
> I got following fun tcpdump and failed mount (it stuck, but can be interrupted):
> ...
> But no corruption in the dmesg (like oops or bug).
Are you running with CONFIG_DEBUG_SLAB=y?
David
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: NFS/credentials leak in 2.6.29-rc1
2009-01-21 13:17 ` David Howells
@ 2009-01-21 13:18 ` Evgeniy Polyakov
0 siblings, 0 replies; 27+ messages in thread
From: Evgeniy Polyakov @ 2009-01-21 13:18 UTC (permalink / raw)
To: David Howells; +Cc: J. Bruce Fields, Trond Myklebust, linux-fsdevel
On Wed, Jan 21, 2009 at 01:17:02PM +0000, David Howells (dhowells@redhat.com) wrote:
> > I got following fun tcpdump and failed mount (it stuck, but can be interrupted):
> > ...
> > But no corruption in the dmesg (like oops or bug).
>
> Are you running with CONFIG_DEBUG_SLAB=y?
Nope: # CONFIG_DEBUG_KERNEL is not set
--
Evgeniy Polyakov
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: NFS/credentials leak in 2.6.29-rc1
2009-01-21 12:23 ` David Howells
2009-01-21 12:37 ` Evgeniy Polyakov
2009-01-21 13:17 ` David Howells
@ 2009-01-21 22:37 ` J. Bruce Fields
2009-01-22 7:08 ` David Howells
3 siblings, 0 replies; 27+ messages in thread
From: J. Bruce Fields @ 2009-01-21 22:37 UTC (permalink / raw)
To: David Howells; +Cc: Evgeniy Polyakov, Trond Myklebust, linux-fsdevel
On Wed, Jan 21, 2009 at 12:23:09PM +0000, David Howells wrote:
> J. Bruce Fields <bfields@fieldses.org> wrote:
>
> > - Finally, we put_cred(override_creds(new)). That modifies
> > current->cred again, putting the old value and getting the
> > new.
> >
> > Hm. But that last part's not OK; aren't we still holding our own
> > reference to new, in addition to the one that override_creds() just
> > took? So I think we need the following?
>
> Yes, you're right. override_creds() takes an extra ref on the argument it is
> passed, thus leaving the caller with their original reference intact.
>
> So really, you don't want to call override_creds() as that will cost you an
> extra atomic_inc() and atomic_dec_and_test(). I recommend you replace:
>
> put_cred(override_creds(new));
>
> with:
>
> revert_creds(new);
>
> I think that should do the right thing. It may look a bit odd, but it'll be
> quicker. If you object to using revert_creds)( because of the name, we can
> come up with an alternative name.
If the only difference is just whether it takes a reference on the
passed-in cred it might be clearest just to write
set_creds(new);
or
set_creds(get_creds(new));
depending on which you want?
In any case, yes, the revert_creds()/override_creds() names don't tell
me much.
> > Looking through nfsd_setuser(), one obvious bug: in the (flags &
> > NFSEXP_ALLSQUASH) case, we never check the return value from the
> > groups_alloc(0). If it returns NULL, we dereference it anyway.
>
> Since a zero-length groups list must be copied before writing, can I recommend
> that we make groups_alloc(0) a special case that returns pointer to a
> statically allocated groups list (after inc'ing the refcount) that represents
> a zero-length list, thus meaning groups_alloc(0) will never fail?
Is there a really big advantage to that? On the face of it it strikes
me as a weird corner case that I'll trip over every time I look at this
code.
--b.
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: NFS/credentials leak in 2.6.29-rc1
2009-01-21 12:23 ` David Howells
` (2 preceding siblings ...)
2009-01-21 22:37 ` J. Bruce Fields
@ 2009-01-22 7:08 ` David Howells
2009-01-22 16:43 ` J. Bruce Fields
3 siblings, 1 reply; 27+ messages in thread
From: David Howells @ 2009-01-22 7:08 UTC (permalink / raw)
To: J. Bruce Fields
Cc: dhowells, Evgeniy Polyakov, Trond Myklebust, linux-fsdevel
J. Bruce Fields <bfields@fieldses.org> wrote:
> If the only difference is just whether it takes a reference on the
> passed-in cred it might be clearest just to write
>
> set_creds(new);
>
> or
> set_creds(get_creds(new));
>
> depending on which you want?
The former would be preferable, if it transfers the reference on the creds to
the task_struct, thus eliminating the need for a put_cred().
> In any case, yes, the revert_creds()/override_creds() names don't tell
> me much.
>
> > > Looking through nfsd_setuser(), one obvious bug: in the (flags &
> > > NFSEXP_ALLSQUASH) case, we never check the return value from the
> > > groups_alloc(0). If it returns NULL, we dereference it anyway.
> >
> > Since a zero-length groups list must be copied before writing, can I recommend
> > that we make groups_alloc(0) a special case that returns pointer to a
> > statically allocated groups list (after inc'ing the refcount) that represents
> > a zero-length list, thus meaning groups_alloc(0) will never fail?
>
> Is there a really big advantage to that? On the face of it it strikes
> me as a weird corner case that I'll trip over every time I look at this
> code.
It'll remove a potential OOM condition. It's a minor optimisation, I think.
David
^ permalink raw reply [flat|nested] 27+ messages in thread* Re: NFS/credentials leak in 2.6.29-rc1
2009-01-22 7:08 ` David Howells
@ 2009-01-22 16:43 ` J. Bruce Fields
0 siblings, 0 replies; 27+ messages in thread
From: J. Bruce Fields @ 2009-01-22 16:43 UTC (permalink / raw)
To: David Howells; +Cc: Evgeniy Polyakov, Trond Myklebust, linux-fsdevel
On Thu, Jan 22, 2009 at 07:08:33AM +0000, David Howells wrote:
> J. Bruce Fields <bfields@fieldses.org> wrote:
>
> > If the only difference is just whether it takes a reference on the
> > passed-in cred it might be clearest just to write
> >
> > set_creds(new);
> >
> > or
> > set_creds(get_creds(new));
> >
> > depending on which you want?
>
> The former would be preferable, if it transfers the reference on the creds to
> the task_struct, thus eliminating the need for a put_cred().
I think I was unclear--but I think we're agreeing anyway? I was
proposing eliminating the two separate revert_creds() and
override_creds() functions and instead using a single set_creds() that
always consumes a reference to its argument, requiring the caller to
explicitly get a reference (as in the second example above) when
necessary.
> > Is there a really big advantage to that? On the face of it it strikes
> > me as a weird corner case that I'll trip over every time I look at this
> > code.
>
> It'll remove a potential OOM condition. It's a minor optimisation, I think.
OK. Let's keep things simple and set that idea aside for now; we've
lived with the current groups_alloc(0) behavior for a while, and keeping
it another kernel version or two can't be so bad.
--b.
^ permalink raw reply [flat|nested] 27+ messages in thread