From: "Zhang, Qiang1" <qiang1.zhang@intel.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "ryabinin.a.a@gmail.com" <ryabinin.a.a@gmail.com>,
"dvyukov@google.com" <dvyukov@google.com>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Alexander Potapenko" <glider@google.com>,
Andrey Konovalov <andreyknvl@gmail.com>,
kasan-dev <kasan-dev@googlegroups.com>
Subject: RE: [PATCH] kasan: Prevent cpu_quarantine corruption when CPU offline and cache shrink occur at same time
Date: Mon, 25 Apr 2022 14:25:16 +0000 [thread overview]
Message-ID: <PH0PR11MB5880B595E4836DF66928692DDAF89@PH0PR11MB5880.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20220421150746.627e0f62363485d65c857010@linux-foundation.org>
On Thu, 14 Apr 2022 10:59:25 +0800 Zqiang <qiang1.zhang@intel.com> wrote:
> The kasan_quarantine_remove_cache() is called in kmem_cache_shrink()/
> destroy(), the kasan_quarantine_remove_cache() call is protected by
> cpuslock in kmem_cache_destroy(), can ensure serialization with
> kasan_cpu_offline(). however the kasan_quarantine_remove_cache() call
> is not protected by cpuslock in kmem_cache_shrink(), when CPU going
> offline and cache shrink occur at same time, the cpu_quarantine may be
> corrupted by interrupt(per_cpu_remove_cache operation). so add
> cpu_quarantine offline flags check in per_cpu_remove_cache().
>
> ...
>
>Could we please have some reviewer input here?
> --- a/mm/kasan/quarantine.c
> +++ b/mm/kasan/quarantine.c
> @@ -330,6 +330,8 @@ static void per_cpu_remove_cache(void *arg)
> struct cpu_shrink_qlist *sq;
> #endif
> q = this_cpu_ptr(&cpu_quarantine);
> + if (READ_ONCE(q->offline))
> + return;
> #ifndef CONFIG_PREEMPT_RT
> qlist_move_cache(q, &to_free, cache);
> qlist_free_all(&to_free, cache);
>It might be helpful to have a little comment which explains why we're doing this?
Sorry for late reply, may be add some comment:
Ensure the ordering between the writing to q->offline and per_cpu_remove_cache.
prevent cpu_quarantine be corrupted by interrupt.
Is this OK ?
Thanks
Zqiang
prev parent reply other threads:[~2022-04-25 14:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-14 2:59 Zqiang
2022-04-21 22:07 ` Andrew Morton
2022-04-22 9:27 ` Dmitry Vyukov
2022-04-25 14:25 ` Zhang, Qiang1 [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=PH0PR11MB5880B595E4836DF66928692DDAF89@PH0PR11MB5880.namprd11.prod.outlook.com \
--to=qiang1.zhang@intel.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 \
/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