Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Hui Su <sh_def@163.com>
To: akpm@linux-foundation.org
Cc: ryabinin.a.a@gmail.com, glider@google.com, andreyknvl@gmail.com,
	dvyukov@google.com, vincenzo.frascino@arm.com,
	kasan-dev@googlegroups.com, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, sashiko-bot@kernel.org
Subject: Re: [PATCH] kasan: fix quarantine_size accounting during cache removal
Date: Wed, 12 Aug 2026 10:34:42 +0800	[thread overview]
Message-ID: <20260812023441.2067480-2-sh_def@163.com> (raw)
In-Reply-To: <20260811182914.ed2cba4ef1a8a88335b9edab@linux-foundation.org>

> > quarantine_size tracks the total number of bytes stored in
> > global_quarantine[]. It is incremented when per-CPU quarantine objects
> > are moved into the global quarantine and decremented when a global
> > batch is evicted by kasan_quarantine_reduce().
> >
> > kasan_quarantine_remove_cache() also removes objects from the global
> > quarantine. qlist_move_cache() rebuilds the source batch and updates
> > its .bytes field, but quarantine_size is not adjusted accordingly.
> >
> > As a result, quarantine_size remains over-counted by the size of the
> > removed objects. The stale accounting accumulates across cache removals.
> > Once the inflated value exceeds quarantine_max_size,
> > kasan_quarantine_reduce() can evict a batch even though the actual
> > number of bytes in global_quarantine[] is still below
> > quarantine_max_size, shortening the quarantine window.
> >
> > Fix the accounting by recording each batch's size before
> > qlist_move_cache() and subtracting the number of bytes actually removed
> > from quarantine_size while holding quarantine_lock.
> >
> > A KUnit reproducer used during testing observed the over-count grow by
> > 4698864 bytes after one kasan_quarantine_remove_cache() call with the
> > fix reverted. With this change applied, the over-count did not grow.
> >
> 
> Thanks.
> 
> > @@ -365,9 +365,14 @@ void kasan_quarantine_remove_cache(struct kmem_cache *cache)
> 
> Sashiko might have found an unrelated pre-existing bug in here.
> 
> 	https://sashiko.dev/#/patchset/20260811073332.1351893-1-sh_def@163.com

Thanks for pointing this out.

The issue found by Sashiko was fixed by a previous patch:
https://lore.kernel.org/lkml/20260808031459.3032812-1-sh_def@163.com/



      reply	other threads:[~2026-08-12  2:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-11  7:33 [PATCH] kasan: fix quarantine_size accounting during cache removal Hui Su
2026-08-11 18:50 ` Andrey Ryabinin
2026-08-12  1:29 ` Andrew Morton
2026-08-12  2:34   ` Hui Su [this message]

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=20260812023441.2067480-2-sh_def@163.com \
    --to=sh_def@163.com \
    --cc=akpm@linux-foundation.org \
    --cc=andreyknvl@gmail.com \
    --cc=dvyukov@google.com \
    --cc=glider@google.com \
    --cc=kasan-dev@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ryabinin.a.a@gmail.com \
    --cc=sashiko-bot@kernel.org \
    --cc=vincenzo.frascino@arm.com \
    /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