Skip to content

Commit 95fc76c

Browse files
committed
Merge tag 'powerpc-5.19-2' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
Pull powerpc fixes from Michael Ellerman: - On 32-bit fix overread/overwrite of thread_struct via ptrace PEEK/POKE. - Fix softirqs not switching to the softirq stack since we moved irq_exit(). - Force thread size increase when KASAN is enabled to avoid stack overflows. - On Book3s 64 mark more code as not to be instrumented by KASAN to avoid crashes. - Exempt __get_wchan() from KASAN checking, as it's inherently racy. - Fix a recently introduced crash in the papr_scm driver in some configurations. - Remove include of <generated/compile.h> which is forbidden. Thanks to Ariel Miculas, Chen Jingwen, Christophe Leroy, Erhard Furtner, He Ying, Kees Cook, Masahiro Yamada, Nageswara R Sastry, Paul Mackerras, Sachin Sant, Vaibhav Jain, and Wanming Hu. * tag 'powerpc-5.19-2' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: powerpc/32: Fix overread/overwrite of thread_struct via ptrace powerpc/book3e: get rid of #include <generated/compile.h> powerpc/kasan: Force thread size increase with KASAN powerpc/papr_scm: don't requests stats with '0' sized stats buffer powerpc: Don't select HAVE_IRQ_EXIT_ON_IRQ_STACK powerpc/kasan: Silence KASAN warnings in __get_wchan() powerpc/kasan: Mark more real-mode code as not to be instrumented
2 parents 825464e + 8e12784 commit 95fc76c

File tree

11 files changed

+38
-21
lines changed

11 files changed

+38
-21
lines changed

arch/powerpc/Kconfig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ config PPC
223223
select HAVE_HARDLOCKUP_DETECTOR_PERF if PERF_EVENTS && HAVE_PERF_EVENTS_NMI && !HAVE_HARDLOCKUP_DETECTOR_ARCH
224224
select HAVE_HW_BREAKPOINT if PERF_EVENTS && (PPC_BOOK3S || PPC_8xx)
225225
select HAVE_IOREMAP_PROT
226-
select HAVE_IRQ_EXIT_ON_IRQ_STACK
227226
select HAVE_IRQ_TIME_ACCOUNTING
228227
select HAVE_KERNEL_GZIP
229228
select HAVE_KERNEL_LZMA if DEFAULT_UIMAGE
@@ -786,7 +785,6 @@ config THREAD_SHIFT
786785
range 13 15
787786
default "15" if PPC_256K_PAGES
788787
default "14" if PPC64
789-
default "14" if KASAN
790788
default "13"
791789
help
792790
Used to define the stack size. The default is almost always what you

arch/powerpc/include/asm/thread_info.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,16 @@
1414

1515
#ifdef __KERNEL__
1616

17-
#if defined(CONFIG_VMAP_STACK) && CONFIG_THREAD_SHIFT < PAGE_SHIFT
17+
#ifdef CONFIG_KASAN
18+
#define MIN_THREAD_SHIFT (CONFIG_THREAD_SHIFT + 1)
19+
#else
20+
#define MIN_THREAD_SHIFT CONFIG_THREAD_SHIFT
21+
#endif
22+
23+
#if defined(CONFIG_VMAP_STACK) && MIN_THREAD_SHIFT < PAGE_SHIFT
1824
#define THREAD_SHIFT PAGE_SHIFT
1925
#else
20-
#define THREAD_SHIFT CONFIG_THREAD_SHIFT
26+
#define THREAD_SHIFT MIN_THREAD_SHIFT
2127
#endif
2228

2329
#define THREAD_SIZE (1 << THREAD_SHIFT)

arch/powerpc/kernel/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ KASAN_SANITIZE_paca.o := n
3737
KASAN_SANITIZE_setup_64.o := n
3838
KASAN_SANITIZE_mce.o := n
3939
KASAN_SANITIZE_mce_power.o := n
40+
KASAN_SANITIZE_udbg.o := n
41+
KASAN_SANITIZE_udbg_16550.o := n
4042

4143
# we have to be particularly careful in ppc64 to exclude code that
4244
# runs with translations off, as we cannot access the shadow with

arch/powerpc/kernel/process.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2158,12 +2158,12 @@ static unsigned long ___get_wchan(struct task_struct *p)
21582158
return 0;
21592159

21602160
do {
2161-
sp = *(unsigned long *)sp;
2161+
sp = READ_ONCE_NOCHECK(*(unsigned long *)sp);
21622162
if (!validate_sp(sp, p, STACK_FRAME_OVERHEAD) ||
21632163
task_is_running(p))
21642164
return 0;
21652165
if (count > 0) {
2166-
ip = ((unsigned long *)sp)[STACK_FRAME_LR_SAVE];
2166+
ip = READ_ONCE_NOCHECK(((unsigned long *)sp)[STACK_FRAME_LR_SAVE]);
21672167
if (!in_sched_functions(ip))
21682168
return ip;
21692169
}

arch/powerpc/kernel/ptrace/ptrace-fpu.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@ int ptrace_get_fpr(struct task_struct *child, int index, unsigned long *data)
1717

1818
#ifdef CONFIG_PPC_FPU_REGS
1919
flush_fp_to_thread(child);
20-
if (fpidx < (PT_FPSCR - PT_FPR0))
21-
memcpy(data, &child->thread.TS_FPR(fpidx), sizeof(long));
22-
else
20+
if (fpidx < (PT_FPSCR - PT_FPR0)) {
21+
if (IS_ENABLED(CONFIG_PPC32))
22+
// On 32-bit the index we are passed refers to 32-bit words
23+
*data = ((u32 *)child->thread.fp_state.fpr)[fpidx];
24+
else
25+
memcpy(data, &child->thread.TS_FPR(fpidx), sizeof(long));
26+
} else
2327
*data = child->thread.fp_state.fpscr;
2428
#else
2529
*data = 0;
@@ -39,9 +43,13 @@ int ptrace_put_fpr(struct task_struct *child, int index, unsigned long data)
3943

4044
#ifdef CONFIG_PPC_FPU_REGS
4145
flush_fp_to_thread(child);
42-
if (fpidx < (PT_FPSCR - PT_FPR0))
43-
memcpy(&child->thread.TS_FPR(fpidx), &data, sizeof(long));
44-
else
46+
if (fpidx < (PT_FPSCR - PT_FPR0)) {
47+
if (IS_ENABLED(CONFIG_PPC32))
48+
// On 32-bit the index we are passed refers to 32-bit words
49+
((u32 *)child->thread.fp_state.fpr)[fpidx] = data;
50+
else
51+
memcpy(&child->thread.TS_FPR(fpidx), &data, sizeof(long));
52+
} else
4553
child->thread.fp_state.fpscr = data;
4654
#endif
4755

arch/powerpc/kernel/ptrace/ptrace.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,4 +444,7 @@ void __init pt_regs_check(void)
444444
* real registers.
445445
*/
446446
BUILD_BUG_ON(PT_DSCR < sizeof(struct user_pt_regs) / sizeof(unsigned long));
447+
448+
// ptrace_get/put_fpr() rely on PPC32 and VSX being incompatible
449+
BUILD_BUG_ON(IS_ENABLED(CONFIG_PPC32) && IS_ENABLED(CONFIG_VSX));
447450
}

arch/powerpc/kernel/rtas.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -993,8 +993,8 @@ int rtas_call_reentrant(int token, int nargs, int nret, int *outputs, ...)
993993
*
994994
* Return: A pointer to the specified errorlog or NULL if not found.
995995
*/
996-
struct pseries_errorlog *get_pseries_errorlog(struct rtas_error_log *log,
997-
uint16_t section_id)
996+
noinstr struct pseries_errorlog *get_pseries_errorlog(struct rtas_error_log *log,
997+
uint16_t section_id)
998998
{
999999
struct rtas_ext_event_log_v6 *ext_log =
10001000
(struct rtas_ext_event_log_v6 *)log->buffer;

arch/powerpc/kexec/crash.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ void crash_kexec_secondary(struct pt_regs *regs)
224224

225225
/* wait for all the CPUs to hit real mode but timeout if they don't come in */
226226
#if defined(CONFIG_SMP) && defined(CONFIG_PPC64)
227-
static void __maybe_unused crash_kexec_wait_realmode(int cpu)
227+
noinstr static void __maybe_unused crash_kexec_wait_realmode(int cpu)
228228
{
229229
unsigned int msecs;
230230
int i;

arch/powerpc/mm/nohash/kaslr_booke.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include <asm/cacheflush.h>
2020
#include <asm/kdump.h>
2121
#include <mm/mmu_decl.h>
22-
#include <generated/compile.h>
2322
#include <generated/utsrelease.h>
2423

2524
struct regions {
@@ -37,10 +36,6 @@ struct regions {
3736
int reserved_mem_size_cells;
3837
};
3938

40-
/* Simplified build-specific string for starting entropy. */
41-
static const char build_str[] = UTS_RELEASE " (" LINUX_COMPILE_BY "@"
42-
LINUX_COMPILE_HOST ") (" LINUX_COMPILER ") " UTS_VERSION;
43-
4439
struct regions __initdata regions;
4540

4641
static __init void kaslr_get_cmdline(void *fdt)
@@ -71,7 +66,8 @@ static unsigned long __init get_boot_seed(void *fdt)
7166
{
7267
unsigned long hash = 0;
7368

74-
hash = rotate_xor(hash, build_str, sizeof(build_str));
69+
/* build-specific string for starting entropy. */
70+
hash = rotate_xor(hash, linux_banner, strlen(linux_banner));
7571
hash = rotate_xor(hash, fdt, fdt_totalsize(fdt));
7672

7773
return hash;

arch/powerpc/platforms/powernv/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# in particular, idle code runs a bunch of things in real mode
55
KASAN_SANITIZE_idle.o := n
66
KASAN_SANITIZE_pci-ioda.o := n
7+
KASAN_SANITIZE_pci-ioda-tce.o := n
78
# pnv_machine_check_early
89
KASAN_SANITIZE_setup.o := n
910

0 commit comments

Comments
 (0)