mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	x86@kernel.org, Naresh Kamboju <naresh.kamboju@linaro.org>,
	open list <linux-kernel@vger.kernel.org>,
	Linux trace kernel <linux-trace-kernel@vger.kernel.org>,
	lkft-triage@lists.linaro.org,
	Stephen Rothwell <sfr@canb.auug.org.au>,
	Arnd Bergmann <arnd@arndb.de>,
	Dan Carpenter <dan.carpenter@linaro.org>,
	Anders Roxell <anders.roxell@linaro.org>
Subject: Re: [PATCH] x86: alternative: Fix int3 handling failure from broken text_poke array
Date: Wed, 18 Jun 2025 13:57:37 +0200	[thread overview]
Message-ID: <20250618115737.GI1613376@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <175020512308.3582717.13631440385506146631.stgit@mhiramat.tok.corp.google.com>

On Wed, Jun 18, 2025 at 09:05:23AM +0900, Masami Hiramatsu (Google) wrote:
> From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> 
> Since smp_text_poke_single() does not expect there is another
> text_poke request is queued, it can make text_poke_array not
> sorted or cause a buffer overflow on the text_poke_array.vec[].
> This will cause an Oops in int3 because of bsearch failing;
> 
> 
>    CPU 0                        CPU 1                      CPU 2
>    -----                        -----                      -----
> 
>  smp_text_poke_batch_add()
> 
> 			    smp_text_poke_single() <<-- Adds out of order
> 
> 							<int3>
>                                                 	[Fails o find address
>                                                         in text_poke_array ]
>                                                         OOPS!
> 
> Or unhandled page fault because of a buffer overflow;
> 
> 
>    CPU 0                        CPU 1
>    -----                        -----
> 
>  smp_text_poke_batch_add() <<+
>  ...                         |
>  smp_text_poke_batch_add() <<-- Adds TEXT_POKE_ARRAY_MAX times.
> 
> 			     smp_text_poke_single() {
> 			     	__smp_text_poke_batch_add() <<-- Adds entry at
> 								TEXT_POKE_ARRAY_MAX + 1
> 
>                 		smp_text_poke_batch_finish()
>                         	  [Unhandled page fault because
> 				   text_poke_array.nr_entries is
> 				   overwritten]
> 				   BUG!
> 			     }
> 
> 
> Use smp_text_poke_batch_add() instead of __smp_text_poke_batch_add()
> so that it correctly flush the queue if needed.
> 
> Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>
> Closes: https://lore.kernel.org/all/CA+G9fYsLu0roY3DV=tKyqP7FEKbOEETRvTDhnpPxJGbA=Cg+4w@mail.gmail.com/
> Fixes: c8976ade0c1b ("x86/alternatives: Simplify smp_text_poke_single() by using tp_vec and existing APIs")
> Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> Tested-by: Linux Kernel Functional Testing <lkft@linaro.org>

Thanks!

      reply	other threads:[~2025-06-18 11:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-18  0:05 Masami Hiramatsu (Google)
2025-06-18 11:57 ` Peter Zijlstra [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=20250618115737.GI1613376@noisy.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=anders.roxell@linaro.org \
    --cc=arnd@arndb.de \
    --cc=bp@alien8.de \
    --cc=dan.carpenter@linaro.org \
    --cc=dave.hansen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=lkft-triage@lists.linaro.org \
    --cc=mhiramat@kernel.org \
    --cc=mingo@kernel.org \
    --cc=naresh.kamboju@linaro.org \
    --cc=rostedt@goodmis.org \
    --cc=sfr@canb.auug.org.au \
    --cc=tglx@linutronix.de \
    --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®