lkml.org 
[lkml]   [2000]   [Aug]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: BUG/PATCH: include/asm-*/fcntl.h
Date
Bernd Kischnick writes:

> An hour ago I posted a patch for asm-ppc/fcntl.h.
> Now I scanned the other asm-directories and found the same bug in
...
> +struct flock64 {
> + short l_type;
> + short l_whence;
> + loff_t l_start;
> + loff_t l_len;
> + pid_t l_pid;

Noooo!!!!!

Your struct likely looks like this on some systems:

2 bytes l_type
2 bytes l_whence
4 bytes COMPILER GENERATED CRAP <-- Eeew, gross.
8 bytes l_start
8 bytes l_len
4 bytes l_pid

You didn't follow the rules. (Remember that flamewar?)
You waste space and, maybe, leak secret data out of the kernel.
(if you copy the whole thing, with uninitialized data...)

After you fix the alignment, mind leaving some spare bytes?
It really sucks increasing these structs all the time.
Just define an explicit __u32 after l_whence to align things.
(of course, any padding or spares must be cleared)

For any gcc hacker reading this: we NEED a warning for alignment
problems of this sort. Ideally it would complain about the above
even with an ABI that allows 32-bit alignment of "long long".


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 12:38    [W:0.059 / U:2.944 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site