[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMo8BfJiuPYk8tBVKt6=c3E2SzHBe+0QTo02k3u8KL1CGtEvFQ@mail.gmail.com>
Date: Sun, 14 Dec 2025 19:06:56 -0800
From: Max Filippov <jcmvbkbc@...il.com>
To: Ricky Ringler <richard.rringler@...il.com>
Cc: Chris Zankel <chris@...kel.net>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] xtensa: align: validate access in fast_load_store
On Sun, Dec 14, 2025 at 2:30 PM Ricky Ringler
<richard.rringler@...il.com> wrote:
>
> access_ok() is used only in user mode and
> branches to .Linvalid_instruction on fault.
> Kernel mode behavior unchanged.
>
> v2:
> - Address Max's feedback
> - Fixed formatting
> - Added user mode branch
Please move the patch change log past the `---` marker so that
it is dropped when the patch is committed.
> Tested-by: Ricky Ringler <richard.rringler@...il.com>
>
> Testing:
> - Built with CONFIG_MMU enabled
> - objdump before/after comparison and validated code path
>
> Signed-off-by: Ricky Ringler <richard.rringler@...il.com>
> ---
> arch/xtensa/kernel/align.S | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/arch/xtensa/kernel/align.S b/arch/xtensa/kernel/align.S
> index ee97edce2300..64e775933e9b 100644
> --- a/arch/xtensa/kernel/align.S
> +++ b/arch/xtensa/kernel/align.S
> @@ -21,6 +21,9 @@
> #include <asm/asm-offsets.h>
> #include <asm/asmmacro.h>
> #include <asm/processor.h>
> +#ifdef CONFIG_MMU
> +#include <asm/asm-uaccess.h>
> +#endif
>
> #if XCHAL_UNALIGNED_LOAD_EXCEPTION || defined CONFIG_XTENSA_LOAD_STORE
> #define LOAD_EXCEPTION_HANDLER
> @@ -185,8 +188,12 @@ ENTRY(fast_load_store)
>
> #ifdef CONFIG_MMU
> /* l32e can't be used here even when it's available. */
> - /* TODO access_ok(a3) could be used here */
> - j .Linvalid_instruction
> + rsr a6, ps
> + bbsi.l a6, PS_UM_BIT, 1f # user mode
> + j .Linvalid_instruction # kernel mode
It should be the other way around: kernel mode is allowed to access
anything, user mode needs address checking.
> +1:
> + movi a5, 8
> + access_ok a3, a5, a6, a2, .Linvalid_instruction
> #endif
> l32i a5, a3, 0
> l32i a6, a3, 4
> --
> 2.43.0
>
--
Thanks.
-- Max
Powered by blists - more mailing lists