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  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20070712234938.c77f3a48.akpm@linux-foundation.org>
Date:	Thu, 12 Jul 2007 23:49:38 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Joe Jin <joe.jin@...cle.com>
Cc:	bill.irwin@...cle.com, linux-kernel@...r.kernel.org,
	gurudas.pai@...cle.com
Subject: Re: [PATCH] Add nid sanity on alloc_pages_node

On Fri, 13 Jul 2007 14:40:04 +0800 Joe Jin <joe.jin@...cle.com> wrote:

> On 2007-07-12 22:18, Andrew Morton wrote:
> > On Fri, 13 Jul 2007 10:45:07 +0800 Joe Jin <joe.jin@...cle.com> wrote:
> > 
> > Something like this?
> > 
> > --- a/mm/hugetlb.c~a
> > +++ a/mm/hugetlb.c
> > @@ -105,13 +105,20 @@ static void free_huge_page(struct page *
> >  
> >  static int alloc_fresh_huge_page(void)
> >  {
> > -	static int nid = 0;
> > +	static int prev_nid;
> > +	static DEFINE_SPINLOCK(nid_lock);
> >  	struct page *page;
> > -	page = alloc_pages_node(nid, htlb_alloc_mask|__GFP_COMP|__GFP_NOWARN,
> > -					HUGETLB_PAGE_ORDER);
> > -	nid = next_node(nid, node_online_map);
> > +	int nid;
> > +
> > +	spin_lock(&nid_lock);
> > +	nid = next_node(prev_nid, node_online_map);
> >  	if (nid == MAX_NUMNODES)
> >  		nid = first_node(node_online_map);
> > +	prev_nid = nid;
> > +	spin_unlock(&nid_lock);
> > +
> > +	page = alloc_pages_node(nid, htlb_alloc_mask|__GFP_COMP|__GFP_NOWARN,
> > +					HUGETLB_PAGE_ORDER);
> >  	if (page) {
> >  		set_compound_page_dtor(page, free_huge_page);
> >  		spin_lock(&hugetlb_lock);
> > _
> > 
> 
> The patch looks good for this bug, thanks :)

If you have time could you test it and sent it back at me please?

> if other caller give a invalid nid to alloc_pages_node(), __alloc_pages
> will crash again.

That would be a buggy caller, so we should fix that caller.

> So I think we add some sanity check for nid at alloc_pages_node is
> meaningful.  
> 
> another question, if (nid >= MAX_NUMNODES),  may I set nid to 0 directly
> like following code?
> 
> 	if (unlikly(nid >= MAX_NUMNODES)
> 		nid = 0

if (nid > MAX_NUMNODES) then that is a bug and we should report it (doing
this via a BUG() is OK) rather than quietly covering it up.

if (nid == MAX_NUMNODES) then we should set it to
first_node(node_online_map);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ