]> git.ipfire.org Git - people/ms/linux.git/commitdiff
Merge tag 'powerpc-5.19-2' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc...
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 9 Jun 2022 19:17:43 +0000 (12:17 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 9 Jun 2022 19:17:43 +0000 (12:17 -0700)
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

arch/powerpc/Kconfig
arch/powerpc/include/asm/thread_info.h
arch/powerpc/kernel/Makefile
arch/powerpc/kernel/process.c
arch/powerpc/kernel/ptrace/ptrace-fpu.c
arch/powerpc/kernel/ptrace/ptrace.c
arch/powerpc/kernel/rtas.c
arch/powerpc/kexec/crash.c
arch/powerpc/mm/nohash/kaslr_booke.c
arch/powerpc/platforms/powernv/Makefile
arch/powerpc/platforms/pseries/papr_scm.c

index be68c1f02b794b169da802fb7be41395e07df655..c2ce2e60c8f0f65f0c3ca1ad80142946b2a9d0ec 100644 (file)
@@ -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
index 125328d1b98027e12c36c0ebd3f3dab17892cbc2..af58f1ed3952e09b067dc2ff3b87c021db95f434 100644 (file)
 
 #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)
index 2e2a2a9bcf43f09ef4d9025c1f308d93c6c7ffe6..f91f0f29a566acf4cc3430eb84a9ead48287937c 100644 (file)
@@ -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
index b62046bf3bb88035615f5829c35d531c9579dc37..ee043380962142e85dbc8634824b623e20da5444 100644 (file)
@@ -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;
                }
index 5dca19361316e497d676d113ea74684b37cbda37..09c49632bfe592088a78e251685ed206b5f0d9e7 100644 (file)
@@ -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
 
index 4d2dc22d4a2d54637fb1c042da1b1b5326432bcd..5d7a72b41ae7115848592b2225570583e87bd62d 100644 (file)
@@ -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));
 }
index 9bb43aa53d43ec331299a2d378751b694bed609d..a6fce3106e02b73d595fee1747740b3385f1007d 100644 (file)
@@ -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;
index d85fa9fc6f3ca4a7f12681974961308ace4a78a8..80f54723cf6d1ffa04543fb4f7d7c7a24fb82ca0 100644 (file)
@@ -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;
index 1f3f9fedf1bc2223a0a56a6de8bb24365051e0c5..0d04f9d5da8d2dd194cdb6be7f7d00805b9a29ee 100644 (file)
@@ -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;
index 6488b38421999efd62dff4be1f30294cfb368559..19f0fc5c6f1b4176f208d47801366d067ba74a1c 100644 (file)
@@ -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
 
index 181b855b30509c8bf549bd246c70f4a428b6fc82..82cae08976bcdef531ceda72c7fe007767929b7d 100644 (file)
@@ -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)