From: liqiong <liqiong@nfschina.com>
To: Harry Yoo <harry.yoo@oracle.com>
Cc: Christoph Lameter <cl@gentwo.org>,
David Rientjes <rientjes@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Vlastimil Babka <vbabka@suse.cz>,
Roman Gushchin <roman.gushchin@linux.dev>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] mm: slub: fix dereference invalid pointer in alloc_consistency_checks
Date: Fri, 25 Jul 2025 13:46:59 +0800 [thread overview]
Message-ID: <ef73ea4c-c081-4c64-aab3-a60ec71f03bc@nfschina.com> (raw)
In-Reply-To: <aIMBppTQ-ON7RM8y@harry>
在 2025/7/25 12:01, Harry Yoo 写道:
> On Fri, Jul 25, 2025 at 10:48:54AM +0800, Li Qiong wrote:
>> In object_err(), need dereference the 'object' pointer, it may cause
>> a invalid pointer fault. Use slab_err() instead.
> Hi Li Qiong, this patch makes sense to me.
> But I'd suggest to rephrase it a little bit, like:
>
> mm/slab: avoid deref of free pointer in sanity checks if object is invalid
>
> For debugging purposes, object_err() prints free pointer of the object.
> However, if check_valid_pointer() returns false for object,
> `object + s->offset` is also invalid and dereferncing it can lead to a
> crash. Therefore, avoid dereferencing it and only print the object's
> address in such cases.
Thanks, I will send a v2 patch.
>
>> Signed-off-by: Li Qiong <liqiong@nfschina.com>
> Which commit introduced this problem?
> A Fixes: tag is needed to determine which -stable versions it should be
> backported to.
>
> And to backport MM patches to -stable, you need to explicitly add
> 'Cc: stable@vger.kernel.org' to the patch.
>
>> ---
>> mm/slub.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/mm/slub.c b/mm/slub.c
>> index 31e11ef256f9..3a2e57e2e2d7 100644
>> --- a/mm/slub.c
>> +++ b/mm/slub.c
>> @@ -1587,7 +1587,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, "Freelist Pointer (0x%p) check fails", object);
> Can this be
> slab_err(s, slab, "Invalid object pointer 0x%p", object);
> to align with free_consistency_checks()?
>
>> return 0;
>> }
>>
> It might be worth adding a comment in object_err() stating that it should
> only be called when check_valid_pointer() returns true for object, and
> a WARN_ON_ONCE(!check_valid_pointer(s, slab, object)) to catch incorrect
> usages?
next prev parent reply other threads:[~2025-07-25 5:47 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-25 2:48 Li Qiong
2025-07-25 4:01 ` Harry Yoo
2025-07-25 5:46 ` liqiong [this message]
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
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=ef73ea4c-c081-4c64-aab3-a60ec71f03bc@nfschina.com \
--to=liqiong@nfschina.com \
--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=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=stable@vger.kernel.org \
--cc=vbabka@suse.cz \
/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
all inboxes | Powered by JetHome®