From: Matthew Wilcox <willy@infradead.org>
To: Manjeet Pawar <manjeet.p@samsung.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, vbabka@suse.cz,
mhocko@suse.com, akpm@linux-foundation.org, hughd@google.com,
a.sahrawat@samsung.com, pankaj.m@samsung.com,
lalit.mohan@samsung.com,
Vinay Kumar Rijhwani <v.rijhwani@samsung.com>,
Rohit Thapliyal <r.thapliyal@samsung.com>
Subject: Re: [PATCH] mm: Replace-simple_strtoul-with-kstrtoul
Date: Thu, 9 Nov 2017 05:04:12 -0800 [thread overview]
Message-ID: <20171109130412.GA1094@bombadil.infradead.org> (raw)
In-Reply-To: <1510226898-4310-1-git-send-email-manjeet.p@samsung.com>
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@samsung.com>
> Signed-off-by: Vinay Kumar Rijhwani <v.rijhwani@samsung.com>
> Signed-off-by: Rohit Thapliyal <r.thapliyal@samsung.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).
prev parent reply other threads:[~2017-11-09 13:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20171109113212epcas5p4b93d4830869468901f4003bde11e3d16@epcas5p4.samsung.com>
2017-11-09 11:28 ` [PATCH] mm: Replace-simple_strtoul-with-kstrtoul Manjeet Pawar
2017-11-09 13:04 ` Matthew Wilcox [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171109130412.GA1094@bombadil.infradead.org \
--to=willy@infradead.org \
--cc=a.sahrawat@samsung.com \
--cc=akpm@linux-foundation.org \
--cc=hughd@google.com \
--cc=lalit.mohan@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=manjeet.p@samsung.com \
--cc=mhocko@suse.com \
--cc=pankaj.m@samsung.com \
--cc=r.thapliyal@samsung.com \
--cc=v.rijhwani@samsung.com \
--cc=vbabka@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).