From: Harry Yoo <harry.yoo@oracle.com>
To: liqiong <liqiong@nfschina.com>
Cc: Matthew Wilcox <willy@infradead.org>,
Vlastimil Babka <vbabka@suse.cz>,
Christoph Lameter <cl@gentwo.org>,
David Rientjes <rientjes@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH v2] mm: slub: avoid deref of free pointer in sanity checks if object is invalid
Date: Mon, 28 Jul 2025 22:38:31 +0900 [thread overview]
Message-ID: <aId9V2PrEHCLnpUn@harry> (raw)
In-Reply-To: <ab080493-10cd-4f3b-8dd3-c67b4955a737@nfschina.com>
On Mon, Jul 28, 2025 at 05:08:57PM +0800, liqiong wrote:
>
>
> 在 2025/7/28 13:24, Harry Yoo 写道:
> > On Mon, Jul 28, 2025 at 04:29:22AM +0100, Matthew Wilcox wrote:
> >> On Mon, Jul 28, 2025 at 10:06:42AM +0800, liqiong wrote:
> >>>>> 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...
> >>> free_consistency_checks() has
> >>> 'slab_err(s, slab, "Invalid object pointer 0x%p", object);'
> >>> Maybe it is better, alloc_consisency_checks() has the same message.
> >> No. Think about it.
> > Haha, since I suggested that change, I feel like I have to rethink it
> > and respond... Maybe I'm wrong again, but I love to be proven wrong :)
> >
> > On second thought,
> >
> > Unlike free_consistency_checks() where an arbitrary address can be
> > passed, alloc_consistency_check() is not passed arbitrary addresses
> > but only addresses from the freelist. So if a pointer is invalid
> > there, it means the freelist pointer is invalid. And in all other
> > parts of slub.c, such cases are described as "Free(list) pointer",
> > or "Freechain" being invalid or corrupted.
> >
> > So to stay consistent "Invalid freelist pointer" would be the right choice :)
> > Sorry for the confusion.
> >
> > Anyway, Li, to make progress on this I think it make sense to start by making
> > object_err() resiliant against invalid pointers (as suggested by Matthew)?
> > If you go down that path, this patch might no longer be required to fix
> > the bug anyway...
> >
> > And the change would be quite small. Most part of print_trailer() is printing
> > metadata and raw content of the object, which is risky when the pointer is
> > invalid. In that case we'd only want to print the address of the invalid
> > pointer and the information about slab (print_slab_info()) and nothing more.
> >
>
> Got it, I will a v3 patch, changing the message, and keep it simple,
> dropping the comments of object_err(), just fix the issue.
Well, I was saying let's start from making object_err() against wild
pointers [1] per Matthew's suggestion.
And with that this patch won't be necessary to fix the issue and will be
more robust against similar mistakes like this?
[1] https://lore.kernel.org/linux-mm/aIPZXSnkDF5r-PR5@casper.infradead.org
--
Cheers,
Harry / Hyeonggon
next prev parent reply other threads:[~2025-07-28 13:39 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-25 2:48 [PATCH] mm: slub: fix dereference invalid pointer in alloc_consistency_checks Li Qiong
2025-07-25 4:01 ` Harry Yoo
2025-07-25 5:46 ` liqiong
2025-07-25 6:49 ` [PATCH v2] mm: slub: avoid deref of free pointer in sanity checks if object is invalid Li Qiong
2025-07-25 16:47 ` Vlastimil Babka
2025-07-25 17:10 ` Matthew Wilcox
2025-07-25 19:22 ` Matthew Wilcox
2025-07-25 22:49 ` Harry Yoo
2025-07-25 19:55 ` Harry Yoo
2025-07-25 23:00 ` Harry Yoo
2025-07-28 2:06 ` liqiong
2025-07-28 3:29 ` Matthew Wilcox
2025-07-28 5:24 ` Harry Yoo
2025-07-28 9:08 ` liqiong
2025-07-28 13:38 ` Harry Yoo [this message]
2025-07-28 8:52 ` Vlastimil Babka
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=aId9V2PrEHCLnpUn@harry \
--to=harry.yoo@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=cl@gentwo.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=liqiong@nfschina.com \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=stable@vger.kernel.org \
--cc=vbabka@suse.cz \
--cc=willy@infradead.org \
/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).