lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Thu, 9 Nov 2017 05:04:12 -0800
From:   Matthew Wilcox <willy@...radead.org>
To:     Manjeet Pawar <manjeet.p@...sung.com>
Cc:     linux-kernel@...r.kernel.org, linux-mm@...ck.org, vbabka@...e.cz,
        mhocko@...e.com, akpm@...ux-foundation.org, hughd@...gle.com,
        a.sahrawat@...sung.com, pankaj.m@...sung.com,
        lalit.mohan@...sung.com,
        Vinay Kumar Rijhwani <v.rijhwani@...sung.com>,
        Rohit Thapliyal <r.thapliyal@...sung.com>
Subject: Re: [PATCH] mm: Replace-simple_strtoul-with-kstrtoul

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@...sung.com>
> Signed-off-by: Vinay Kumar Rijhwani <v.rijhwani@...sung.com>
> Signed-off-by: Rohit Thapliyal <r.thapliyal@...sung.com>

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).

Powered by blists - more mailing lists