Re: [PATCH] usb: core: fix information leak to userland

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




--- On Sat, 11/6/10, Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote:


> > 
> 
> Unfortunately I don't have a copy of the C standard here to
> consult.  
> However...  Although I'm perfectly willing to believe
> that the standard
> requires fields in a structure to be initialized to 0 if
> they
> aren't mentioned explicitly in the initializer, I'm
> considerably more
> doubtful that it also requires padding to be initialized!

ISTR initialization-to-zero is the standard
behavior defined for all _memory_ that gets
initialized ... not just named fields ...
whether the init is "static", "bss", or not.
> 
> And I certainly wouldn't want to depend on compilers
> _always_ using 
> memset to do this initialization.

Of course not; just rely on init-to-zero, and
let the compiler worry about efficiency. In
some cases memset(); in others, the result
might be as if memset were inlined, so only
a few "write a zero at this address" type
instructions would be needed.
> 
> > There's certainly a fair amount of code I've seen
> > that uses runtime initializers like that, to zero
> > memory.  I can't believe i's _all_ broken! 
> ;)
> 
> Zeroing memory that belongs to a declared field is
> different from 
> zeroing padding bytes.  Maybe what you remember seeing
> is the first and 
> not the second.

I remember seeing both, and at one point looking
at the issue to verify that padding was treated
uniformly (like other memory).  Also, writing code
that relied on zero-initted padding.

- Dave

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux