From: Michal Hocko <mhocko@suse.com>
To: Li Xinhai <lixinhai.lxh@gmail.com>
Cc: linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
Vlastimil Babka <vbabka@suse.cz>, Hugh Dickins <hughd@google.com>
Subject: Re: [PATCH] mm: mempolicy: Fix wrong use of maxnode in mempolicy API
Date: Fri, 8 Nov 2019 17:04:56 +0100 [thread overview]
Message-ID: <20191108160456.GN15658@dhcp22.suse.cz> (raw)
In-Reply-To: <1573228169-30986-1-git-send-email-lixinhai.lxh@gmail.com>
On Fri 08-11-19 23:49:29, Li Xinhai wrote:
> The maxnode used by mbind(), set_mempolicy() and migrate_pages() is not
> correctly handled in get_nodes(), where --maxnode cause the calculation
> endmask = (1UL << (maxnode % BITS_PER_LONG)) - 1;
> ignores the highest node ID bit. Then, at
> nodes_addr(*nodes)[nlongs-1] &= endmask;
> the highest node ID bit is cleared. Finally, cause mpol_new() think user
> does not pass in any node ID, and return EINVAL.
>
> The results are:
> - Application receives EINVAL when only the highest node ID bit is set.
> - Application recevies no error when other bits set together with the
> highest node ID bit, but that highest ID is ignored.
A similar patch has been posted [1] and rejected [2].
[1] http://lkml.kernel.org/r/1570882789-20579-1-git-send-email-zhangpan26@huawei.com
[2] http://lkml.kernel.org/r/20191014091243.GD317@dhcp22.suse.cz
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Michal Hocko <mhocko@suse.com>
> Cc: Vlastimil Babka <vbabka@suse.cz>
> Cc: Hugh Dickins <hughd@google.com>
> Signed-off-by: Li Xinhai <lixinhai.lxh@gmail.com>
> ---
> mm/mempolicy.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/mm/mempolicy.c b/mm/mempolicy.c
> index 4ae967b..2bdc365 100644
> --- a/mm/mempolicy.c
> +++ b/mm/mempolicy.c
> @@ -1328,7 +1328,6 @@ static int get_nodes(nodemask_t *nodes, const unsigned long __user *nmask,
> unsigned long nlongs;
> unsigned long endmask;
>
> - --maxnode;
> nodes_clear(*nodes);
> if (maxnode == 0 || !nmask)
> return 0;
> --
> 1.8.3.1
>
--
Michal Hocko
SUSE Labs
next prev parent reply other threads:[~2019-11-08 16:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-08 15:49 [PATCH] mm: mempolicy: Fix wrong use of maxnode in mempolicy API Li Xinhai
2019-11-08 16:04 ` Michal Hocko [this message]
2019-11-08 16:48 ` lixinhai.lxh
2019-11-11 10:04 ` Michal Hocko
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=20191108160456.GN15658@dhcp22.suse.cz \
--to=mhocko@suse.com \
--cc=akpm@linux-foundation.org \
--cc=hughd@google.com \
--cc=linux-mm@kvack.org \
--cc=lixinhai.lxh@gmail.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).