mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Alexander Potapenko <glider@google.com>
Cc: vrilutza@gmail.com, Marco Elver <elver@google.com>,
	Dmitry Vyukov <dvyukov@google.com>,
	Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
	Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Kees Cook <kees@kernel.org>, Borislav Petkov <bp@suse.de>,
	kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] x86/kmsan: Fix CPU entry area metadata lookup
Date: Tue, 27 Oct 2026 17:26:14 +0100	[thread overview]
Message-ID: <20261027162614.GB1779021@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <CAG_fn=X=edvfVtq35i7baEKems+ahRb87LY66xLwGLvW9BLZdg@mail.gmail.com>

On Tue, Oct 27, 2026 at 04:28:36PM +0100, Alexander Potapenko wrote:
> On Tue, Oct 6, 2026 at 8:10 PM Viorel Cernateanu via B4 Relay
> <devnull+vrilutza.gmail.com@kernel.org> wrote:
> >
> > From: Viorel Cernateanu <vrilutza@gmail.com>
> >
> > arch_kmsan_get_meta_or_null() works out which CPU owns an address in the
> > CPU entry area as (addr - CPU_ENTRY_AREA_BASE) / CPU_ENTRY_AREA_SIZE.
> > That is wrong in two ways:
> >
> >  - With KASLR, init_cea_offsets() puts each CPU's area in a random slot,
> >    so the result is a slot number, usually far above NR_CPUS, and
> >    get_cpu_entry_area() reads past the end of __per_cpu_offset[].
> 
> Thanks for noticing this!
> I find the O(n) lookup per each memory access to the cpu_entry_area
> excessive. Could we disable the randomization in
> arch/x86/mm/cpu_entry_area.c
> 
>         if (!kaslr_enabled() || IS_ENABLED(CONFIG_KMSAN)) {
>                 for_each_possible_cpu(i)
>                         per_cpu(_cea_offset, i) = i;
>                 return;
>         }
> 
> (there's a similar precedent for KASAN in arch/x86/include/asm/setup.h already)
> 
> Peter, what do you think?

I suppose that works; KMSAN is a debug kernel per definition and I don't
think we really care all that much about kaslr on debug kernels (I
certainly have it disabled on all my dev boxes because its a pain).

  reply	other threads:[~2026-10-27 16:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-06 18:10 [PATCH 0/2] x86/kmsan: Fix two bugs in the " Viorel Cernateanu via B4 Relay
2026-10-06 18:10 ` [PATCH 1/2] x86/kmsan: Fix CPU entry area " Viorel Cernateanu via B4 Relay
2026-10-27 15:28   ` Alexander Potapenko
2026-10-27 16:26     ` Peter Zijlstra [this message]
2026-10-06 18:10 ` [PATCH 2/2] x86/kmsan: Don't call instrumented code from kmsan_virt_addr_valid() Viorel Cernateanu via B4 Relay
2026-10-27 16:27   ` Alexander Potapenko

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=20261027162614.GB1779021@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=akpm@linux-foundation.org \
    --cc=bp@alien8.de \
    --cc=bp@suse.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=dvyukov@google.com \
    --cc=elver@google.com \
    --cc=glider@google.com \
    --cc=hpa@zytor.com \
    --cc=kasan-dev@googlegroups.com \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@kernel.org \
    --cc=vrilutza@gmail.com \
    --cc=x86@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

all inboxes | Powered by JetHome®