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!
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");
return 0; }slab_err(s, slab, "Invalid object pointer 0x%p", object);