RE: [PATCH] SUNRPC: Prevent kernel stack corruption on long values of flush

2012-10-18 Thread David Laight
> ... > long is always the same or bigger then a pointer > (A pointer must always fit in a long) > ... Linux may make that assumption, but it doesn't have to be true. 64bit windows still has 32bit long. C99 inttypes.h defines [u]intptr_t to be an integral type that is large enough to hold a pointe

Re: [PATCH] SUNRPC: Prevent kernel stack corruption on long values of flush

2012-10-17 Thread J. Bruce Fields
On Wed, Oct 17, 2012 at 01:59:39PM -0400, Sasha Levin wrote: > On Wed, Jul 18, 2012 at 1:39 PM, J. Bruce Fields wrote: > > On Tue, Jul 17, 2012 at 12:01:26AM +0200, Sasha Levin wrote: > >> The buffer size in read_flush() is too small for the longest possible > >> values > >> for it. This can lead

Re: [PATCH] SUNRPC: Prevent kernel stack corruption on long values of flush

2012-10-17 Thread Boaz Harrosh
On 07/18/2012 01:55 PM, Jim Rees wrote: > Dave Jones wrote: > > > Unsigned long isn't necessarily 32 bits. > On 64-bit systems %lu can be up to 18446744073709551615 > > Thanks. You caught me thinking "Intel." How embarrassing. What? why even on Intel-64 long is 64bit. long is always the

Re: [PATCH] SUNRPC: Prevent kernel stack corruption on long values of flush

2012-10-17 Thread Sasha Levin
On Wed, Jul 18, 2012 at 1:39 PM, J. Bruce Fields wrote: > On Tue, Jul 17, 2012 at 12:01:26AM +0200, Sasha Levin wrote: >> The buffer size in read_flush() is too small for the longest possible values >> for it. This can lead to a kernel stack corruption: > > Thanks! I've just stumbled on this cras

Re: [PATCH] SUNRPC: Prevent kernel stack corruption on long values of flush

2012-07-18 Thread Jim Rees
Sasha Levin wrote: > Learning from what happened in this specific case, there are actually 2 issues here: > > - Array size was constant and too small, which is solved by the patch above. > - We were blindly trying to sprintf() into that array, this issue may pop back up if someone de

Re: [PATCH] SUNRPC: Prevent kernel stack corruption on long values of flush

2012-07-18 Thread Sasha Levin
On 07/18/2012 11:33 PM, Sasha Levin wrote: > On 07/18/2012 11:08 PM, J. Bruce Fields wrote: >> On Wed, Jul 18, 2012 at 04:00:49PM -0400, Jim Rees wrote: >>> J. Bruce Fields wrote: >>> >>> On Tue, Jul 17, 2012 at 12:01:26AM +0200, Sasha Levin wrote: >>> > The buffer size in read_flush() is too s

Re: [PATCH] SUNRPC: Prevent kernel stack corruption on long values of flush

2012-07-18 Thread J. Bruce Fields
On Wed, Jul 18, 2012 at 04:00:49PM -0400, Jim Rees wrote: > J. Bruce Fields wrote: > > On Tue, Jul 17, 2012 at 12:01:26AM +0200, Sasha Levin wrote: > > The buffer size in read_flush() is too small for the longest possible > values > > for it. This can lead to a kernel stack corruption: >

Re: [PATCH] SUNRPC: Prevent kernel stack corruption on long values of flush

2012-07-18 Thread Jim Rees
Dave Jones wrote: On Wed, Jul 18, 2012 at 04:00:49PM -0400, Jim Rees wrote: > You could use something like: > > char tbuf[sizeof (unsigned long) * 24 / 10 + 1 + 2]; /* + 2 for final "\n\0" */ > > since there are roughly 10 bits for every 3 decimal digits. > > But

Re: [PATCH] SUNRPC: Prevent kernel stack corruption on long values of flush

2012-07-18 Thread Dave Jones
On Wed, Jul 18, 2012 at 04:00:49PM -0400, Jim Rees wrote: > You could use something like: > > char tbuf[sizeof (unsigned long) * 24 / 10 + 1 + 2]; /* + 2 for final > "\n\0" */ > > since there are roughly 10 bits for every 3 decimal digits. > > But I'm obviously confused, because I

Re: [PATCH] SUNRPC: Prevent kernel stack corruption on long values of flush

2012-07-18 Thread Jim Rees
J. Bruce Fields wrote: On Tue, Jul 17, 2012 at 12:01:26AM +0200, Sasha Levin wrote: > The buffer size in read_flush() is too small for the longest possible values > for it. This can lead to a kernel stack corruption: Thanks! > > diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache

Re: [PATCH] SUNRPC: Prevent kernel stack corruption on long values of flush

2012-07-18 Thread J. Bruce Fields
On Tue, Jul 17, 2012 at 12:01:26AM +0200, Sasha Levin wrote: > The buffer size in read_flush() is too small for the longest possible values > for it. This can lead to a kernel stack corruption: Thanks! > > diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c > index 2afd2a8..f86d95e 100644 > ---

[PATCH] SUNRPC: Prevent kernel stack corruption on long values of flush

2012-07-16 Thread Sasha Levin
The buffer size in read_flush() is too small for the longest possible values for it. This can lead to a kernel stack corruption: [ 43.047329] Kernel panic - not syncing: stack-protector: Kernel stack is corrupted in: 833e64b4 [ 43.047329] [ 43.049030] Pid: 6015, comm: trinity-child1