Re: [PATCH] mm: Replace-simple_strtoul-with-kstrtoul

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Nov 09, 2017 at 04:58:18PM +0530, Manjeet Pawar wrote:
> simple_strtoul() is obselete now, so using newer function kstrtoul()
> 
> Signed-off-by: Manjeet Pawar <manjeet.p@xxxxxxxxxxx>
> Signed-off-by: Vinay Kumar Rijhwani <v.rijhwani@xxxxxxxxxxx>
> Signed-off-by: Rohit Thapliyal <r.thapliyal@xxxxxxxxxxx>

NAK NAK NAK.

You haven't tested this on a 64-bit big-endian machine.

>  static int __init set_hashdist(char *str)
>  {
> -	if (!str)
> +	if (!str || kstrtoul(str, 0, (unsigned long *)&hashdist))
>  		return 0;
> -	hashdist = simple_strtoul(str, &str, 0);
>  	return 1;

The context missing from this patch is:

int hashdist = HASHDIST_DEFAULT;

So you're taking the address of an int and passing it to a function
which is expecting a pointer to an unsigned long.  That works on a
32-bit machine because ints and longs are the same size.  On a 64-bit
little-endian machine, the bits are in the right place, but kstrtoul()
will overwrite the 32 bits after the int with zeroes.  On a 64-bit
big-endian machine, you'll overwrite the int that you're pointing to
with zeroes and the 32 bits after the int will have the data you're
looking for.

There's a kstrtoint().  Why would you not just use that?

Also, I'm shocked that this went through a chain of three different
sign-offs with nobody noticing the problem.  Do none of you understand C?

(similar problems snipped).

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]
  Powered by Linux