lkml.org 
[lkml]   [2023]   [Jan]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 9/9] mm: kmemleak: fix undetected leaks for page aligned objects
On Mon, Jan 23, 2023 at 11:04:19AM -0600, George Prekas wrote:
> If kmalloc returns a page aligned object, then the object has 2
> references: the pointer returned by kmalloc and page->s_mem of the first
> page of the object. Account for this extra reference, so that kmemleak
> can correctly detect leaks for page aligned objects.

Is this true for multi-page slabs? Imagine if you allocate objects of
size 4kB. Slab/Slub will allocate slabs of size 32kB and try to
allocate 8 objects from each slab. Only the first one will have an
s_mem pointing into it. No?

> - kmemleak_alloc_recursive(p[i], s->object_size, 1,
> + min_count = 1;
> + /* If p[i] is page aligned, then a page->s_mem refers to it. */

Also this comment should read 'slab->s_mem'. Individual pages within
the slab do not have s_mem pointers, only the slab.

> + if (((uintptr_t)p[i] & ~PAGE_MASK) == 0)
> + min_count++;
> + kmemleak_alloc_recursive(p[i], s->object_size, min_count,
> s->flags, flags);

\
 
 \ /
  Last update: 2023-03-26 23:54    [W:0.100 / U:1.136 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site