public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: stable@vger.kernel.org, Fei Yang <fei.yang@intel.com>,
	Ingo Molnar <mingo@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH 6.1.y] x86/alternatives: Disable KASAN in apply_alternatives()
Date: Mon, 16 Oct 2023 09:47:36 +0200	[thread overview]
Message-ID: <2023101627-yield-trickle-9105@gregkh> (raw)
In-Reply-To: <20231015200908.3254-1-kirill.shutemov@linux.intel.com>

On Sun, Oct 15, 2023 at 11:09:08PM +0300, Kirill A. Shutemov wrote:
> Fei has reported that KASAN triggers during apply_alternatives() on
> a 5-level paging machine:
> 
> 	BUG: KASAN: out-of-bounds in rcu_is_watching()
> 	Read of size 4 at addr ff110003ee6419a0 by task swapper/0/0
> 	...
> 	__asan_load4()
> 	rcu_is_watching()
> 	trace_hardirqs_on()
> 	text_poke_early()
> 	apply_alternatives()
> 	...
> 
> On machines with 5-level paging, cpu_feature_enabled(X86_FEATURE_LA57)
> gets patched. It includes KASAN code, where KASAN_SHADOW_START depends on
> __VIRTUAL_MASK_SHIFT, which is defined with cpu_feature_enabled().
> 
> KASAN gets confused when apply_alternatives() patches the
> KASAN_SHADOW_START users. A test patch that makes KASAN_SHADOW_START
> static, by replacing __VIRTUAL_MASK_SHIFT with 56, works around the issue.
> 
> Fix it for real by disabling KASAN while the kernel is patching alternatives.
> 
> [ mingo: updated the changelog ]
> 
> Fixes: 6657fca06e3f ("x86/mm: Allow to boot without LA57 if CONFIG_X86_5LEVEL=y")
> Reported-by: Fei Yang <fei.yang@intel.com>
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Signed-off-by: Ingo Molnar <mingo@kernel.org>
> Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> Cc: Linus Torvalds <torvalds@linux-foundation.org>
> Cc: stable@vger.kernel.org
> Link: https://lore.kernel.org/r/20231012100424.1456-1-kirill.shutemov@linux.intel.com
> (cherry picked from commit d35652a5fc9944784f6f50a5c979518ff8dacf61)
> Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> ---
>  arch/x86/kernel/alternative.c | 13 +++++++++++++
>  1 file changed, 13 insertions(+)

All now queued up, thanks.

greg k-h

      reply	other threads:[~2023-10-16  7:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-15 18:17 FAILED: patch "[PATCH] x86/alternatives: Disable KASAN in apply_alternatives()" failed to apply to 6.1-stable tree gregkh
2023-10-15 20:09 ` [PATCH 6.1.y] x86/alternatives: Disable KASAN in apply_alternatives() Kirill A. Shutemov
2023-10-16  7:47   ` Greg KH [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=2023101627-yield-trickle-9105@gregkh \
    --to=greg@kroah.com \
    --cc=fei.yang@intel.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linux-foundation.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