Re: [GIT PULL] oprofile fixes for 3.2

From: Ingo Molnar
Date: Mon Dec 19 2011 - 09:02:45 EST



* Robert Richter <robert.richter@xxxxxxx> wrote:

> Ingo,
>
> please pull this one fix for 3.2.
>
> Thanks,
>
> -Robert
>
>
>
> The following changes since commit dc47ce90c3a822cd7c9e9339fe4d5f61dcb26b50:
>
> Linux 3.2-rc5 (2011-12-09 15:09:32 -0800)
>
> are available in the git repository at:
> git://git.kernel.org/pub/scm/linux/kernel/git/rric/oprofile.git urgent
>
> Robert Richter (1):
> oprofile: Fix uninitialized memory access when writing to oprofilefs
>
> arch/s390/oprofile/init.c | 3 +++
> drivers/oprofile/oprofile_files.c | 9 +++++++++
> drivers/oprofile/oprofilefs.c | 15 ++++++++++++++-
> 3 files changed, 26 insertions(+), 1 deletions(-)

Hm, i really don't like this:

+ if (!count)
+ return 0;
+
retval = oprofilefs_ulong_from_user(&val, buf, count);
if (retval)
return retval;

+ if (!count)
+ return 0;
+
retval = oprofilefs_ulong_from_user(&val, buf, count);
if (retval)
return retval;

+ if (!count)
+ return 0;
+
retval = oprofilefs_ulong_from_user(&val, buf, count);
if (retval)
return retval;

+ if (!count)
+ return 0;
+
retval = oprofilefs_ulong_from_user(&val, buf, count);
if (retval)
return retval;

+ if (!count)
+ return 0;
+
retval = oprofilefs_ulong_from_user(&value, buf, count);
if (retval)
return retval;

See the ugly and fragile pattern?

This should *really* be solved via the
oprofilefs_ulong_from_user() helper function, not by sprinkling
the !count checks in half a dozen places ...

Thanks,

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