oprofile: Fix uninitialized memory access when writing to writing to oprofilefs
authorRobert Richter <robert.richter@amd.com>
Mon, 19 Dec 2011 15:38:30 +0000 (16:38 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 6 Jan 2012 22:17:04 +0000 (14:17 -0800)
commitc9b5dd12ec6e93b609b0e61acd02944352cd436d
treeaf2e9cd97019c2c4c99a6b543bac61f8a085347f
parent56c6a8a4aadca809e04276eabe5552935c51387f
oprofile: Fix uninitialized memory access when writing to writing to oprofilefs

commit 913050b91eb94f194392dd797b1ff3779f606ac0 upstream.

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 <mikew@google.com>
Signed-off-by: Robert Richter <robert.richter@amd.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: oprofile-list <oprofile-list@lists.sourceforge.net>
Link: http://lkml.kernel.org/r/20111219153830.GH16765@erda.amd.com
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
arch/s390/oprofile/init.c
drivers/oprofile/oprofile_files.c
drivers/oprofile/oprofilefs.c