[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aIQMhSlOMREOTLyl@hyeyoo>
Date: Sat, 26 Jul 2025 08:00:21 +0900
From: Harry Yoo <harry.yoo@...cle.com>
To: Matthew Wilcox <willy@...radead.org>
Cc: Vlastimil Babka <vbabka@...e.cz>, Li Qiong <liqiong@...china.com>,
Christoph Lameter <cl@...two.org>,
David Rientjes <rientjes@...gle.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Roman Gushchin <roman.gushchin@...ux.dev>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, stable@...r.kernel.org
Subject: Re: [PATCH v2] mm: slub: avoid deref of free pointer in sanity
checks if object is invalid
On Sat, Jul 26, 2025 at 04:55:06AM +0900, Harry Yoo wrote:
> On Fri, Jul 25, 2025 at 06:10:51PM +0100, Matthew Wilcox wrote:
> > On Fri, Jul 25, 2025 at 06:47:01PM +0200, Vlastimil Babka wrote:
> > > On 7/25/25 08:49, Li Qiong wrote:
> > > > For debugging, object_err() prints free pointer of the object.
> > > > However, if check_valid_pointer() returns false for a object,
> > > > dereferncing `object + s->offset` can lead to a crash. Therefore,
> > > > print the object's address in such cases.
> >
> > > > if (!check_valid_pointer(s, slab, object)) {
> > > > - object_err(s, slab, object, "Freelist Pointer check fails");
> > > > + slab_err(s, slab, "Invalid object pointer 0x%p", object);
> > > > return 0;
> >
> > No, the error message is now wrong. It's not an object, it's the
> > freelist pointer.
>
> Because it's the object is about to be allocated, it will look like
> this:
>
> object pointer -> obj: [ garbage ][ freelist pointer ][ garbage ]
>
> SLUB uses check_valid_pointer() to check either 1) freelist pointer of
> an object is valid (e.g. in check_object()), or 2) an object pointer
> points to a valid address (e.g. in free_debug_processing()).
>
> In this case it's an object pointer, not a freelist pointer.
> Or am I misunderstanding something?
Actually, in alloc_debug_processing() the pointer came from slab->freelist,
so I think saying either "invalid freelist pointer" or
"invalid object pointer" make sense...
--
Cheers,
Harry / Hyeonggon
Powered by blists - more mailing lists