1. 20 Aug, 2021 2 commits
  2. 18 Aug, 2021 3 commits
    • Michael Ellerman's avatar
      powerpc/mm: Fix set_memory_*() against concurrent accesses · 9f7853d7
      Michael Ellerman authored
      Laurent reported that STRICT_MODULE_RWX was causing intermittent crashes
      on one of his systems:
      
        kernel tried to execute exec-protected page (c008000004073278) - exploit attempt? (uid: 0)
        BUG: Unable to handle kernel instruction fetch
        Faulting instruction address: 0xc008000004073278
        Oops: Kernel access of bad area, sig: 11 [#1]
        LE PAGE_SIZE=64K MMU=Radix SMP NR_CPUS=2048 NUMA pSeries
        Modules linked in: drm virtio_console fuse drm_panel_orientation_quirks ...
        CPU: 3 PID: 44 Comm: kworker/3:1 Not tainted 5.14.0-rc4+ #12
        Workqueue: events control_work_handler [virtio_console]
        NIP:  c008000004073278 LR: c008000004073278 CTR: c0000000001e9de0
        REGS: c00000002e4ef7e0 TRAP: 0400   Not tainted  (5.14.0-rc4+)
        MSR:  800000004280b033 <SF,VEC,VSX,EE,FP,ME,IR,DR,RI,LE>  CR: 24002822 XER: 200400cf
        ...
        NIP fill_queue+0xf0/0x210 [virtio_console]
        LR  fill_queue+0xf0/0x210 [virtio_console]
        Call Trace:
          fill_queue+0xb4/0x210 [virtio_console] (unreliable)
          add_port+0x1a8/0x470 [virtio_console]
          control_work_handler+0xbc/0x1e8 [virtio_console]
          process_one_work+0x290/0x590
          worker_thread+0x88/0x620
          kthread+0x194/0x1a0
          ret_from_kernel_thread+0x5c/0x64
      
      Jordan, Fabiano & Murilo were able to reproduce and identify that the
      problem is caused by the call to module_enable_ro() in do_init_module(),
      which happens after the module's init function has already been called.
      
      Our current implementation of change_page_attr() is not safe against
      concurrent accesses, because it invalidates the PTE before flushing the
      TLB and then installing the new PTE. That leaves a window in time where
      there is no valid PTE for the page, if another CPU tries to access the
      page at that time we see something like the fault above.
      
      We can't simply switch to set_pte_at()/flush TLB, because our hash MMU
      code doesn't handle a set_pte_at() of a valid PTE. See [1].
      
      But we do have pte_update(), which replaces the old PTE with the new,
      meaning there's no window where the PTE is invalid. And the hash MMU
      version hash__pte_update() deals with synchronising the hash page table
      correctly.
      
      [1]: https://lore.kernel.org/linuxppc-dev/87y318wp9r.fsf@linux.ibm.com/
      
      Fixes: 1f9ad21c ("powerpc/mm: Implement set_memory() routines")
      Reported-by: default avatarLaurent Vivier <lvivier@redhat.com>
      Reviewed-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      Reviewed-by: default avatarMurilo Opsfelder Araújo <muriloo@linux.ibm.com>
      Tested-by: default avatarLaurent Vivier <lvivier@redhat.com>
      Signed-off-by: default avatarFabiano Rosas <farosas@linux.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20210818120518.3603172-1-mpe@ellerman.id.au
      9f7853d7
    • Christophe Leroy's avatar
      powerpc/32s: Fix random crashes by adding isync() after locking/unlocking KUEP · ef486bf4
      Christophe Leroy authored
      Commit b5efec00 ("powerpc/32s: Move KUEP locking/unlocking in C")
      removed the 'isync' instruction after adding/removing NX bit in user
      segments. The reasoning behind this change was that when setting the
      NX bit we don't mind it taking effect with delay as the kernel never
      executes text from userspace, and when clearing the NX bit this is
      to return to userspace and then the 'rfi' should synchronise the
      context.
      
      However, it looks like on book3s/32 having a hash page table, at least
      on the G3 processor, we get an unexpected fault from userspace, then
      this is followed by something wrong in the verification of MSR_PR
      at end of another interrupt.
      
      This is fixed by adding back the removed isync() following update
      of NX bit in user segment registers. Only do it for cores with an
      hash table, as 603 cores don't exhibit that problem and the two isync
      increase ./null_syscall selftest by 6 cycles on an MPC 832x.
      
      First problem: unexpected WARN_ON() for mysterious PROTFAULT
      
        WARNING: CPU: 0 PID: 1660 at arch/powerpc/mm/fault.c:354 do_page_fault+0x6c/0x5b0
        Modules linked in:
        CPU: 0 PID: 1660 Comm: Xorg Not tainted 5.13.0-pmac-00028-gb3c15b60339a #40
        NIP:  c001b5c8 LR: c001b6f8 CTR: 00000000
        REGS: e2d09e40 TRAP: 0700   Not tainted  (5.13.0-pmac-00028-gb3c15b60339a)
        MSR:  00021032 <ME,IR,DR,RI>  CR: 42d04f30  XER: 20000000
        GPR00: c000424c e2d09f00 c301b680 e2d09f40 0000001e 42000000 00cba028 00000000
        GPR08: 08000000 48000010 c301b680 e2d09f30 22d09f30 00c1fff0 00cba000 a7b7ba4c
        GPR16: 00000031 00000000 00000000 00000000 00000000 00000000 a7b7b0d0 00c5c010
        GPR24: a7b7b64c a7b7d2f0 00000004 00000000 c1efa6c0 00cba02c 00000300 e2d09f40
        NIP [c001b5c8] do_page_fault+0x6c/0x5b0
        LR [c001b6f8] do_page_fault+0x19c/0x5b0
        Call Trace:
        [e2d09f00] [e2d09f04] 0xe2d09f04 (unreliable)
        [e2d09f30] [c000424c] DataAccess_virt+0xd4/0xe4
        --- interrupt: 300 at 0xa7a261dc
        NIP:  a7a261dc LR: a7a253bc CTR: 00000000
        REGS: e2d09f40 TRAP: 0300   Not tainted  (5.13.0-pmac-00028-gb3c15b60339a)
        MSR:  0000d032 <EE,PR,ME,IR,DR,RI>  CR: 228428e2  XER: 20000000
        DAR: 00cba02c DSISR: 42000000
        GPR00: a7a27448 afa6b0e0 a74c35c0 a7b7b614 0000001e a7b7b614 00cba028 00000000
        GPR08: 00020fd9 00000031 00cb9ff8 a7a273b0 220028e2 00c1fff0 00cba000 a7b7ba4c
        GPR16: 00000031 00000000 00000000 00000000 00000000 00000000 a7b7b0d0 00c5c010
        GPR24: a7b7b64c a7b7d2f0 00000004 00000002 0000001e a7b7b614 a7b7aff4 00000030
        NIP [a7a261dc] 0xa7a261dc
        LR [a7a253bc] 0xa7a253bc
        --- interrupt: 300
        Instruction dump:
        7c4a1378 810300a0 75278410 83820298 83a300a4 553b018c 551e0036 4082038c
        2e1b0000 40920228 75280800 41820220 <0fe00000> 3b600000 41920214 81420594
      
      Second problem: MSR PR is seen unset allthough the interrupt frame shows it set
      
        kernel BUG at arch/powerpc/kernel/interrupt.c:458!
        Oops: Exception in kernel mode, sig: 5 [#1]
        BE PAGE_SIZE=4K MMU=Hash SMP NR_CPUS=2 PowerMac
        Modules linked in:
        CPU: 0 PID: 1660 Comm: Xorg Tainted: G        W         5.13.0-pmac-00028-gb3c15b60339a #40
        NIP:  c0011434 LR: c001629c CTR: 00000000
        REGS: e2d09e70 TRAP: 0700   Tainted: G        W          (5.13.0-pmac-00028-gb3c15b60339a)
        MSR:  00029032 <EE,ME,IR,DR,RI>  CR: 42d09f30  XER: 00000000
        GPR00: 00000000 e2d09f30 c301b680 e2d09f40 83440000 c44d0e68 e2d09e8c 00000000
        GPR08: 00000002 00dc228a 00004000 e2d09f30 22d09f30 00c1fff0 afa6ceb4 00c26144
        GPR16: 00c25fb8 00c26140 afa6ceb8 90000000 00c944d8 0000001c 00000000 00200000
        GPR24: 00000000 000001fb afa6d1b4 00000001 00000000 a539a2a0 a530fd80 00000089
        NIP [c0011434] interrupt_exit_kernel_prepare+0x10/0x70
        LR [c001629c] interrupt_return+0x9c/0x144
        Call Trace:
        [e2d09f30] [c000424c] DataAccess_virt+0xd4/0xe4 (unreliable)
        --- interrupt: 300 at 0xa09be008
        NIP:  a09be008 LR: a09bdfe8 CTR: a09bdfc0
        REGS: e2d09f40 TRAP: 0300   Tainted: G        W          (5.13.0-pmac-00028-gb3c15b60339a)
        MSR:  0000d032 <EE,PR,ME,IR,DR,RI>  CR: 420028e2  XER: 20000000
        DAR: a539a308 DSISR: 0a000000
        GPR00: a7b90d50 afa6b2d0 a74c35c0 a0a8b690 a0a8b698 a5365d70 a4fa82a8 00000004
        GPR08: 00000000 a09bdfc0 00000000 a5360000 a09bde7c 00c1fff0 afa6ceb4 00c26144
        GPR16: 00c25fb8 00c26140 afa6ceb8 90000000 00c944d8 0000001c 00000000 00200000
        GPR24: 00000000 000001fb afa6d1b4 00000001 00000000 a539a2a0 a530fd80 00000089
        NIP [a09be008] 0xa09be008
        LR [a09bdfe8] 0xa09bdfe8
        --- interrupt: 300
        Instruction dump:
        80010024 83e1001c 7c0803a6 4bffff80 3bc00800 4bffffd0 486b42fd 4bffffcc
        81430084 71480002 41820038 554a0462 <0f0a0000> 80620060 74630001 40820034
      
      Fixes: b5efec00 ("powerpc/32s: Move KUEP locking/unlocking in C")
      Cc: stable@vger.kernel.org # v5.13+
      Reported-by: default avatarStan Johnson <userm57@yahoo.com>
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/4856f5574906e2aec0522be17bf3848a22b2cd0b.1629269345.git.christophe.leroy@csgroup.eu
      ef486bf4
    • Nathan Chancellor's avatar
      powerpc/xive: Do not mark xive_request_ipi() as __init · 3f78c90f
      Nathan Chancellor authored
      Compiling ppc64le_defconfig with clang-14 shows a modpost warning:
      
      WARNING: modpost: vmlinux.o(.text+0xa74e0): Section mismatch in
      reference from the function xive_setup_cpu_ipi() to the function
      .init.text:xive_request_ipi()
      The function xive_setup_cpu_ipi() references
      the function __init xive_request_ipi().
      This is often because xive_setup_cpu_ipi lacks a __init
      annotation or the annotation of xive_request_ipi is wrong.
      
      xive_request_ipi() is called from xive_setup_cpu_ipi(), which is not
      __init, so xive_request_ipi() should not be marked __init. Remove the
      attribute so there is no more warning.
      
      Fixes: cbc06f05 ("powerpc/xive: Do not skip CPU-less nodes when creating the IPIs")
      Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20210816185711.21563-1-nathan@kernel.org
      3f78c90f
  3. 12 Aug, 2021 3 commits
    • Cédric Le Goater's avatar
      powerpc/xive: Do not skip CPU-less nodes when creating the IPIs · cbc06f05
      Cédric Le Goater authored
      On PowerVM, CPU-less nodes can be populated with hot-plugged CPUs at
      runtime. Today, the IPI is not created for such nodes, and hot-plugged
      CPUs use a bogus IPI, which leads to soft lockups.
      
      We can not directly allocate and request the IPI on demand because
      bringup_up() is called under the IRQ sparse lock. The alternative is
      to allocate the IPIs for all possible nodes at startup and to request
      the mapping on demand when the first CPU of a node is brought up.
      
      Fixes: 7dcc37b3 ("powerpc/xive: Map one IPI interrupt per node")
      Cc: stable@vger.kernel.org # v5.13
      Reported-by: default avatarGeetika Moolchandani <Geetika.Moolchandani1@ibm.com>
      Signed-off-by: default avatarCédric Le Goater <clg@kaod.org>
      Tested-by: default avatarSrikar Dronamraju <srikar@linux.vnet.ibm.com>
      Tested-by: default avatarLaurent Vivier <lvivier@redhat.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20210807072057.184698-1-clg@kaod.org
      cbc06f05
    • Christophe Leroy's avatar
      powerpc/interrupt: Do not call single_step_exception() from other exceptions · 01fcac8e
      Christophe Leroy authored
      single_step_exception() is called by emulate_single_step() which
      is called from (at least) alignment exception() handler and
      program_check_exception() handler.
      
      Redefine it as a regular __single_step_exception() which is called
      by both single_step_exception() handler and emulate_single_step()
      function.
      
      Fixes: 3a96570f ("powerpc: convert interrupt handlers to use wrappers")
      Cc: stable@vger.kernel.org # v5.12+
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      Reviewed-by: default avatarNicholas Piggin <npiggin@gmail.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/aed174f5cbc06f2cf95233c071d8aac948e46043.1628611921.git.christophe.leroy@csgroup.eu
      01fcac8e
    • Christophe Leroy's avatar
      powerpc/interrupt: Fix OOPS by not calling do_IRQ() from timer_interrupt() · 98694166
      Christophe Leroy authored
      An interrupt handler shall not be called from another interrupt
      handler otherwise this leads to problems like the following:
      
        Kernel attempted to write user page (afd4fa84) - exploit attempt? (uid: 1000)
        ------------[ cut here ]------------
        Bug: Write fault blocked by KUAP!
        WARNING: CPU: 0 PID: 1617 at arch/powerpc/mm/fault.c:230 do_page_fault+0x484/0x720
        Modules linked in:
        CPU: 0 PID: 1617 Comm: sshd Tainted: G        W         5.13.0-pmac-00010-g8393422eb77 #7
        NIP:  c001b77c LR: c001b77c CTR: 00000000
        REGS: cb9e5bc0 TRAP: 0700   Tainted: G        W          (5.13.0-pmac-00010-g8393422eb77)
        MSR:  00021032 <ME,IR,DR,RI>  CR: 24942424  XER: 00000000
      
        GPR00: c001b77c cb9e5c80 c1582c00 00000021 3ffffbff 085b0000 00000027 c8eb644c
        GPR08: 00000023 00000000 00000000 00000000 24942424 0063f8c8 00000000 000186a0
        GPR16: afd52dd4 afd52dd0 afd52dcc afd52dc8 0065a990 c07640c4 cb9e5e98 cb9e5e90
        GPR24: 00000040 afd4fa96 00000040 02000000 c1fda6c0 afd4fa84 00000300 cb9e5cc0
        NIP [c001b77c] do_page_fault+0x484/0x720
        LR [c001b77c] do_page_fault+0x484/0x720
        Call Trace:
        [cb9e5c80] [c001b77c] do_page_fault+0x484/0x720 (unreliable)
        [cb9e5cb0] [c000424c] DataAccess_virt+0xd4/0xe4
        --- interrupt: 300 at __copy_tofrom_user+0x110/0x20c
        NIP:  c001f9b4 LR: c03250a0 CTR: 00000004
        REGS: cb9e5cc0 TRAP: 0300   Tainted: G        W          (5.13.0-pmac-00010-g8393422eb77)
        MSR:  00009032 <EE,ME,IR,DR,RI>  CR: 48028468  XER: 20000000
        DAR: afd4fa84 DSISR: 0a000000
        GPR00: 20726f6f cb9e5d80 c1582c00 00000004 cb9e5e3a 00000016 afd4fa80 00000000
        GPR08: 3835202d 72777872 2d78722d 00000004 28028464 0063f8c8 00000000 000186a0
        GPR16: afd52dd4 afd52dd0 afd52dcc afd52dc8 0065a990 c07640c4 cb9e5e98 cb9e5e90
        GPR24: 00000040 afd4fa96 00000040 cb9e5e0c 00000daa a0000000 cb9e5e98 afd4fa56
        NIP [c001f9b4] __copy_tofrom_user+0x110/0x20c
        LR [c03250a0] _copy_to_iter+0x144/0x990
        --- interrupt: 300
        [cb9e5d80] [c03e89c0] n_tty_read+0xa4/0x598 (unreliable)
        [cb9e5df0] [c03e2a0c] tty_read+0xdc/0x2b4
        [cb9e5e80] [c0156bf8] vfs_read+0x274/0x340
        [cb9e5f00] [c01571ac] ksys_read+0x70/0x118
        [cb9e5f30] [c0016048] ret_from_syscall+0x0/0x28
        --- interrupt: c00 at 0xa7855c88
        NIP:  a7855c88 LR: a7855c5c CTR: 00000000
        REGS: cb9e5f40 TRAP: 0c00   Tainted: G        W          (5.13.0-pmac-00010-g8393422eb77)
        MSR:  0000d032 <EE,PR,ME,IR,DR,RI>  CR: 2402446c  XER: 00000000
      
        GPR00: 00000003 afd4ec70 a72137d0 0000000b afd4ecac 00004000 0065a990 00000800
        GPR08: 00000000 a7947930 00000000 00000004 c15831b0 0063f8c8 00000000 000186a0
        GPR16: afd52dd4 afd52dd0 afd52dcc afd52dc8 0065a990 0065a9e0 00000001 0065fac0
        GPR24: 00000000 00000089 00664050 00000000 00668e30 a720c8dc a7943ff4 0065f9b0
        NIP [a7855c88] 0xa7855c88
        LR [a7855c5c] 0xa7855c5c
        --- interrupt: c00
        Instruction dump:
        3884aa88 38630178 48076861 807f0080 48042e45 2f830000 419e0148 3c80c079
        3c60c076 38841be4 386301c0 4801f705 <0fe00000> 3860000b 4bfffe30 3c80c06b
        ---[ end trace fd69b91a8046c2e5 ]---
      
      Here the problem is that by re-enterring an exception handler,
      kuap_save_and_lock() is called a second time with this time KUAP
      access locked, leading to regs->kuap being overwritten hence
      KUAP not being unlocked at exception exit as expected.
      
      Do not call do_IRQ() from timer_interrupt() directly. Instead,
      redefine do_IRQ() as a standard function named __do_IRQ(), and
      call it from both do_IRQ() and time_interrupt() handlers.
      
      Fixes: 3a96570f ("powerpc: convert interrupt handlers to use wrappers")
      Cc: stable@vger.kernel.org # v5.12+
      Reported-by: default avatarStan Johnson <userm57@yahoo.com>
      Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      Reviewed-by: default avatarNicholas Piggin <npiggin@gmail.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/c17d234f4927d39a1d7100864a8e1145323d33a0.1628611927.git.christophe.leroy@csgroup.eu
      98694166
  4. 09 Aug, 2021 1 commit
    • Pu Lehui's avatar
      powerpc/kprobes: Fix kprobe Oops happens in booke · 43e8f760
      Pu Lehui authored
      When using kprobe on powerpc booke series processor, Oops happens
      as show bellow:
      
      / # echo "p:myprobe do_nanosleep" > /sys/kernel/debug/tracing/kprobe_events
      / # echo 1 > /sys/kernel/debug/tracing/events/kprobes/myprobe/enable
      / # sleep 1
      [   50.076730] Oops: Exception in kernel mode, sig: 5 [#1]
      [   50.077017] BE PAGE_SIZE=4K SMP NR_CPUS=24 QEMU e500
      [   50.077221] Modules linked in:
      [   50.077462] CPU: 0 PID: 77 Comm: sleep Not tainted 5.14.0-rc4-00022-g251a1524 #21
      [   50.077887] NIP:  c0b9c4e0 LR: c00ebecc CTR: 00000000
      [   50.078067] REGS: c3883de0 TRAP: 0700   Not tainted (5.14.0-rc4-00022-g251a1524)
      [   50.078349] MSR:  00029000 <CE,EE,ME>  CR: 24000228  XER: 20000000
      [   50.078675]
      [   50.078675] GPR00: c00ebdf0 c3883e90 c313e300 c3883ea0 00000001 00000000 c3883ecc 00000001
      [   50.078675] GPR08: c100598c c00ea250 00000004 00000000 24000222 102490c2 bff4180c 101e60d4
      [   50.078675] GPR16: 00000000 102454ac 00000040 10240000 10241100 102410f8 10240000 00500000
      [   50.078675] GPR24: 00000002 00000000 c3883ea0 00000001 00000000 0000c350 3b9b8d50 00000000
      [   50.080151] NIP [c0b9c4e0] do_nanosleep+0x0/0x190
      [   50.080352] LR [c00ebecc] hrtimer_nanosleep+0x14c/0x1e0
      [   50.080638] Call Trace:
      [   50.080801] [c3883e90] [c00ebdf0] hrtimer_nanosleep+0x70/0x1e0 (unreliable)
      [   50.081110] [c3883f00] [c00ec004] sys_nanosleep_time32+0xa4/0x110
      [   50.081336] [c3883f40] [c001509c] ret_from_syscall+0x0/0x28
      [   50.081541] --- interrupt: c00 at 0x100a4d08
      [   50.081749] NIP:  100a4d08 LR: 101b5234 CTR: 00000003
      [   50.081931] REGS: c3883f50 TRAP: 0c00   Not tainted (5.14.0-rc4-00022-g251a1524)
      [   50.082183] MSR:  0002f902 <CE,EE,PR,FP,ME>  CR: 24000222  XER: 00000000
      [   50.082457]
      [   50.082457] GPR00: 000000a2 bf980040 1024b4d0 bf980084 bf980084 64000000 00555345 fefefeff
      [   50.082457] GPR08: 7f7f7f7f 101e0000 00000069 00000003 28000422 102490c2 bff4180c 101e60d4
      [   50.082457] GPR16: 00000000 102454ac 00000040 10240000 10241100 102410f8 10240000 00500000
      [   50.082457] GPR24: 00000002 bf9803f4 10240000 00000000 00000000 100039e0 00000000 102444e8
      [   50.083789] NIP [100a4d08] 0x100a4d08
      [   50.083917] LR [101b5234] 0x101b5234
      [   50.084042] --- interrupt: c00
      [   50.084238] Instruction dump:
      [   50.084483] 4bfffc40 60000000 60000000 60000000 9421fff0 39400402 914200c0 38210010
      [   50.084841] 4bfffc20 00000000 00000000 00000000 <7fe00008> 7c0802a6 7c892378 93c10048
      [   50.085487] ---[ end trace f6fffe98e2fa8f3e ]---
      [   50.085678]
      Trace/breakpoint trap
      
      There is no real mode for booke arch and the MMU translation is
      always on. The corresponding MSR_IS/MSR_DS bit in booke is used
      to switch the address space, but not for real mode judgment.
      
      Fixes: 21f8b2fa ("powerpc/kprobes: Ignore traps that happened in real mode")
      Signed-off-by: default avatarPu Lehui <pulehui@huawei.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20210809023658.218915-1-pulehui@huawei.com
      43e8f760
  5. 06 Aug, 2021 4 commits
  6. 29 Jul, 2021 2 commits
    • Michael Ellerman's avatar
      powerpc/vdso: Don't use r30 to avoid breaking Go lang · a88603f4
      Michael Ellerman authored
      The Go runtime uses r30 for some special value called 'g'. It assumes
      that value will remain unchanged even when calling VDSO functions.
      Although r30 is non-volatile across function calls, the callee is free
      to use it, as long as the callee saves the value and restores it before
      returning.
      
      It used to be true by accident that the VDSO didn't use r30, because the
      VDSO was hand-written asm. When we switched to building the VDSO from C
      the compiler started using r30, at least in some builds, leading to
      crashes in Go. eg:
      
        ~/go/src$ ./all.bash
        Building Go cmd/dist using /usr/lib/go-1.16. (go1.16.2 linux/ppc64le)
        Building Go toolchain1 using /usr/lib/go-1.16.
        go build os/exec: /usr/lib/go-1.16/pkg/tool/linux_ppc64le/compile: signal: segmentation fault
        go build reflect: /usr/lib/go-1.16/pkg/tool/linux_ppc64le/compile: signal: segmentation fault
        go tool dist: FAILED: /usr/lib/go-1.16/bin/go install -gcflags=-l -tags=math_big_pure_go compiler_bootstrap bootstrap/cmd/...: exit status 1
      
      There are patches in flight to fix Go[1], but until they are released
      and widely deployed we can workaround it in the VDSO by avoiding use of
      r30.
      
      Note this only works with GCC, clang does not support -ffixed-rN.
      
      1: https://go-review.googlesource.com/c/go/+/328110
      
      Fixes: ab037dd8 ("powerpc/vdso: Switch VDSO to generic C implementation.")
      Cc: stable@vger.kernel.org # v5.11+
      Reported-by: default avatarPaul Menzel <pmenzel@molgen.mpg.de>
      Tested-by: default avatarPaul Menzel <pmenzel@molgen.mpg.de>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20210729131244.2595519-1-mpe@ellerman.id.au
      a88603f4
    • Srikar Dronamraju's avatar
      powerpc/pseries: Fix regression while building external modules · 333cf507
      Srikar Dronamraju authored
      With commit c9f34013 ("powerpc: Always enable queued spinlocks for
      64s, disable for others") CONFIG_PPC_QUEUED_SPINLOCKS is always
      enabled on ppc64le, external modules that use spinlock APIs are
      failing.
      
        ERROR: modpost: GPL-incompatible module XXX.ko uses GPL-only symbol 'shared_processor'
      
      Before the above commit, modules were able to build without any
      issues. Also this problem is not seen on other architectures. This
      problem can be workaround if CONFIG_UNINLINE_SPIN_UNLOCK is enabled in
      the config. However CONFIG_UNINLINE_SPIN_UNLOCK is not enabled by
      default and only enabled in certain conditions like
      CONFIG_DEBUG_SPINLOCKS is set in the kernel config.
      
        #include <linux/module.h>
        spinlock_t spLock;
      
        static int __init spinlock_test_init(void)
        {
                spin_lock_init(&spLock);
                spin_lock(&spLock);
                spin_unlock(&spLock);
                return 0;
        }
      
        static void __exit spinlock_test_exit(void)
        {
        	printk("spinlock_test unloaded\n");
        }
        module_init(spinlock_test_init);
        module_exit(spinlock_test_exit);
      
        MODULE_DESCRIPTION ("spinlock_test");
        MODULE_LICENSE ("non-GPL");
        MODULE_AUTHOR ("Srikar Dronamraju");
      
      Given that spin locks are one of the basic facilities for module code,
      this effectively makes it impossible to build/load almost any non GPL
      modules on ppc64le.
      
      This was first reported at https://github.com/openzfs/zfs/issues/11172
      
      Currently shared_processor is exported as GPL only symbol.
      Fix this for parity with other architectures by exposing
      shared_processor to non-GPL modules too.
      
      Fixes: 14c73bd3 ("powerpc/vcpu: Assume dedicated processors as non-preempt")
      Cc: stable@vger.kernel.org # v5.5+
      Reported-by: marc.c.dionne@gmail.com
      Signed-off-by: default avatarSrikar Dronamraju <srikar@linux.vnet.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20210729060449.292780-1-srikar@linux.vnet.ibm.com
      333cf507
  7. 26 Jul, 2021 1 commit
  8. 23 Jul, 2021 2 commits
    • Nicholas Piggin's avatar
      KVM: PPC: Book3S HV Nested: Sanitise H_ENTER_NESTED TM state · d9c57d3e
      Nicholas Piggin authored
      The H_ENTER_NESTED hypercall is handled by the L0, and it is a request
      by the L1 to switch the context of the vCPU over to that of its L2
      guest, and return with an interrupt indication. The L1 is responsible
      for switching some registers to guest context, and the L0 switches
      others (including all the hypervisor privileged state).
      
      If the L2 MSR has TM active, then the L1 is responsible for
      recheckpointing the L2 TM state. Then the L1 exits to L0 via the
      H_ENTER_NESTED hcall, and the L0 saves the TM state as part of the exit,
      and then it recheckpoints the TM state as part of the nested entry and
      finally HRFIDs into the L2 with TM active MSR. Not efficient, but about
      the simplest approach for something that's horrendously complicated.
      
      Problems arise if the L1 exits to the L0 with a TM state which does not
      match the L2 TM state being requested. For example if the L1 is
      transactional but the L2 MSR is non-transactional, or vice versa. The
      L0's HRFID can take a TM Bad Thing interrupt and crash.
      
      Fix this by disallowing H_ENTER_NESTED in TM[T] state entirely, and then
      ensuring that if the L1 is suspended then the L2 must have TM active,
      and if the L1 is not suspended then the L2 must not have TM active.
      
      Fixes: 360cae31 ("KVM: PPC: Book3S HV: Nested guest entry via hypercall")
      Cc: stable@vger.kernel.org # v4.20+
      Reported-by: default avatarAlexey Kardashevskiy <aik@ozlabs.ru>
      Acked-by: default avatarMichael Neuling <mikey@neuling.org>
      Signed-off-by: default avatarNicholas Piggin <npiggin@gmail.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      d9c57d3e
    • Nicholas Piggin's avatar
      KVM: PPC: Book3S: Fix H_RTAS rets buffer overflow · f62f3c20
      Nicholas Piggin authored
      The kvmppc_rtas_hcall() sets the host rtas_args.rets pointer based on
      the rtas_args.nargs that was provided by the guest. That guest nargs
      value is not range checked, so the guest can cause the host rets pointer
      to be pointed outside the args array. The individual rtas function
      handlers check the nargs and nrets values to ensure they are correct,
      but if they are not, the handlers store a -3 (0xfffffffd) failure
      indication in rets[0] which corrupts host memory.
      
      Fix this by testing up front whether the guest supplied nargs and nret
      would exceed the array size, and fail the hcall directly without storing
      a failure indication to rets[0].
      
      Also expand on a comment about why we kill the guest and try not to
      return errors directly if we have a valid rets[0] pointer.
      
      Fixes: 8e591cb7 ("KVM: PPC: Book3S: Add infrastructure to implement kernel-side RTAS calls")
      Cc: stable@vger.kernel.org # v3.10+
      Reported-by: default avatarAlexey Kardashevskiy <aik@ozlabs.ru>
      Signed-off-by: default avatarNicholas Piggin <npiggin@gmail.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      f62f3c20
  9. 18 Jul, 2021 13 commits
    • Linus Torvalds's avatar
      Linux 5.14-rc2 · 2734d6c1
      Linus Torvalds authored
      2734d6c1
    • Linus Torvalds's avatar
      Merge tag 'perf-tools-fixes-for-v5.14-2021-07-18' of... · 8c25c447
      Linus Torvalds authored
      Merge tag 'perf-tools-fixes-for-v5.14-2021-07-18' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux
      
      Pull perf tools fixes from Arnaldo Carvalho de Melo:
      
       - Skip invalid hybrid PMU on hybrid systems when the atom (little) CPUs
         are offlined.
      
       - Fix 'perf test' problems related to the recently added hybrid
         (BIG/little) code.
      
       - Split ARM's coresight (hw tracing) decode by aux records to avoid
         fatal decoding errors.
      
       - Fix add event failure in 'perf probe' when running 32-bit perf in a
         64-bit kernel.
      
       - Fix 'perf sched record' failure when CONFIG_SCHEDSTATS is not set.
      
       - Fix memory and refcount leaks detected by ASAn when running 'perf
         test', should be clean of warnings now.
      
       - Remove broken definition of __LITTLE_ENDIAN from tools'
         linux/kconfig.h, which was breaking the build in some systems.
      
       - Cast PTHREAD_STACK_MIN to int as it may turn into 'long
         sysconf(__SC_THREAD_STACK_MIN_VALUE), breaking the build in some
         systems.
      
       - Fix libperf build error with LIBPFM4=1.
      
       - Sync UAPI files changed by the memfd_secret new syscall.
      
      * tag 'perf-tools-fixes-for-v5.14-2021-07-18' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux: (35 commits)
        perf sched: Fix record failure when CONFIG_SCHEDSTATS is not set
        perf probe: Fix add event failure when running 32-bit perf in a 64-bit kernel
        perf data: Close all files in close_dir()
        perf probe-file: Delete namelist in del_events() on the error path
        perf test bpf: Free obj_buf
        perf trace: Free strings in trace__parse_events_option()
        perf trace: Free syscall tp fields in evsel->priv
        perf trace: Free syscall->arg_fmt
        perf trace: Free malloc'd trace fields on exit
        perf lzma: Close lzma stream on exit
        perf script: Fix memory 'threads' and 'cpus' leaks on exit
        perf script: Release zstd data
        perf session: Cleanup trace_event
        perf inject: Close inject.output on exit
        perf report: Free generated help strings for sort option
        perf env: Fix memory leak of cpu_pmu_caps
        perf test maps__merge_in: Fix memory leak of maps
        perf dso: Fix memory leak in dso__new_map()
        perf test event_update: Fix memory leak of unit
        perf test event_update: Fix memory leak of evlist
        ...
      8c25c447
    • Linus Torvalds's avatar
      Merge tag 'xfs-5.14-fixes-1' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux · f0eb870a
      Linus Torvalds authored
      Pull xfs fixes from Darrick Wong:
       "A few fixes for issues in the new online shrink code, additional
        corrections for my recent bug-hunt w.r.t. extent size hints on
        realtime, and improved input checking of the GROWFSRT ioctl.
      
        IOW, the usual 'I somehow got bored during the merge window and
        resumed auditing the farther reaches of xfs':
      
         - Fix shrink eligibility checking when sparse inode clusters enabled
      
         - Reset '..' directory entries when unlinking directories to prevent
           verifier errors if fs is shrinked later
      
         - Don't report unusable extent size hints to FSGETXATTR
      
         - Don't warn when extent size hints are unusable because the sysadmin
           configured them that way
      
         - Fix insufficient parameter validation in GROWFSRT ioctl
      
         - Fix integer overflow when adding rt volumes to filesystem"
      
      * tag 'xfs-5.14-fixes-1' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux:
        xfs: detect misaligned rtinherit directory extent size hints
        xfs: fix an integer overflow error in xfs_growfs_rt
        xfs: improve FSGROWFSRT precondition checking
        xfs: don't expose misaligned extszinherit hints to userspace
        xfs: correct the narrative around misaligned rtinherit/extszinherit dirs
        xfs: reset child dir '..' entry when unlinking child
        xfs: check for sparse inode clusters that cross new EOAG when shrinking
      f0eb870a
    • Linus Torvalds's avatar
      Merge tag 'iomap-5.14-fixes-1' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux · fbf1bddc
      Linus Torvalds authored
      Pull iomap fixes from Darrick Wong:
       "A handful of bugfixes for the iomap code.
      
        There's nothing especially exciting here, just fixes for UBSAN (not
        KASAN as I erroneously wrote in the tag message) warnings about
        undefined behavior in the SEEK_DATA/SEEK_HOLE code, and some
        reshuffling of per-page block state info to fix some problems with
        gfs2.
      
         - Fix KASAN warnings due to integer overflow in SEEK_DATA/SEEK_HOLE
      
         - Fix assertion errors when using inlinedata files on gfs2"
      
      * tag 'iomap-5.14-fixes-1' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux:
        iomap: Don't create iomap_page objects in iomap_page_mkwrite_actor
        iomap: Don't create iomap_page objects for inline files
        iomap: Permit pages without an iop to enter writeback
        iomap: remove the length variable in iomap_seek_hole
        iomap: remove the length variable in iomap_seek_data
      fbf1bddc
    • Linus Torvalds's avatar
      Merge tag 'kbuild-fixes-v5.14' of... · 6750691a
      Linus Torvalds authored
      Merge tag 'kbuild-fixes-v5.14' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
      
      Pull Kbuild fixes from Masahiro Yamada:
      
       - Restore the original behavior of scripts/setlocalversion when
         LOCALVERSION is set to empty.
      
       - Show Kconfig prompts even for 'make -s'
      
       - Fix the combination of COFNIG_LTO_CLANG=y and CONFIG_MODVERSIONS=y
         for older GNU Make versions
      
      * tag 'kbuild-fixes-v5.14' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
        Documentation: Fix intiramfs script name
        Kbuild: lto: fix module versionings mismatch in GNU make 3.X
        kbuild: do not suppress Kconfig prompts for silent build
        scripts/setlocalversion: fix a bug when LOCALVERSION is empty
      6750691a
    • Robert Richter's avatar
      Documentation: Fix intiramfs script name · 5e60f363
      Robert Richter authored
      Documentation was not changed when renaming the script in commit
      80e715a0 ("initramfs: rename gen_initramfs_list.sh to
      gen_initramfs.sh"). Fixing this.
      
      Basically does:
      
       $ sed -i -e s/gen_initramfs_list.sh/gen_initramfs.sh/g $(git grep -l gen_initramfs_list.sh)
      
      Fixes: 80e715a0 ("initramfs: rename gen_initramfs_list.sh to gen_initramfs.sh")
      Signed-off-by: default avatarRobert Richter <rrichter@amd.com>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      5e60f363
    • Lecopzer Chen's avatar
      Kbuild: lto: fix module versionings mismatch in GNU make 3.X · 1d11053d
      Lecopzer Chen authored
      When building modules(CONFIG_...=m), I found some of module versions
      are incorrect and set to 0.
      This can be found in build log for first clean build which shows
      
      WARNING: EXPORT symbol "XXXX" [drivers/XXX/XXX.ko] version generation failed,
      symbol will not be versioned.
      
      But in second build(incremental build), the WARNING disappeared and the
      module version becomes valid CRC and make someone who want to change
      modules without updating kernel image can't insert their modules.
      
      The problematic code is
      +	$(foreach n, $(filter-out FORCE,$^),				\
      +		$(if $(wildcard $(n).symversions),			\
      +			; cat $(n).symversions >> $@.symversions))
      
      For example:
        rm -f fs/notify/built-in.a.symversions    ; rm -f fs/notify/built-in.a; \
      llvm-ar cDPrST fs/notify/built-in.a fs/notify/fsnotify.o \
      fs/notify/notification.o fs/notify/group.o ...
      
      `foreach n` shows nothing to `cat` into $(n).symversions because
      `if $(wildcard $(n).symversions)` return nothing, but actually
      they do exist during this line was executed.
      
      -rw-r--r-- 1 root root 168580 Jun 13 19:10 fs/notify/fsnotify.o
      -rw-r--r-- 1 root root    111 Jun 13 19:10 fs/notify/fsnotify.o.symversions
      
      The reason is the $(n).symversions are generated at runtime, but
      Makefile wildcard function expends and checks the file exist or not
      during parsing the Makefile.
      
      Thus fix this by use `test` shell command to check the file
      existence in runtime.
      
      Rebase from both:
      1. [https://lore.kernel.org/lkml/20210616080252.32046-1-lecopzer.chen@mediatek.com/]
      2. [https://lore.kernel.org/lkml/20210702032943.7865-1-lecopzer.chen@mediatek.com/]
      
      Fixes: 38e89184 ("kbuild: lto: fix module versioning")
      Co-developed-by: default avatarSami Tolvanen <samitolvanen@google.com>
      Signed-off-by: default avatarLecopzer Chen <lecopzer.chen@mediatek.com>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      1d11053d
    • Masahiro Yamada's avatar
      kbuild: do not suppress Kconfig prompts for silent build · d952cfaf
      Masahiro Yamada authored
      When a new CONFIG option is available, Kbuild shows a prompt to get
      the user input.
      
        $ make
        [ snip ]
        Core Scheduling for SMT (SCHED_CORE) [N/y/?] (NEW)
      
      This is the only interactive place in the build process.
      
      Commit 174a1dcc ("kbuild: sink stdout from cmd for silent build")
      suppressed Kconfig prompts as well because syncconfig is invoked by
      the 'cmd' macro. You cannot notice the fact that Kconfig is waiting
      for the user input.
      
      Use 'kecho' to show the equivalent short log without suppressing stdout
      from sub-make.
      
      Fixes: 174a1dcc ("kbuild: sink stdout from cmd for silent build")
      Reported-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Tested-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      d952cfaf
    • Mikulas Patocka's avatar
      scripts/setlocalversion: fix a bug when LOCALVERSION is empty · 5df99bec
      Mikulas Patocka authored
      The commit 042da426 ("scripts/setlocalversion: simplify the short
      version part") reduces indentation. Unfortunately, it also changes behavior
      in a subtle way - if the user has empty "LOCALVERSION" variable, the plus
      sign is appended to the kernel version. It wasn't appended before.
      
      This patch reverts to the old behavior - we append the plus sign only if
      the LOCALVERSION variable is not set.
      
      Fixes: 042da426 ("scripts/setlocalversion: simplify the short version part")
      Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      5df99bec
    • Yang Jihong's avatar
      perf sched: Fix record failure when CONFIG_SCHEDSTATS is not set · b0f00855
      Yang Jihong authored
      The tracepoints trace_sched_stat_{wait, sleep, iowait} are not exposed to user
      if CONFIG_SCHEDSTATS is not set, "perf sched record" records the three events.
      As a result, the command fails.
      
      Before:
      
        #perf sched record sleep 1
        event syntax error: 'sched:sched_stat_wait'
                             \___ unknown tracepoint
      
        Error:  File /sys/kernel/tracing/events/sched/sched_stat_wait not found.
        Hint:   Perhaps this kernel misses some CONFIG_ setting to enable this feature?.
      
        Run 'perf list' for a list of valid events
      
         Usage: perf record [<options>] [<command>]
            or: perf record [<options>] -- <command> [<options>]
      
            -e, --event <event>   event selector. use 'perf list' to list available events
      
      Solution:
        Check whether schedstat tracepoints are exposed. If no, these events are not recorded.
      
      After:
        # perf sched record sleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.163 MB perf.data (1091 samples) ]
        # perf sched report
        run measurement overhead: 4736 nsecs
        sleep measurement overhead: 9059979 nsecs
        the run test took 999854 nsecs
        the sleep test took 8945271 nsecs
        nr_run_events:        716
        nr_sleep_events:      785
        nr_wakeup_events:     0
        ...
        ------------------------------------------------------------
      
      Fixes: 2a09b5de ("sched/fair: do not expose some tracepoints to user if CONFIG_SCHEDSTATS is not set")
      Signed-off-by: default avatarYang Jihong <yangjihong1@huawei.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Yafang Shao <laoar.shao@gmail.com>
      Link: http://lore.kernel.org/lkml/20210713112358.194693-1-yangjihong1@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b0f00855
    • Yang Jihong's avatar
      perf probe: Fix add event failure when running 32-bit perf in a 64-bit kernel · 22a66551
      Yang Jihong authored
      The "address" member of "struct probe_trace_point" uses long data type.
      If kernel is 64-bit and perf program is 32-bit, size of "address"
      variable is 32 bits.
      
      As a result, upper 32 bits of address read from kernel are truncated, an
      error occurs during address comparison in kprobe_warn_out_range().
      
      Before:
      
        # perf probe -a schedule
        schedule is out of .text, skip it.
          Error: Failed to add events.
      
      Solution:
        Change data type of "address" variable to u64 and change corresponding
      address printing and value assignment.
      
      After:
      
        # perf.new.new probe -a schedule
        Added new event:
          probe:schedule       (on schedule)
      
        You can now use it in all perf tools, such as:
      
                perf record -e probe:schedule -aR sleep 1
      
        # perf probe -l
          probe:schedule       (on schedule@kernel/sched/core.c)
        # perf record -e probe:schedule -aR sleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.156 MB perf.data (1366 samples) ]
        # perf report --stdio
        # To display the perf.data header info, please use --header/--header-only options.
        #
        #
        # Total Lost Samples: 0
        #
        # Samples: 1K of event 'probe:schedule'
        # Event count (approx.): 1366
        #
        # Overhead  Command          Shared Object      Symbol
        # ........  ...............  .................  ............
        #
             6.22%  migration/0      [kernel.kallsyms]  [k] schedule
             6.22%  migration/1      [kernel.kallsyms]  [k] schedule
             6.22%  migration/2      [kernel.kallsyms]  [k] schedule
             6.22%  migration/3      [kernel.kallsyms]  [k] schedule
             6.15%  migration/10     [kernel.kallsyms]  [k] schedule
             6.15%  migration/11     [kernel.kallsyms]  [k] schedule
             6.15%  migration/12     [kernel.kallsyms]  [k] schedule
             6.15%  migration/13     [kernel.kallsyms]  [k] schedule
             6.15%  migration/14     [kernel.kallsyms]  [k] schedule
             6.15%  migration/15     [kernel.kallsyms]  [k] schedule
             6.15%  migration/4      [kernel.kallsyms]  [k] schedule
             6.15%  migration/5      [kernel.kallsyms]  [k] schedule
             6.15%  migration/6      [kernel.kallsyms]  [k] schedule
             6.15%  migration/7      [kernel.kallsyms]  [k] schedule
             6.15%  migration/8      [kernel.kallsyms]  [k] schedule
             6.15%  migration/9      [kernel.kallsyms]  [k] schedule
             0.22%  rcu_sched        [kernel.kallsyms]  [k] schedule
        ...
        #
        # (Cannot load tips.txt file, please install perf!)
        #
      Signed-off-by: default avatarYang Jihong <yangjihong1@huawei.com>
      Acked-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Frank Ch. Eigler <fche@redhat.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jianlin Lv <jianlin.lv@arm.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Li Huafei <lihuafei1@huawei.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
      Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
      Link: http://lore.kernel.org/lkml/20210715063723.11926-1-yangjihong1@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      22a66551
    • Riccardo Mancini's avatar
      perf data: Close all files in close_dir() · d4b3eedc
      Riccardo Mancini authored
      When using 'perf report' in directory mode, the first file is not closed
      on exit, causing a memory leak.
      
      The problem is caused by the iterating variable never reaching 0.
      
      Fixes: 14552063 ("perf data: Add perf_data__(create_dir|close_dir) functions")
      Signed-off-by: default avatarRiccardo Mancini <rickyman7@gmail.com>
      Acked-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Zhen Lei <thunder.leizhen@huawei.com>
      Link: http://lore.kernel.org/lkml/20210716141122.858082-1-rickyman7@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d4b3eedc
    • Riccardo Mancini's avatar
      perf probe-file: Delete namelist in del_events() on the error path · e0fa7ab4
      Riccardo Mancini authored
      ASan reports some memory leaks when running:
      
        # perf test "42: BPF filter"
      
      This second leak is caused by a strlist not being dellocated on error
      inside probe_file__del_events.
      
      This patch adds a goto label before the deallocation and makes the error
      path jump to it.
      Signed-off-by: default avatarRiccardo Mancini <rickyman7@gmail.com>
      Fixes: e7895e42 ("perf probe: Split del_perf_probe_events()")
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/174963c587ae77fa108af794669998e4ae558338.1626343282.git.rickyman7@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e0fa7ab4
  10. 17 Jul, 2021 9 commits