Re: [PATCH 1/1] setitimer : Return -EFAULT if the user pointer"value" is NULL

From: Thomas Gleixner
Date: Wed Mar 21 2012 - 06:09:42 EST


On Tue, 20 Mar 2012, Sasikantha babu wrote:

> Return -EFAULT if user pointer "value" is NULL.

In principle I agree, though this might break exisiting user space as
this behaviour has been there since Linux 1.1.52

So the right thing to do is to add a WARN_ONCE() in the else path and
schedule the removal of this "feature" for v3.6

> diff --git a/kernel/itimer.c b/kernel/itimer.c
> index 22000c3..f356bdf 100644
> --- a/kernel/itimer.c
> +++ b/kernel/itimer.c
> @@ -279,19 +279,18 @@ SYSCALL_DEFINE3(setitimer, int, which, struct itimerval __user *, value,
> struct itimerval __user *, ovalue)
> {
> struct itimerval set_buffer, get_buffer;
> - int error;
> + int error = -EFAULT;

Instead of ripping the whole thing apart, it's way simpler to just do

if (!value)
return -EFAULT;

Thanks,

tglx
--
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/