oprofile: Fix uninitialized memory access when writing to writing to oprofilefs
authorRobert Richter <[email protected]>
Mon, 19 Dec 2011 15:38:30 +0000 (16:38 +0100)
committerIngo Molnar <[email protected]>
Mon, 19 Dec 2011 16:18:43 +0000 (17:18 +0100)
commit913050b91eb94f194392dd797b1ff3779f606ac0
treebcb861e17dc40875ef0f694641392b7177f04852
parent497f16f21a04060098c0da6ed522fbcafb90c0db
oprofile: Fix uninitialized memory access when writing to writing to oprofilefs

If oprofilefs_ulong_from_user() is called with count equals
zero, *val remains unchanged. Depending on the implementation it
might be uninitialized.

Change oprofilefs_ulong_from_user()'s interface to return count
on success. Thus, we are able to return early if count equals
zero which avoids using *val uninitialized. Fixing all users of
oprofilefs_ulong_ from_user().

This follows write syscall implementation when count is zero:
"If count is zero ... [and if] no errors are detected, 0 will be
returned without causing any other effect." (man 2 write)

Reported-By: Mike Waychison <[email protected]>
Signed-off-by: Robert Richter <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: <[email protected]>
Cc: oprofile-list <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
arch/s390/oprofile/init.c
drivers/oprofile/oprofile_files.c
drivers/oprofile/oprofilefs.c