From: Vlastimil Babka <vbabka@suse.cz>
To: Li Qiong <liqiong@nfschina.com>,
Christoph Lameter <cl@gentwo.org>,
David Rientjes <rientjes@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Matthew Wilcox <willy@infradead.org>
Cc: Roman Gushchin <roman.gushchin@linux.dev>,
Harry Yoo <harry.yoo@oracle.com>,
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 10:52:22 +0200 [thread overview]
Message-ID: <431bf109-2bc7-4284-9b3a-7b36c329f25b@suse.cz> (raw)
In-Reply-To: <996a7622-219f-4e05-96ce-96bbc70068b0@suse.cz>
On 7/25/25 18:47, 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.
>>
>> Fixes: bb192ed9aa71 ("mm/slub: Convert most struct page to struct slab by spatch")
>
> That was the last commit to change the line, but the problem existed before,
> AFAICS all the time, so I did:
>
> Fixes: 7656c72b5a63 ("SLUB: add macros for scanning objects in a slab")
> Cc: <stable@vger.kernel.org>
>
>> Signed-off-by: Li Qiong <liqiong@nfschina.com>
>
> Added to slab/for-next, thanks!
Dropped based on Matthew's review
>> ---
>> v2:
>> - rephrase the commit message, add comment for object_err().
>> ---
>> mm/slub.c | 6 +++++-
>> 1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/mm/slub.c b/mm/slub.c
>> index 31e11ef256f9..8b24f1cf3079 100644
>> --- a/mm/slub.c
>> +++ b/mm/slub.c
>> @@ -1097,6 +1097,10 @@ static void print_trailer(struct kmem_cache *s, struct slab *slab, u8 *p)
>> size_from_object(s) - off);
>> }
>>
>> +/*
>> + * object - should be a valid object.
>> + * check_valid_pointer(s, slab, object) should be true.
>> + */
>> static void object_err(struct kmem_cache *s, struct slab *slab,
>> u8 *object, const char *reason)
>> {
>> @@ -1587,7 +1591,7 @@ static inline int alloc_consistency_checks(struct kmem_cache *s,
>> return 0;
>>
>> 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;
>> }
>>
>
prev parent reply other threads:[~2025-07-28 8:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20250725064919.1785537-1-liqiong@nfschina.com>
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
[not found] ` <e6f14d8a-5d32-473e-ba2d-1064ab8ef8fe@nfschina.com>
2025-07-28 3:29 ` Matthew Wilcox
2025-07-28 5:24 ` Harry Yoo
[not found] ` <ab080493-10cd-4f3b-8dd3-c67b4955a737@nfschina.com>
2025-07-28 13:38 ` Harry Yoo
2025-07-28 8:52 ` Vlastimil Babka [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=431bf109-2bc7-4284-9b3a-7b36c329f25b@suse.cz \
--to=vbabka@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=cl@gentwo.org \
--cc=harry.yoo@oracle.com \
--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=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