Thread (32 messages) 32 messages, 5 authors, 2013-03-29

Re: [PATCH 3/3] powerpc/fsl: add MPIC timer wakeup support

flat view

From: Scott Wood <hidden>
Date: 2013-03-22 22:11:45

On 03/22/2013 12:46:24 AM, Wang Dongsheng-B40534 wrote:
=20
=20
quoted
-----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; =20
linuxppc-dev@lists.ozlabs.org;
quoted
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:
quoted
	while (*s) {
		if ('0' <=3D *s && *s <=3D '9')
			val =3D *s - '0';
		else if ('a' <=3D _tolower(*s) && _tolower(*s) <=3D 'f')
			val =3D _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] =3D { '5' };
write(fd, &buffer, 1);

What comes after that '5' byte in the pointer you pass to kstrtol?
"kstrtol" is used in almost of sysfs interface, I think it should be =20
accepted in defaule :).
Just because a lot of other people copy blindly doesn't make it right.  =20
Most of the examples I found use sscanf instead, though that has the =20
same problem.

I do see a few instances of the "strings from sysfs write are not 0 =20
terminated!" in the comments, though (kernel/time/clocksource.c and =20
kernel/rtmutex-tester.c).

Also "words written to sysfs files may, or may not, be \n terminated" =20
in drivers/md/md.c.

-Scott=
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help