diff options
author | Robert Richter <robert.richter@amd.com> | 2011-12-19 10:38:30 -0500 |
---|---|---|
committer | Brad Figg <brad.figg@canonical.com> | 2012-01-23 18:35:55 -0500 |
commit | 892c0a848966cc15d744cbf9fb372be2ba636e7d (patch) | |
tree | 49c05b1eedad942504b911b440f87ae8a4c2cba2 /arch/s390 | |
parent | bb63e9f198a1928e1004fbc868f9a98d8d9e8ee5 (diff) |
oprofile: Fix uninitialized memory access when writing to writing to oprofilefs
BugLink: http://bugs.launchpad.net/bugs/913373
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>
Signed-off-by: Brad Figg <brad.figg@canonical.com>
Diffstat (limited to 'arch/s390')
-rw-r--r-- | arch/s390/oprofile/init.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/s390/oprofile/init.c b/arch/s390/oprofile/init.c index 0e358c2cffe..422110a4385 100644 --- a/arch/s390/oprofile/init.c +++ b/arch/s390/oprofile/init.c | |||
@@ -90,7 +90,7 @@ static ssize_t hwsampler_write(struct file *file, char const __user *buf, | |||
90 | return -EINVAL; | 90 | return -EINVAL; |
91 | 91 | ||
92 | retval = oprofilefs_ulong_from_user(&val, buf, count); | 92 | retval = oprofilefs_ulong_from_user(&val, buf, count); |
93 | if (retval) | 93 | if (retval <= 0) |
94 | return retval; | 94 | return retval; |
95 | 95 | ||
96 | if (oprofile_started) | 96 | if (oprofile_started) |