[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250618115737.GI1613376@noisy.programming.kicks-ass.net>
Date: Wed, 18 Jun 2025 13:57:37 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: "Masami Hiramatsu (Google)" <mhiramat@...nel.org>
Cc: Ingo Molnar <mingo@...nel.org>, Thomas Gleixner <tglx@...utronix.de>,
Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Steven Rostedt <rostedt@...dmis.org>, x86@...nel.org,
Naresh Kamboju <naresh.kamboju@...aro.org>,
open list <linux-kernel@...r.kernel.org>,
Linux trace kernel <linux-trace-kernel@...r.kernel.org>,
lkft-triage@...ts.linaro.org,
Stephen Rothwell <sfr@...b.auug.org.au>,
Arnd Bergmann <arnd@...db.de>,
Dan Carpenter <dan.carpenter@...aro.org>,
Anders Roxell <anders.roxell@...aro.org>
Subject: Re: [PATCH] x86: alternative: Fix int3 handling failure from broken
text_poke array
On Wed, Jun 18, 2025 at 09:05:23AM +0900, Masami Hiramatsu (Google) wrote:
> From: Masami Hiramatsu (Google) <mhiramat@...nel.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@...aro.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@...nel.org>
> Reviewed-by: Steven Rostedt (Google) <rostedt@...dmis.org>
> Tested-by: Linux Kernel Functional Testing <lkft@...aro.org>
Thanks!
Powered by blists - more mailing lists