lkml.org 
[lkml]   [2014]   [Apr]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: + lib-stringc-strlcpy-might-read-too-far.patch added to -mm tree
On Tue, Apr 15, 2014 at 01:49:38PM +0300, Alexey Dobriyan wrote:
> Return value matters. It may not matter for kernel, because kernel is
> not heavy string user.
> But it is better to not diverge from master code:
> http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libc/string/strlcpy.c?rev=1.11
>

Oh... Hm. Maybe we should drop this patch then.

> Counter-rationale:
> * strlcpy() accepts strings, so if you're giving raw buffer you're
> doing it wrong.
> * last byte of last page argument is bogus because kernel copies data
> from userspace first.

The last byte of the page argument seems possible:

foo = kmalloc();
copy_from_user(foo, arg, sizeof(foo));
strlcpy(dest.str, foo->bar, sizeof(dest.str));

It's a very unlikely scenario. You have to be very unlucky to hit it at
all.

regards,
dan carpenter


\
 
 \ /
  Last update: 2014-04-18 21:01    [W:0.283 / U:0.116 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site