linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Kasireddy, Vivek" <vivek.kasireddy@intel.com>
To: Oscar Salvador <osalvador@suse.de>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>,
	Muchun Song <muchun.song@linux.dev>,
	"syzbot+569ed13f4054f271087b@syzkaller.appspotmail.com"
	<syzbot+569ed13f4054f271087b@syzkaller.appspotmail.com>
Subject: RE: [PATCH] mm/hugetlb: Guard dequeue_hugetlb_folio_nodemask against NUMA_NO_NODE uses
Date: Wed, 12 Jun 2024 17:25:45 +0000	[thread overview]
Message-ID: <IA0PR11MB71853C005303041A07A5CF12F8C02@IA0PR11MB7185.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20240612082936.10867-1-osalvador@suse.de>

> dequeue_hugetlb_folio_nodemask() expects a preferred node where to get
> the
> hugetlb page from.
> It does not expect, though, users to pass NUMA_NO_NODE, otherwise we
> will
> get trash when trying to get the zonelist from that node.
> All current users are careful enough to not pass NUMA_NO_NODE, but
> it opens the door for new users to get this wrong since it is not
> documented [0].
> Guard against this by getting the local nid if NUMA_NO_NODE was passed.
> 
> [0] https://lore.kernel.org/linux-
> mm/0000000000004f12bb061a9acf07@google.com/
> 
> Closes: https://lore.kernel.org/linux-
> mm/0000000000004f12bb061a9acf07@google.com/
> Reported-and-tested-by:
> syzbot+569ed13f4054f271087b@syzkaller.appspotmail.com
> Signed-off-by: Oscar Salvador <osalvador@suse.de>
> ---
>  mm/hugetlb.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 3518321f6598..6a5ea898e4da 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -1355,6 +1355,10 @@ static struct folio
> *dequeue_hugetlb_folio_nodemask(struct hstate *h, gfp_t gfp_
>  	struct zoneref *z;
>  	int node = NUMA_NO_NODE;
> 
> +	/* 'nid' should not be NUMA_NO_NODE. Try to catch any misuse of it
> and rectifiy. */
> +	if (nid == NUMA_NO_NODE)
> +		nid = numa_node_id();
> +
>  	zonelist = node_zonelist(nid, gfp_mask);
Acked-by: Vivek Kasireddy <vivek.kasireddy@intel.com>

> 
>  retry_cpuset:
> --
> 2.45.2



      parent reply	other threads:[~2024-06-12 17:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-12  8:29 Oscar Salvador
2024-06-12  8:53 ` Muchun Song
2024-06-12 17:25 ` Kasireddy, Vivek [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=IA0PR11MB71853C005303041A07A5CF12F8C02@IA0PR11MB7185.namprd11.prod.outlook.com \
    --to=vivek.kasireddy@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=muchun.song@linux.dev \
    --cc=osalvador@suse.de \
    --cc=syzbot+569ed13f4054f271087b@syzkaller.appspotmail.com \
    /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