Skip to content

Commit 0d4b3ca

Browse files
Ricky Ringlerjcmvbkbc
authored andcommitted
xtensa: align: validate access in fast_load_store
access_ok() is used only in user mode and branches to .Linvalid_instruction on fault. Kernel mode skips access_ok(). Tested-by: Ricky Ringler <richard.rringler@gmail.com> Signed-off-by: Ricky Ringler <richard.rringler@gmail.com> Message-ID: <20251215143323.2771889-1-richard.rringler@gmail.com> Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
1 parent 7d0a66e commit 0d4b3ca

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

arch/xtensa/kernel/align.S

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
#include <asm/asm-offsets.h>
2222
#include <asm/asmmacro.h>
2323
#include <asm/processor.h>
24+
#ifdef CONFIG_MMU
25+
#include <asm/asm-uaccess.h>
26+
#endif
2427

2528
#if XCHAL_UNALIGNED_LOAD_EXCEPTION || defined CONFIG_XTENSA_LOAD_STORE
2629
#define LOAD_EXCEPTION_HANDLER
@@ -185,8 +188,11 @@ ENTRY(fast_load_store)
185188

186189
#ifdef CONFIG_MMU
187190
/* l32e can't be used here even when it's available. */
188-
/* TODO access_ok(a3) could be used here */
189-
j .Linvalid_instruction
191+
rsr a6, ps
192+
bbci.l a6, PS_UM_BIT, 1f # kernel mode
193+
movi a5, 8
194+
access_ok a3, a5, a6, a2, .Linvalid_instruction
195+
1:
190196
#endif
191197
l32i a5, a3, 0
192198
l32i a6, a3, 4

0 commit comments

Comments
 (0)