RE: [PATCH][4/4] let's kill verify_area - convert kernel/printk.c to access_ok()

From: Peter Kjellerstedt
Date: Fri Jan 07 2005 - 10:44:33 EST


> -----Original Message-----
> From: linux-kernel-owner@xxxxxxxxxxxxxxx
> [mailto:linux-kernel-owner@xxxxxxxxxxxxxxx] On Behalf Of
> Vincent Hanquez
> Sent: Friday, January 07, 2005 13:52
> To: Jesper Juhl
> Cc: linux-kernel; Andrew Morton
> Subject: Re: [PATCH][4/4] let's kill verify_area - convert
> kernel/printk.c to access_ok()
>
> On Fri, Jan 07, 2005 at 02:18:55AM +0100, Jesper Juhl wrote:
> > @@ -300,8 +300,8 @@ int do_syslog(int type, char __user * bu
> > error = 0;
> > if (!len)
> > goto out;
> > - error = verify_area(VERIFY_WRITE,buf,len);
> > - if (error)
> > + error = access_ok(VERIFY_WRITE,buf,len);
> > + if (!error)
>
> I would rather put the ! on access_ok
> "if (!error)" is read as "if no error"

Actually, this should be:

error = access_ok(VERIFY_WRITE, buf, len) ? 0 : -EFAULT;
if (error)
goto out;

Alternatively:

if (!access_ok(VERIFY_WRITE, buf, len)) {
error = -EFAULT;
goto out;
}

Otherwise the returned value from do_syslog() is incorrect
in case access_ok() fails (i.e., 0 instead of -EFAULT)...

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