Re: [PATCH] percpu: add basic double free check

From: Andrew Morton

Date: Thu Jan 15 2026 - 18:13:29 EST


On Wed, 14 Jan 2026 04:22:00 -0800 Chris Mason <clm@xxxxxxxx> wrote:

> On Fri, 19 Dec 2025 16:27:37 -0800 Dennis Zhou <dennis@xxxxxxxxxx> 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.