* Re: [PATCH v5] mm/slub: avoid accessing metadata when pointer is invalid in object_err()
[not found] <20250804014626.134396-1-liqiong@nfschina.com>
@ 2025-08-04 2:25 ` Harry Yoo
2025-08-04 2:35 ` Harry Yoo
0 siblings, 1 reply; 2+ messages in thread
From: Harry Yoo @ 2025-08-04 2:25 UTC (permalink / raw)
To: Li Qiong
Cc: Christoph Lameter, David Rientjes, Andrew Morton,
Vlastimil Babka, Roman Gushchin, linux-mm, linux-kernel, stable
On Mon, Aug 04, 2025 at 09:46:25AM +0800, Li Qiong wrote:
> object_err() reports details of an object for further debugging, such as
> the freelist pointer, redzone, etc. However, if the pointer is invalid,
> attempting to access object metadata can lead to a crash since it does
> not point to a valid object.
>
> In case check_valid_pointer() returns false for the pointer, only print
> the pointer value and skip accessing metadata.
>
> Fixes: 81819f0fc828 ("SLUB core")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Li Qiong <liqiong@nfschina.com>
> ---
> v2:
> - rephrase the commit message, add comment for object_err().
> v3:
> - check object pointer in object_err().
> v4:
> - restore changes in alloc_consistency_checks().
> v5:
> - rephrase message, fix code style.
> ---
Looks good to me,
Reviewed-by: Harry Yoo <harry.yoo@oracle.com>
--
Cheers,
Harry / Hyeonggon
> mm/slub.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/mm/slub.c b/mm/slub.c
> index 31e11ef256f9..b3eff1476c85 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -1104,7 +1104,12 @@ static void object_err(struct kmem_cache *s, struct slab *slab,
> return;
>
> slab_bug(s, reason);
> - print_trailer(s, slab, object);
> + if (!check_valid_pointer(s, slab, object)) {
> + print_slab_info(slab);
> + pr_err("Invalid pointer 0x%p\n", object);
> + } else {
> + print_trailer(s, slab, object);
> + }
> add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE);
>
> WARN_ON(1);
> --
> 2.30.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v5] mm/slub: avoid accessing metadata when pointer is invalid in object_err()
2025-08-04 2:25 ` [PATCH v5] mm/slub: avoid accessing metadata when pointer is invalid in object_err() Harry Yoo
@ 2025-08-04 2:35 ` Harry Yoo
0 siblings, 0 replies; 2+ messages in thread
From: Harry Yoo @ 2025-08-04 2:35 UTC (permalink / raw)
To: Li Qiong
Cc: Christoph Lameter, David Rientjes, Andrew Morton,
Vlastimil Babka, Roman Gushchin, linux-mm, linux-kernel, stable
On Mon, Aug 04, 2025 at 11:25:23AM +0900, Harry Yoo wrote:
> On Mon, Aug 04, 2025 at 09:46:25AM +0800, Li Qiong wrote:
> > object_err() reports details of an object for further debugging, such as
> > the freelist pointer, redzone, etc. However, if the pointer is invalid,
> > attempting to access object metadata can lead to a crash since it does
> > not point to a valid object.
> >
> > In case check_valid_pointer() returns false for the pointer, only print
> > the pointer value and skip accessing metadata.
> >
> > Fixes: 81819f0fc828 ("SLUB core")
> > Cc: <stable@vger.kernel.org>
> > Signed-off-by: Li Qiong <liqiong@nfschina.com>
> > ---
> > v2:
> > - rephrase the commit message, add comment for object_err().
> > v3:
> > - check object pointer in object_err().
> > v4:
> > - restore changes in alloc_consistency_checks().
> > v5:
> > - rephrase message, fix code style.
> > ---
>
> Looks good to me,
> Reviewed-by: Harry Yoo <harry.yoo@oracle.com>
>
> --
> Cheers,
> Harry / Hyeonggon
>
> > mm/slub.c | 7 ++++++-
> > 1 file changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/mm/slub.c b/mm/slub.c
> > index 31e11ef256f9..b3eff1476c85 100644
> > --- a/mm/slub.c
> > +++ b/mm/slub.c
> > @@ -1104,7 +1104,12 @@ static void object_err(struct kmem_cache *s, struct slab *slab,
> > return;
> >
> > slab_bug(s, reason);
> > - print_trailer(s, slab, object);
> > + if (!check_valid_pointer(s, slab, object)) {
Wait, hold on. check_valid_pointer() returns true when object == NULL.
the condition should be (!object || !check_valid_pointer())?
> > + print_slab_info(slab);
> > + pr_err("Invalid pointer 0x%p\n", object);
> > + } else {
> > + print_trailer(s, slab, object);
> > + }
> > add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE);
> >
> > WARN_ON(1);
> > --
> > 2.30.2
--
Cheers,
Harry / Hyeonggon
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-08-04 2:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20250804014626.134396-1-liqiong@nfschina.com>
2025-08-04 2:25 ` [PATCH v5] mm/slub: avoid accessing metadata when pointer is invalid in object_err() Harry Yoo
2025-08-04 2:35 ` Harry Yoo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox