From: Dennis Zhou <dennis@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Chris Mason <clm@meta.com>, Tejun Heo <tj@kernel.org>,
Christoph Lameter <cl@linux.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Subject: Re: [PATCH] percpu: add basic double free check
Date: Thu, 15 Jan 2026 18:56:53 -0800 [thread overview]
Message-ID: <aWmo9elLCfyb96VR@snowbird> (raw)
In-Reply-To: <20260115151328.38cc7cf0d0b8bf97ee5b3791@linux-foundation.org>
Hi Andrew,
On Thu, Jan 15, 2026 at 03:13:28PM -0800, Andrew Morton wrote:
> On Wed, 14 Jan 2026 04:22:00 -0800 Chris Mason <clm@meta.com> wrote:
>
> > On Fri, 19 Dec 2025 16:27:37 -0800 Dennis Zhou <dennis@kernel.org> wrote:
> >
> > > This adds a basic double free check by validating the first bit of the
> > > allocation in alloc_map and bound_map are set. If the alloc_map bit is
> > > not set, then this means the area is currently unallocated. If the
> > > bound_map bit is not set, then we are not freeing from the beginning of
> > > the allocation.
> >
> > Hi Dennis,
> >
> > I ran mm-new through the AI review prompts, and this one was flagged:
>
> So good.
>
> > If nr_alloc is underreported due to this bug, the buffer may be undersized
> > for the actual number of allocations tracked in alloc_map, which
> > chunk_map_stats() iterates based on the actual bitmap contents.
>
> That's pretty serious, although unlikely to occur. I'll drop this
> version of the patch, thanks.
>
It's a good catch by AI, I fixed it in v2 [1].
My thoughts are this is really to serve developers. It's not really a
recoverable error because if the pointer is re-allocated before the
double free, then you'll only find out in the future when the new owner
tries to free memory that it doesn't own. An even more contrived case is
the pages get freed out from under it and then the new owner seg faults.
Thanks,
Dennis
[1] https://lore.kernel.org/lkml/20260116023216.14515-1-dennis@kernel.org/
next prev parent reply other threads:[~2026-01-16 2:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-20 0:27 Dennis Zhou
2026-01-12 16:03 ` Sebastian Andrzej Siewior
2026-01-14 12:22 ` Chris Mason
2026-01-15 23:13 ` Andrew Morton
2026-01-16 2:56 ` Dennis Zhou [this message]
2026-01-16 2:38 ` Dennis Zhou
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=aWmo9elLCfyb96VR@snowbird \
--to=dennis@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=bigeasy@linutronix.de \
--cc=cl@linux.com \
--cc=clm@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=tj@kernel.org \
/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