lab.nexedi.com will be down from Thursday, 20 March 2025, 07:30:00 UTC for a duration of approximately 2 hours

Commit 95fc76c8 authored by Linus Torvalds's avatar Linus Torvalds

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
parents 825464e7 8e127844
...@@ -223,7 +223,6 @@ config PPC ...@@ -223,7 +223,6 @@ config PPC
select HAVE_HARDLOCKUP_DETECTOR_PERF if PERF_EVENTS && HAVE_PERF_EVENTS_NMI && !HAVE_HARDLOCKUP_DETECTOR_ARCH select HAVE_HARDLOCKUP_DETECTOR_PERF if PERF_EVENTS && HAVE_PERF_EVENTS_NMI && !HAVE_HARDLOCKUP_DETECTOR_ARCH
select HAVE_HW_BREAKPOINT if PERF_EVENTS && (PPC_BOOK3S || PPC_8xx) select HAVE_HW_BREAKPOINT if PERF_EVENTS && (PPC_BOOK3S || PPC_8xx)
select HAVE_IOREMAP_PROT select HAVE_IOREMAP_PROT
select HAVE_IRQ_EXIT_ON_IRQ_STACK
select HAVE_IRQ_TIME_ACCOUNTING select HAVE_IRQ_TIME_ACCOUNTING
select HAVE_KERNEL_GZIP select HAVE_KERNEL_GZIP
select HAVE_KERNEL_LZMA if DEFAULT_UIMAGE select HAVE_KERNEL_LZMA if DEFAULT_UIMAGE
...@@ -786,7 +785,6 @@ config THREAD_SHIFT ...@@ -786,7 +785,6 @@ config THREAD_SHIFT
range 13 15 range 13 15
default "15" if PPC_256K_PAGES default "15" if PPC_256K_PAGES
default "14" if PPC64 default "14" if PPC64
default "14" if KASAN
default "13" default "13"
help help
Used to define the stack size. The default is almost always what you Used to define the stack size. The default is almost always what you
......
...@@ -14,10 +14,16 @@ ...@@ -14,10 +14,16 @@
#ifdef __KERNEL__ #ifdef __KERNEL__
#if defined(CONFIG_VMAP_STACK) && CONFIG_THREAD_SHIFT < PAGE_SHIFT #ifdef CONFIG_KASAN
#define MIN_THREAD_SHIFT (CONFIG_THREAD_SHIFT + 1)
#else
#define MIN_THREAD_SHIFT CONFIG_THREAD_SHIFT
#endif
#if defined(CONFIG_VMAP_STACK) && MIN_THREAD_SHIFT < PAGE_SHIFT
#define THREAD_SHIFT PAGE_SHIFT #define THREAD_SHIFT PAGE_SHIFT
#else #else
#define THREAD_SHIFT CONFIG_THREAD_SHIFT #define THREAD_SHIFT MIN_THREAD_SHIFT
#endif #endif
#define THREAD_SIZE (1 << THREAD_SHIFT) #define THREAD_SIZE (1 << THREAD_SHIFT)
......
...@@ -37,6 +37,8 @@ KASAN_SANITIZE_paca.o := n ...@@ -37,6 +37,8 @@ KASAN_SANITIZE_paca.o := n
KASAN_SANITIZE_setup_64.o := n KASAN_SANITIZE_setup_64.o := n
KASAN_SANITIZE_mce.o := n KASAN_SANITIZE_mce.o := n
KASAN_SANITIZE_mce_power.o := n KASAN_SANITIZE_mce_power.o := n
KASAN_SANITIZE_udbg.o := n
KASAN_SANITIZE_udbg_16550.o := n
# we have to be particularly careful in ppc64 to exclude code that # we have to be particularly careful in ppc64 to exclude code that
# runs with translations off, as we cannot access the shadow with # runs with translations off, as we cannot access the shadow with
......
...@@ -2158,12 +2158,12 @@ static unsigned long ___get_wchan(struct task_struct *p) ...@@ -2158,12 +2158,12 @@ static unsigned long ___get_wchan(struct task_struct *p)
return 0; return 0;
do { do {
sp = *(unsigned long *)sp; sp = READ_ONCE_NOCHECK(*(unsigned long *)sp);
if (!validate_sp(sp, p, STACK_FRAME_OVERHEAD) || if (!validate_sp(sp, p, STACK_FRAME_OVERHEAD) ||
task_is_running(p)) task_is_running(p))
return 0; return 0;
if (count > 0) { if (count > 0) {
ip = ((unsigned long *)sp)[STACK_FRAME_LR_SAVE]; ip = READ_ONCE_NOCHECK(((unsigned long *)sp)[STACK_FRAME_LR_SAVE]);
if (!in_sched_functions(ip)) if (!in_sched_functions(ip))
return ip; return ip;
} }
......
...@@ -17,9 +17,13 @@ int ptrace_get_fpr(struct task_struct *child, int index, unsigned long *data) ...@@ -17,9 +17,13 @@ int ptrace_get_fpr(struct task_struct *child, int index, unsigned long *data)
#ifdef CONFIG_PPC_FPU_REGS #ifdef CONFIG_PPC_FPU_REGS
flush_fp_to_thread(child); flush_fp_to_thread(child);
if (fpidx < (PT_FPSCR - PT_FPR0)) if (fpidx < (PT_FPSCR - PT_FPR0)) {
memcpy(data, &child->thread.TS_FPR(fpidx), sizeof(long)); if (IS_ENABLED(CONFIG_PPC32))
else // On 32-bit the index we are passed refers to 32-bit words
*data = ((u32 *)child->thread.fp_state.fpr)[fpidx];
else
memcpy(data, &child->thread.TS_FPR(fpidx), sizeof(long));
} else
*data = child->thread.fp_state.fpscr; *data = child->thread.fp_state.fpscr;
#else #else
*data = 0; *data = 0;
...@@ -39,9 +43,13 @@ int ptrace_put_fpr(struct task_struct *child, int index, unsigned long data) ...@@ -39,9 +43,13 @@ int ptrace_put_fpr(struct task_struct *child, int index, unsigned long data)
#ifdef CONFIG_PPC_FPU_REGS #ifdef CONFIG_PPC_FPU_REGS
flush_fp_to_thread(child); flush_fp_to_thread(child);
if (fpidx < (PT_FPSCR - PT_FPR0)) if (fpidx < (PT_FPSCR - PT_FPR0)) {
memcpy(&child->thread.TS_FPR(fpidx), &data, sizeof(long)); if (IS_ENABLED(CONFIG_PPC32))
else // On 32-bit the index we are passed refers to 32-bit words
((u32 *)child->thread.fp_state.fpr)[fpidx] = data;
else
memcpy(&child->thread.TS_FPR(fpidx), &data, sizeof(long));
} else
child->thread.fp_state.fpscr = data; child->thread.fp_state.fpscr = data;
#endif #endif
......
...@@ -444,4 +444,7 @@ void __init pt_regs_check(void) ...@@ -444,4 +444,7 @@ void __init pt_regs_check(void)
* real registers. * real registers.
*/ */
BUILD_BUG_ON(PT_DSCR < sizeof(struct user_pt_regs) / sizeof(unsigned long)); BUILD_BUG_ON(PT_DSCR < sizeof(struct user_pt_regs) / sizeof(unsigned long));
// ptrace_get/put_fpr() rely on PPC32 and VSX being incompatible
BUILD_BUG_ON(IS_ENABLED(CONFIG_PPC32) && IS_ENABLED(CONFIG_VSX));
} }
...@@ -993,8 +993,8 @@ int rtas_call_reentrant(int token, int nargs, int nret, int *outputs, ...) ...@@ -993,8 +993,8 @@ int rtas_call_reentrant(int token, int nargs, int nret, int *outputs, ...)
* *
* Return: A pointer to the specified errorlog or NULL if not found. * Return: A pointer to the specified errorlog or NULL if not found.
*/ */
struct pseries_errorlog *get_pseries_errorlog(struct rtas_error_log *log, noinstr struct pseries_errorlog *get_pseries_errorlog(struct rtas_error_log *log,
uint16_t section_id) uint16_t section_id)
{ {
struct rtas_ext_event_log_v6 *ext_log = struct rtas_ext_event_log_v6 *ext_log =
(struct rtas_ext_event_log_v6 *)log->buffer; (struct rtas_ext_event_log_v6 *)log->buffer;
......
...@@ -224,7 +224,7 @@ void crash_kexec_secondary(struct pt_regs *regs) ...@@ -224,7 +224,7 @@ void crash_kexec_secondary(struct pt_regs *regs)
/* wait for all the CPUs to hit real mode but timeout if they don't come in */ /* wait for all the CPUs to hit real mode but timeout if they don't come in */
#if defined(CONFIG_SMP) && defined(CONFIG_PPC64) #if defined(CONFIG_SMP) && defined(CONFIG_PPC64)
static void __maybe_unused crash_kexec_wait_realmode(int cpu) noinstr static void __maybe_unused crash_kexec_wait_realmode(int cpu)
{ {
unsigned int msecs; unsigned int msecs;
int i; int i;
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include <asm/cacheflush.h> #include <asm/cacheflush.h>
#include <asm/kdump.h> #include <asm/kdump.h>
#include <mm/mmu_decl.h> #include <mm/mmu_decl.h>
#include <generated/compile.h>
#include <generated/utsrelease.h> #include <generated/utsrelease.h>
struct regions { struct regions {
...@@ -37,10 +36,6 @@ struct regions { ...@@ -37,10 +36,6 @@ struct regions {
int reserved_mem_size_cells; int reserved_mem_size_cells;
}; };
/* Simplified build-specific string for starting entropy. */
static const char build_str[] = UTS_RELEASE " (" LINUX_COMPILE_BY "@"
LINUX_COMPILE_HOST ") (" LINUX_COMPILER ") " UTS_VERSION;
struct regions __initdata regions; struct regions __initdata regions;
static __init void kaslr_get_cmdline(void *fdt) static __init void kaslr_get_cmdline(void *fdt)
...@@ -71,7 +66,8 @@ static unsigned long __init get_boot_seed(void *fdt) ...@@ -71,7 +66,8 @@ static unsigned long __init get_boot_seed(void *fdt)
{ {
unsigned long hash = 0; unsigned long hash = 0;
hash = rotate_xor(hash, build_str, sizeof(build_str)); /* build-specific string for starting entropy. */
hash = rotate_xor(hash, linux_banner, strlen(linux_banner));
hash = rotate_xor(hash, fdt, fdt_totalsize(fdt)); hash = rotate_xor(hash, fdt, fdt_totalsize(fdt));
return hash; return hash;
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
# in particular, idle code runs a bunch of things in real mode # in particular, idle code runs a bunch of things in real mode
KASAN_SANITIZE_idle.o := n KASAN_SANITIZE_idle.o := n
KASAN_SANITIZE_pci-ioda.o := n KASAN_SANITIZE_pci-ioda.o := n
KASAN_SANITIZE_pci-ioda-tce.o := n
# pnv_machine_check_early # pnv_machine_check_early
KASAN_SANITIZE_setup.o := n KASAN_SANITIZE_setup.o := n
......
...@@ -465,6 +465,9 @@ static int papr_scm_pmu_check_events(struct papr_scm_priv *p, struct nvdimm_pmu ...@@ -465,6 +465,9 @@ static int papr_scm_pmu_check_events(struct papr_scm_priv *p, struct nvdimm_pmu
u32 available_events; u32 available_events;
int index, rc = 0; int index, rc = 0;
if (!p->stat_buffer_len)
return -ENOENT;
available_events = (p->stat_buffer_len - sizeof(struct papr_scm_perf_stats)) available_events = (p->stat_buffer_len - sizeof(struct papr_scm_perf_stats))
/ sizeof(struct papr_scm_perf_stat); / sizeof(struct papr_scm_perf_stat);
if (available_events == 0) if (available_events == 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment