powerpc fixes for 5.19 #2
- 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, Wanming Hu. -----BEGIN PGP SIGNATURE----- iQJHBAABCAAxFiEEJFGtCPCthwEv2Y/bUevqPMjhpYAFAmKiBo8THG1wZUBlbGxl cm1hbi5pZC5hdQAKCRBR6+o8yOGlgKnND/9wmr3nlA9gaXYCFyfnH5m8u/x7gNFs yW150WbcF/9FkhGwGED1kozyCrKqNt9UmBdyEqDjdtHE3ydW3dRnNaBG1wqLzlJd BpRUfe8VW5hR7aWkX7Vqzx7bnZACb2bxXv1upYDSeWDF0Bk7szdW2y2ucvRhx8Vv 8hxDsqIo+AsJV9oP6WSkIMFst0GDVBhbnd70zgu/4j9AYgWlfyJoFRw3vwUMWzS9 sW6niAZd9PsFboJkBj0LYxPQ6nHXUFEQp5OIn/ZPHmzHW4rnuYao8qgfzWSfxvA1 LcKLLtvobR9t0jK7SEh7efyOoIY3iprPNtP00jXdvtKMI8gv9bxCNyZBKap1TgQN TDexS6ShwcoHTMV6HyR4zA6OqFCn/stsuUNIrywPUvsEBgUPjRLiA2Nzk8wbEGG2 DXIBqYaNHIr34bRxjQ7K6JzovCGF/VOoRiJqwaAEujz4R164fuw7td/yuflLjL0Q JtT9DHXdzskzi+JWxHhsK3sLSHY5BInxt5GNNVsbecgpeizGFjwpGsxhWFOZNrBG P8zy7FZ7EzZe1a3qYdFROwZY3kkR4Rtp207ZdgAoWjTrt62ACwyx5HheaxGx+0R1 LL8LbHPxoWXJyQomMR1zVIzNhivcPqlH+yGkVaZJJY971HxjaCxIbbrH7rNpOf+w 2l5lxjzq5WrCNQ== =Odes -----END PGP SIGNATURE----- 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
This commit is contained in:
commit
95fc76c81b
|
@ -223,7 +223,6 @@ config PPC
|
|||
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_IOREMAP_PROT
|
||||
select HAVE_IRQ_EXIT_ON_IRQ_STACK
|
||||
select HAVE_IRQ_TIME_ACCOUNTING
|
||||
select HAVE_KERNEL_GZIP
|
||||
select HAVE_KERNEL_LZMA if DEFAULT_UIMAGE
|
||||
|
@ -786,7 +785,6 @@ config THREAD_SHIFT
|
|||
range 13 15
|
||||
default "15" if PPC_256K_PAGES
|
||||
default "14" if PPC64
|
||||
default "14" if KASAN
|
||||
default "13"
|
||||
help
|
||||
Used to define the stack size. The default is almost always what you
|
||||
|
|
|
@ -14,10 +14,16 @@
|
|||
|
||||
#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
|
||||
#else
|
||||
#define THREAD_SHIFT CONFIG_THREAD_SHIFT
|
||||
#define THREAD_SHIFT MIN_THREAD_SHIFT
|
||||
#endif
|
||||
|
||||
#define THREAD_SIZE (1 << THREAD_SHIFT)
|
||||
|
|
|
@ -37,6 +37,8 @@ KASAN_SANITIZE_paca.o := n
|
|||
KASAN_SANITIZE_setup_64.o := n
|
||||
KASAN_SANITIZE_mce.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
|
||||
# runs with translations off, as we cannot access the shadow with
|
||||
|
|
|
@ -2158,12 +2158,12 @@ static unsigned long ___get_wchan(struct task_struct *p)
|
|||
return 0;
|
||||
|
||||
do {
|
||||
sp = *(unsigned long *)sp;
|
||||
sp = READ_ONCE_NOCHECK(*(unsigned long *)sp);
|
||||
if (!validate_sp(sp, p, STACK_FRAME_OVERHEAD) ||
|
||||
task_is_running(p))
|
||||
return 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))
|
||||
return ip;
|
||||
}
|
||||
|
|
|
@ -17,9 +17,13 @@ int ptrace_get_fpr(struct task_struct *child, int index, unsigned long *data)
|
|||
|
||||
#ifdef CONFIG_PPC_FPU_REGS
|
||||
flush_fp_to_thread(child);
|
||||
if (fpidx < (PT_FPSCR - PT_FPR0))
|
||||
memcpy(data, &child->thread.TS_FPR(fpidx), sizeof(long));
|
||||
else
|
||||
if (fpidx < (PT_FPSCR - PT_FPR0)) {
|
||||
if (IS_ENABLED(CONFIG_PPC32))
|
||||
// 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;
|
||||
#else
|
||||
*data = 0;
|
||||
|
@ -39,9 +43,13 @@ int ptrace_put_fpr(struct task_struct *child, int index, unsigned long data)
|
|||
|
||||
#ifdef CONFIG_PPC_FPU_REGS
|
||||
flush_fp_to_thread(child);
|
||||
if (fpidx < (PT_FPSCR - PT_FPR0))
|
||||
memcpy(&child->thread.TS_FPR(fpidx), &data, sizeof(long));
|
||||
else
|
||||
if (fpidx < (PT_FPSCR - PT_FPR0)) {
|
||||
if (IS_ENABLED(CONFIG_PPC32))
|
||||
// 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;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -444,4 +444,7 @@ void __init pt_regs_check(void)
|
|||
* real registers.
|
||||
*/
|
||||
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, ...)
|
|||
*
|
||||
* Return: A pointer to the specified errorlog or NULL if not found.
|
||||
*/
|
||||
struct pseries_errorlog *get_pseries_errorlog(struct rtas_error_log *log,
|
||||
uint16_t section_id)
|
||||
noinstr struct pseries_errorlog *get_pseries_errorlog(struct rtas_error_log *log,
|
||||
uint16_t section_id)
|
||||
{
|
||||
struct rtas_ext_event_log_v6 *ext_log =
|
||||
(struct rtas_ext_event_log_v6 *)log->buffer;
|
||||
|
|
|
@ -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 */
|
||||
#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;
|
||||
int i;
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include <asm/cacheflush.h>
|
||||
#include <asm/kdump.h>
|
||||
#include <mm/mmu_decl.h>
|
||||
#include <generated/compile.h>
|
||||
#include <generated/utsrelease.h>
|
||||
|
||||
struct regions {
|
||||
|
@ -37,10 +36,6 @@ struct regions {
|
|||
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;
|
||||
|
||||
static __init void kaslr_get_cmdline(void *fdt)
|
||||
|
@ -71,7 +66,8 @@ static unsigned long __init get_boot_seed(void *fdt)
|
|||
{
|
||||
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));
|
||||
|
||||
return hash;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
# in particular, idle code runs a bunch of things in real mode
|
||||
KASAN_SANITIZE_idle.o := n
|
||||
KASAN_SANITIZE_pci-ioda.o := n
|
||||
KASAN_SANITIZE_pci-ioda-tce.o := n
|
||||
# pnv_machine_check_early
|
||||
KASAN_SANITIZE_setup.o := n
|
||||
|
||||
|
|
|
@ -465,6 +465,9 @@ static int papr_scm_pmu_check_events(struct papr_scm_priv *p, struct nvdimm_pmu
|
|||
u32 available_events;
|
||||
int index, rc = 0;
|
||||
|
||||
if (!p->stat_buffer_len)
|
||||
return -ENOENT;
|
||||
|
||||
available_events = (p->stat_buffer_len - sizeof(struct papr_scm_perf_stats))
|
||||
/ sizeof(struct papr_scm_perf_stat);
|
||||
if (available_events == 0)
|
||||
|
|
Loading…
Reference in New Issue