Skip to content

Commit 7fd7d5c

Browse files
committed
Merge tag 'riscv-for-linus-5.12-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull RISC-V fixes from Palmer Dabbelt: "A handful of fixes for 5.12: - fix a stack tracing regression related to "const register asm" variables, which have unexpected behavior. - ensure the value to be written by put_user() is evaluated before enabling access to userspace memory.. - align the exception vector table correctly, so we don't rely on the firmware's handling of unaligned accesses. - build fix to make NUMA depend on MMU, which triggered on some randconfigs" * tag 'riscv-for-linus-5.12-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: riscv: Make NUMA depend on MMU riscv: remove unneeded semicolon riscv,entry: fix misaligned base for excp_vect_table riscv: evaluate put_user() arg before enabling user access riscv: Drop const annotation for sp
2 parents 9c2ef23 + 1adbc29 commit 7fd7d5c

File tree

5 files changed

+9
-5
lines changed

5 files changed

+9
-5
lines changed

arch/riscv/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ endchoice
314314
# Common NUMA Features
315315
config NUMA
316316
bool "NUMA Memory Allocation and Scheduler Support"
317-
depends on SMP
317+
depends on SMP && MMU
318318
select GENERIC_ARCH_NUMA
319319
select OF_NUMA
320320
select ARCH_SUPPORTS_NUMA_BALANCING

arch/riscv/include/asm/uaccess.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,9 @@ do { \
306306
* data types like structures or arrays.
307307
*
308308
* @ptr must have pointer-to-simple-variable type, and @x must be assignable
309-
* to the result of dereferencing @ptr.
309+
* to the result of dereferencing @ptr. The value of @x is copied to avoid
310+
* re-ordering where @x is evaluated inside the block that enables user-space
311+
* access (thus bypassing user space protection if @x is a function).
310312
*
311313
* Caller must check the pointer with access_ok() before calling this
312314
* function.
@@ -316,12 +318,13 @@ do { \
316318
#define __put_user(x, ptr) \
317319
({ \
318320
__typeof__(*(ptr)) __user *__gu_ptr = (ptr); \
321+
__typeof__(*__gu_ptr) __val = (x); \
319322
long __pu_err = 0; \
320323
\
321324
__chk_user_ptr(__gu_ptr); \
322325
\
323326
__enable_user_access(); \
324-
__put_user_nocheck(x, __gu_ptr, __pu_err); \
327+
__put_user_nocheck(__val, __gu_ptr, __pu_err); \
325328
__disable_user_access(); \
326329
\
327330
__pu_err; \

arch/riscv/kernel/entry.S

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ ENDPROC(__switch_to)
447447
#endif
448448

449449
.section ".rodata"
450+
.align LGREG
450451
/* Exception vector table */
451452
ENTRY(excp_vect_table)
452453
RISCV_PTR do_trap_insn_misaligned

arch/riscv/kernel/stacktrace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
#include <asm/stacktrace.h>
1616

17-
register const unsigned long sp_in_global __asm__("sp");
17+
register unsigned long sp_in_global __asm__("sp");
1818

1919
#ifdef CONFIG_FRAME_POINTER
2020

arch/riscv/mm/kasan_init.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ void __init kasan_init(void)
216216
break;
217217

218218
kasan_populate(kasan_mem_to_shadow(start), kasan_mem_to_shadow(end));
219-
};
219+
}
220220

221221
for (i = 0; i < PTRS_PER_PTE; i++)
222222
set_pte(&kasan_early_shadow_pte[i],

0 commit comments

Comments
 (0)