[PATCH 3/3] powerpc/fsl: add MPIC timer wakeup support
Wang Dongsheng-B40534
B40534 at freescale.com
Tue Mar 26 14:27:24 EST 2013
> -----Original Message-----
> From: Wood Scott-B07421
> Sent: Saturday, March 23, 2013 6:11 AM
> To: Wang Dongsheng-B40534
> Cc: Wood Scott-B07421; Gala Kumar-B11780; linuxppc-dev at lists.ozlabs.org;
> Zhao Chenhui-B35336; Li Yang-R58472
> Subject: Re: [PATCH 3/3] powerpc/fsl: add MPIC timer wakeup support
>
> On 03/22/2013 12:46:24 AM, Wang Dongsheng-B40534 wrote:
> >
> >
> > > -----Original Message-----
> > > From: Wood Scott-B07421
> > > Sent: Thursday, March 21, 2013 5:49 AM
> > > To: Wang Dongsheng-B40534
> > > Cc: Wood Scott-B07421; Gala Kumar-B11780;
> > linuxppc-dev at lists.ozlabs.org;
> > > Zhao Chenhui-B35336; Li Yang-R58472
> > > Subject: Re: [PATCH 3/3] powerpc/fsl: add MPIC timer wakeup support
> > >
> > > On 03/19/2013 10:48:53 PM, Wang Dongsheng-B40534 wrote:
> > > > while (*s) {
> > > > if ('0' <= *s && *s <= '9')
> > > > val = *s - '0';
> > > > else if ('a' <= _tolower(*s) && _tolower(*s) <= 'f')
> > > > val = _tolower(*s) - 'a' + 10;
> > > > else
> > > > break; //this will break out to convert.
> > >
> > > Really? How do you know that the next byte after the buffer isn't a
> > > valid hex digit? How do you even know that we won't take a fault
> > > accessing it?
> > >
> > Under what case is unsafe, please make sense.
>
> char buffer[1] = { '5' };
> write(fd, &buffer, 1);
>
> What comes after that '5' byte in the pointer you pass to kstrtol?
>
The buffer is userspace. It will fall in the kernel space.
Kernel will get a free page, and copy the buffer to page.
This page has been cleared before copy to page.
The page has already have null-terminated.
> > "kstrtol" is used in almost of sysfs interface, I think it should be
> > accepted in defaule :).
>
> Just because a lot of other people copy blindly doesn't make it right.
> Most of the examples I found use sscanf instead, though that has the same
> problem.
>
> I do see a few instances of the "strings from sysfs write are not 0
> terminated!" in the comments, though (kernel/time/clocksource.c and
> kernel/rtmutex-tester.c).
>
> Also "words written to sysfs files may, or may not, be \n terminated"
> in drivers/md/md.c.
>
It's not "kstrtol" doesn't work as well, They do not belong to this kind
of scenarios.
More information about the Linuxppc-dev
mailing list