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-next>] [day] [month] [year] [list]
Message-ID: <257c094c-522c-48c8-9bc2-70571dfb276f@lucifer.local>
Date: Wed, 21 May 2025 13:48:43 +0100
From: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
To: Ye Chey <yechey@...sast.com>
Cc: akpm@...ux-foundation.org, david@...hat.com, Liam.Howlett@...cle.com,
        vbabka@...e.cz, rppt@...nel.org, surenb@...gle.com, mhocko@...e.com,
        linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm: fix potential NULL pointer dereference in
 pagetable_alloc_noprof

+cc mailing lists

Please ensure you always cc these when submitting patches by the way :)

On Wed, May 21, 2025 at 01:46:48PM +0100, Lorenzo Stoakes wrote:
> On Wed, May 21, 2025 at 08:40:08PM +0800, Ye Chey wrote:
> > The pagetable_alloc_noprof function does not check the return value of
> > alloc_pages_noprof, which could lead to a NULL pointer dereference when
> > memory allocation fails. Add a NULL check to prevent this issue.
> >
> > Signed-off-by: Ye Chey <yechey@...sast.com>
> > ---
> >  include/linux/mm.h | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/include/linux/mm.h b/include/linux/mm.h
> > index bf5520693..9052bb531 100644
> > --- a/include/linux/mm.h
> > +++ b/include/linux/mm.h
> > @@ -3000,7 +3000,8 @@ static inline bool pagetable_is_reserved(struct ptdesc *pt)
> >  static inline struct ptdesc *pagetable_alloc_noprof(gfp_t gfp, unsigned int order)
> >  {
> >  	struct page *page = alloc_pages_noprof(gfp | __GFP_COMP, order);
> > -
> > +	if (!page)
> > +		return NULL;
> >  	return page_ptdesc(page);
>
> Doesn't page_ptdesc() just cast the page to the appropriate type? And thus can
> handle it being NULL?
>
> >  }
> >  #define pagetable_alloc(...)	alloc_hooks(pagetable_alloc_noprof(__VA_ARGS__))
> > --
> > 2.44.0
> >

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ