From: Matthew Wilcox <willy@infradead.org>
To: George Prekas <george@enfabrica.net>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Catalin Marinas <catalin.marinas@arm.com>,
Andrew Morton <akpm@linux-foundation.org>,
Christoph Lameter <cl@linux.com>,
Pekka Enberg <penberg@kernel.org>,
David Rientjes <rientjes@google.com>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>,
Vlastimil Babka <vbabka@suse.cz>,
Roman Gushchin <roman.gushchin@linux.dev>,
Hyeonggon Yoo <42.hyeyoo@gmail.com>,
Thomas Gleixner <tglx@linutronix.de>,
"Eric W. Biederman" <ebiederm@xmission.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Andy Lutomirski <luto@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
"Liam R. Howlett" <Liam.Howlett@oracle.com>,
Fenghua Yu <fenghua.yu@intel.com>,
Andrei Vagin <avagin@gmail.com>
Subject: Re: [PATCH 9/9] mm: kmemleak: fix undetected leaks for page aligned objects
Date: Tue, 24 Jan 2023 16:16:22 +0000 [thread overview]
Message-ID: <Y9AEVhNyllqmn0ZH@casper.infradead.org> (raw)
In-Reply-To: <20230123170419.7292-10-george@enfabrica.net>
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);
next prev parent reply other threads:[~2023-01-24 16:16 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-23 17:04 [PATCH 0/9] mm: kmemleak: fix unreported memory leaks George Prekas
2023-01-23 17:04 ` [PATCH 1/9] mm: kmemleak: properly disable task stack scanning George Prekas
2023-01-24 0:39 ` kernel test robot
2023-01-24 5:46 ` kernel test robot
2023-01-24 5:57 ` kernel test robot
2023-01-24 6:07 ` kernel test robot
2023-01-25 14:47 ` Catalin Marinas
2023-02-01 15:38 ` kernel test robot
2023-01-23 17:04 ` [PATCH 2/9] Revert "mm/kmemleak: make create_object return void" George Prekas
2023-01-23 17:04 ` [PATCH 3/9] mm: kmemleak: propagate NO_SCAN flag in delete_object_part George Prekas
2023-01-23 17:04 ` [PATCH 4/9] mm: kmemleak: add kmemleak_noscan_phys function George Prekas
2023-01-23 17:04 ` [PATCH 5/9] mm: kmemleak: do not scan sparsemap_buf George Prekas
2023-01-23 17:04 ` [PATCH 6/9] mm: kmemleak: do not scan cpu_cache of struct kmem_cache George Prekas
2023-01-23 17:04 ` [PATCH 7/9] mm: kmemleak: erase page->s_mem in slab_destroy George Prekas
2023-01-26 11:28 ` Christoph Lameter
2023-01-23 17:04 ` [PATCH 8/9] mm: kmemleak: erase page->freelist " George Prekas
2023-01-23 17:04 ` [PATCH 9/9] mm: kmemleak: fix undetected leaks for page aligned objects George Prekas
2023-01-24 16:16 ` Matthew Wilcox [this message]
2023-01-26 11:21 ` Christoph Lameter
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=Y9AEVhNyllqmn0ZH@casper.infradead.org \
--to=willy@infradead.org \
--cc=42.hyeyoo@gmail.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=avagin@gmail.com \
--cc=bigeasy@linutronix.de \
--cc=catalin.marinas@arm.com \
--cc=cl@linux.com \
--cc=ebiederm@xmission.com \
--cc=fenghua.yu@intel.com \
--cc=george@enfabrica.net \
--cc=iamjoonsoo.kim@lge.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=luto@kernel.org \
--cc=penberg@kernel.org \
--cc=peterz@infradead.org \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=tglx@linutronix.de \
--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