linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* PATCH: fix 2 byte data leak due to padding
@ 2003-07-27 20:19 Alan Cox
  2003-07-28  3:49 ` Lou Langholtz
  0 siblings, 1 reply; 5+ messages in thread
From: Alan Cox @ 2003-07-27 20:19 UTC (permalink / raw)
  To: linux-kernel, torvalds

diff -u --new-file --recursive --exclude-from /usr/src/exclude linux-2.6.0-test2/fs/stat.c linux-2.6.0-test2-ac1/fs/stat.c
--- linux-2.6.0-test2/fs/stat.c	2003-07-14 14:11:56.000000000 +0100
+++ linux-2.6.0-test2-ac1/fs/stat.c	2003-07-23 16:27:42.000000000 +0100
@@ -106,7 +106,7 @@
 {
 	static int warncount = 5;
 	struct __old_kernel_stat tmp;
-
+	
 	if (warncount > 0) {
 		warncount--;
 		printk(KERN_WARNING "VFS: Warning: %s using old stat() call. Recompile your binary.\n",
@@ -116,6 +116,7 @@
 		warncount = 0;
 	}
 
+	memset(&tmp, 0, sizeof(struct __old_kernel_stat));
 	tmp.st_dev = stat->dev;
 	tmp.st_ino = stat->ino;
 	tmp.st_mode = stat->mode;


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH: fix 2 byte data leak due to padding
  2003-07-27 20:19 PATCH: fix 2 byte data leak due to padding Alan Cox
@ 2003-07-28  3:49 ` Lou Langholtz
  2003-07-28 11:32   ` Alan Cox
  0 siblings, 1 reply; 5+ messages in thread
From: Lou Langholtz @ 2003-07-28  3:49 UTC (permalink / raw)
  To: Alan Cox; +Cc: linux-kernel

Alan Cox wrote:

>diff -u --new-file --recursive --exclude-from /usr/src/exclude linux-2.6.0-test2/fs/stat.c linux-2.6.0-test2-ac1/fs/stat.c
>--- linux-2.6.0-test2/fs/stat.c	2003-07-14 14:11:56.000000000 +0100
>+++ linux-2.6.0-test2-ac1/fs/stat.c	2003-07-23 16:27:42.000000000 +0100
>@@ -106,7 +106,7 @@
> {
> 	static int warncount = 5;
> 	struct __old_kernel_stat tmp;
>-
>+	
> 	if (warncount > 0) {
> 		warncount--;
> 		printk(KERN_WARNING "VFS: Warning: %s using old stat() call. Recompile your binary.\n",
>@@ -116,6 +116,7 @@
> 		warncount = 0;
> 	}
> 
>+	memset(&tmp, 0, sizeof(struct __old_kernel_stat));
>
Wouldn't it be more clear (better) to use sizeof(tmp) here rather than 
sizeof(struct _old_kernel_stat)?


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH: fix 2 byte data leak due to padding
  2003-07-28  3:49 ` Lou Langholtz
@ 2003-07-28 11:32   ` Alan Cox
  2003-07-28 11:44     ` Wichert Akkerman
  2003-07-28 19:54     ` Andrew Morton
  0 siblings, 2 replies; 5+ messages in thread
From: Alan Cox @ 2003-07-28 11:32 UTC (permalink / raw)
  To: Lou Langholtz; +Cc: Linux Kernel Mailing List

On Llu, 2003-07-28 at 04:49, Lou Langholtz wrote:
> >+	memset(&tmp, 0, sizeof(struct __old_kernel_stat));
> >
> Wouldn't it be more clear (better) to use sizeof(tmp) here rather than 
> sizeof(struct _old_kernel_stat)?

sizeof(variable) can be suprising some times so I always use sizeof(type) out
of habit. (Think sizeof(x) when X later becomes a pointer)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH: fix 2 byte data leak due to padding
  2003-07-28 11:32   ` Alan Cox
@ 2003-07-28 11:44     ` Wichert Akkerman
  2003-07-28 19:54     ` Andrew Morton
  1 sibling, 0 replies; 5+ messages in thread
From: Wichert Akkerman @ 2003-07-28 11:44 UTC (permalink / raw)
  To: Linux Kernel Mailing List

Previously Alan Cox wrote:
> sizeof(variable) can be suprising some times so I always use sizeof(type) out
> of habit. (Think sizeof(x) when X later becomes a pointer)

when X becomes a pointer and you use sizeof(type of what X points to)
you'll be in trouble anyway.

Wichert.

-- 
Wichert Akkerman <wichert@wiggy.net>    It is simple to make things.
http://www.wiggy.net/                   It is hard to make things simple.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: PATCH: fix 2 byte data leak due to padding
  2003-07-28 11:32   ` Alan Cox
  2003-07-28 11:44     ` Wichert Akkerman
@ 2003-07-28 19:54     ` Andrew Morton
  1 sibling, 0 replies; 5+ messages in thread
From: Andrew Morton @ 2003-07-28 19:54 UTC (permalink / raw)
  To: Alan Cox; +Cc: ldl, linux-kernel

Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:
>
> On Llu, 2003-07-28 at 04:49, Lou Langholtz wrote:
> > >+	memset(&tmp, 0, sizeof(struct __old_kernel_stat));
> > >
> > Wouldn't it be more clear (better) to use sizeof(tmp) here rather than 
> > sizeof(struct _old_kernel_stat)?
> 
> sizeof(variable) can be suprising some times so I always use sizeof(type) out
> of habit. (Think sizeof(x) when X later becomes a pointer)

#define memzero(addr) memset(addr, 0, sizeof(*addr))

would robustify a lot of these things...


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-07-28 20:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-27 20:19 PATCH: fix 2 byte data leak due to padding Alan Cox
2003-07-28  3:49 ` Lou Langholtz
2003-07-28 11:32   ` Alan Cox
2003-07-28 11:44     ` Wichert Akkerman
2003-07-28 19:54     ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).