lkml.org 
[lkml]   [2010]   [Nov]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] fs: select: fix information leak to userspace
On Tue, 16 Nov 2010 13:19:36 +0200
Boaz Harrosh <bharrosh@panasas.com> wrote:

> On 11/15/2010 09:12 PM, Eric Dumazet wrote:
> > Le dimanche 14 novembre 2010 __ 18:06 -0800, Andrew Morton a __crit :
> >> On Sun, 14 Nov 2010 12:25:33 +0300 Vasiliy Kulikov <segoon@openwall.com> wrote:
> >>>
> >>> if (timeval) {
> >>> - rtv.tv_sec = rts.tv_sec;
> >>> - rtv.tv_usec = rts.tv_nsec / NSEC_PER_USEC;
> >>> + struct timeval rtv = {
> >>> + .tv_sec = rts.tv_sec,
> >>> + .tv_usec = rts.tv_nsec / NSEC_PER_USEC
> >>> + };
> >>>
> >>> if (!copy_to_user(p, &rtv, sizeof(rtv)))
> >>> return ret;
> >>
> >> Please check the assembly code - this will still leave four bytes of
> >> uninitalised stack data in 'rtv', surely.
> >
> > Thats a good question.
> >
> > In my understanding, gcc should initialize all holes (and other not
> > mentioned fields) with 0, even for automatic storage [C99 only mandates
> > this on static storage]
> >
> > I tested on x86_64 and this is the case, but could not find a definitive
> > answer in gcc documentation.
> >
> > This kind of construct is widely used in networking tree.
> >
> > Maybe we should ask to gcc experts if this behavior is guaranteed by
> > gcc, or if we must review our code ;(
> >
> > CC Jakub
> >
> > Thanks !
> >
>
> This is what I thought too. If it is not there are tones of bugs I wrote
> of code that relays on this behaviour.
>
> It would be interesting to know for sure

Well. We certainly assume in many places that

struct foo {
int a;
int b;
} f = {
.a = 1,
};

will initialise b to zero. But I doubt if much code at all assumes
that this initialisation patterm will reliably zero out *holes* in the
struct.



\
 
 \ /
  Last update: 2010-11-23 00:53    [W:0.135 / U:0.396 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site