Skip to content
  1. Sep 05, 2022
    • Letu Ren's avatar
      fbdev: fb_pm2fb: Avoid potential divide by zero error · cb4bb011
      Letu Ren authored
      commit 19f953e7
      
       upstream.
      
      In `do_fb_ioctl()` of fbmem.c, if cmd is FBIOPUT_VSCREENINFO, var will be
      copied from user, then go through `fb_set_var()` and
      `info->fbops->fb_check_var()` which could may be `pm2fb_check_var()`.
      Along the path, `var->pixclock` won't be modified. This function checks
      whether reciprocal of `var->pixclock` is too high. If `var->pixclock` is
      zero, there will be a divide by zero error. So, it is necessary to check
      whether denominator is zero to avoid crash. As this bug is found by
      Syzkaller, logs are listed below.
      
      divide error in pm2fb_check_var
      Call Trace:
       <TASK>
       fb_set_var+0x367/0xeb0 drivers/video/fbdev/core/fbmem.c:1015
       do_fb_ioctl+0x234/0x670 drivers/video/fbdev/core/fbmem.c:1110
       fb_ioctl+0xdd/0x130 drivers/video/fbdev/core/fbmem.c:1189
      
      Reported-by: default avatarZheyu Ma <zheyuma97@gmail.com>
      Signed-off-by: default avatarLetu Ren <fantasquex@gmail.com>
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cb4bb011
    • Hawkins Jiawei's avatar
      net: fix refcount bug in sk_psock_get (2) · 86026be8
      Hawkins Jiawei authored
      commit 2a013372 upstream.
      
      Syzkaller reports refcount bug as follows:
      ------------[ cut here ]------------
      refcount_t: saturated; leaking memory.
      WARNING: CPU: 1 PID: 3605 at lib/refcount.c:19 refcount_warn_saturate+0xf4/0x1e0 lib/refcount.c:19
      Modules linked in:
      CPU: 1 PID: 3605 Comm: syz-executor208 Not tainted 5.18.0-syzkaller-03023-g7e062cda7d90 #0
       <TASK>
       __refcount_add_not_zero include/linux/refcount.h:163 [inline]
       __refcount_inc_not_zero include/linux/refcount.h:227 [inline]
       refcount_inc_not_zero include/linux/refcount.h:245 [inline]
       sk_psock_get+0x3bc/0x410 include/linux/skmsg.h:439
       tls_data_ready+0x6d/0x1b0 net/tls/tls_sw.c:2091
       tcp_data_ready+0x106/0x520 net/ipv4/tcp_input.c:4983
       tcp_data_queue+0x25f2/0x4c90 net/ipv4/tcp_input.c:5057
       tcp_rcv_state_process+0x1774/0x4e80 net/ipv4/tcp_input.c:6659
       tcp_v4_do_rcv+0x339/0x980 net/ipv4/tcp_ipv4.c:1682
       sk_backlog_rcv include/net/sock.h:1061 [inline]
       __release_sock+0x134/0x3b0 net/core/sock.c:2849
       release_sock+0x54/0x1b0 net/core/sock.c:3404
       inet_shutdown+0x1e0/0x430 net/ipv4/af_inet.c:909
       __sys_shutdown_sock net/socket.c:2331 [inline]
       __sys_shutdown_sock net/socket.c:2325 [inline]
       __sys_shutdown+0xf1/0x1b0 net/socket.c:2343
       __do_sys_shutdown net/socket.c:2351 [inline]
       __se_sys_shutdown net/socket.c:2349 [inline]
       __x64_sys_shutdown+0x50/0x70 net/socket.c:2349
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x46/0xb0
       </TASK>
      
      During SMC fallback process in connect syscall, kernel will
      replaces TCP with SMC. In order to forward wakeup
      smc socket waitqueue after fallback, kernel will sets
      clcsk->sk_user_data to origin smc socket in
      smc_fback_replace_callbacks().
      
      Later, in shutdown syscall, kernel will calls
      sk_psock_get(), which treats the clcsk->sk_user_data
      as psock type, triggering the refcnt warning.
      
      So, the root cause is that smc and psock, both will use
      sk_user_data field. So they will mismatch this field
      easily.
      
      This patch solves it by using another bit(defined as
      SK_USER_DATA_PSOCK) in PTRMASK, to mark whether
      sk_user_data points to a psock object or not.
      This patch depends on a PTRMASK introduced in commit f1ff5ce2
      
      
      ("net, sk_msg: Clear sk_user_data pointer on clone if tagged").
      
      For there will possibly be more flags in the sk_user_data field,
      this patch also refactor sk_user_data flags code to be more generic
      to improve its maintainability.
      
      Reported-and-tested-by: default avatar <syzbot+5f26f85569bd179c18ce@syzkaller.appspotmail.com>
      Suggested-by: default avatarJakub Kicinski <kuba@kernel.org>
      Acked-by: default avatarWen Gu <guwen@linux.alibaba.com>
      Signed-off-by: default avatarHawkins Jiawei <yin31149@gmail.com>
      Reviewed-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      86026be8
    • Karthik Alapati's avatar
      HID: hidraw: fix memory leak in hidraw_release() · 52a3c62a
      Karthik Alapati authored
      commit a5623a20
      
       upstream.
      
      Free the buffered reports before deleting the list entry.
      
      BUG: memory leak
      unreferenced object 0xffff88810e72f180 (size 32):
        comm "softirq", pid 0, jiffies 4294945143 (age 16.080s)
        hex dump (first 32 bytes):
          64 f3 c6 6a d1 88 07 04 00 00 00 00 00 00 00 00  d..j............
          00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
        backtrace:
          [<ffffffff814ac6c3>] kmemdup+0x23/0x50 mm/util.c:128
          [<ffffffff8357c1d2>] kmemdup include/linux/fortify-string.h:440 [inline]
          [<ffffffff8357c1d2>] hidraw_report_event+0xa2/0x150 drivers/hid/hidraw.c:521
          [<ffffffff8356ddad>] hid_report_raw_event+0x27d/0x740 drivers/hid/hid-core.c:1992
          [<ffffffff8356e41e>] hid_input_report+0x1ae/0x270 drivers/hid/hid-core.c:2065
          [<ffffffff835f0d3f>] hid_irq_in+0x1ff/0x250 drivers/hid/usbhid/hid-core.c:284
          [<ffffffff82d3c7f9>] __usb_hcd_giveback_urb+0xf9/0x230 drivers/usb/core/hcd.c:1670
          [<ffffffff82d3cc26>] usb_hcd_giveback_urb+0x1b6/0x1d0 drivers/usb/core/hcd.c:1747
          [<ffffffff82ef1e14>] dummy_timer+0x8e4/0x14c0 drivers/usb/gadget/udc/dummy_hcd.c:1988
          [<ffffffff812f50a8>] call_timer_fn+0x38/0x200 kernel/time/timer.c:1474
          [<ffffffff812f5586>] expire_timers kernel/time/timer.c:1519 [inline]
          [<ffffffff812f5586>] __run_timers.part.0+0x316/0x430 kernel/time/timer.c:1790
          [<ffffffff812f56e4>] __run_timers kernel/time/timer.c:1768 [inline]
          [<ffffffff812f56e4>] run_timer_softirq+0x44/0x90 kernel/time/timer.c:1803
          [<ffffffff848000e6>] __do_softirq+0xe6/0x2ea kernel/softirq.c:571
          [<ffffffff81246db0>] invoke_softirq kernel/softirq.c:445 [inline]
          [<ffffffff81246db0>] __irq_exit_rcu kernel/softirq.c:650 [inline]
          [<ffffffff81246db0>] irq_exit_rcu+0xc0/0x110 kernel/softirq.c:662
          [<ffffffff84574f02>] sysvec_apic_timer_interrupt+0xa2/0xd0 arch/x86/kernel/apic/apic.c:1106
          [<ffffffff84600c8b>] asm_sysvec_apic_timer_interrupt+0x1b/0x20 arch/x86/include/asm/idtentry.h:649
          [<ffffffff8458a070>] native_safe_halt arch/x86/include/asm/irqflags.h:51 [inline]
          [<ffffffff8458a070>] arch_safe_halt arch/x86/include/asm/irqflags.h:89 [inline]
          [<ffffffff8458a070>] acpi_safe_halt drivers/acpi/processor_idle.c:111 [inline]
          [<ffffffff8458a070>] acpi_idle_do_entry+0xc0/0xd0 drivers/acpi/processor_idle.c:554
      
      Link: https://syzkaller.appspot.com/bug?id=19a04b43c75ed1092021010419b5e560a8172c4f
      Reported-by: default avatar <syzbot+f59100a0428e6ded9443@syzkaller.appspotmail.com>
      Signed-off-by: default avatarKarthik Alapati <mail@karthek.com>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      52a3c62a
    • Alan Stern's avatar
      USB: gadget: Fix use-after-free Read in usb_udc_uevent() · f44b0b95
      Alan Stern authored
      commit 2191c008 upstream.
      
      The syzbot fuzzer found a race between uevent callbacks and gadget
      driver unregistration that can cause a use-after-free bug:
      
      ---------------------------------------------------------------
      BUG: KASAN: use-after-free in usb_udc_uevent+0x11f/0x130
      drivers/usb/gadget/udc/core.c:1732
      Read of size 8 at addr ffff888078ce2050 by task udevd/2968
      
      CPU: 1 PID: 2968 Comm: udevd Not tainted 5.19.0-rc4-next-20220628-syzkaller #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google
      06/29/2022
      Call Trace:
       <TASK>
       __dump_stack lib/dump_stack.c:88 [inline]
       dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
       print_address_description mm/kasan/report.c:317 [inline]
       print_report.cold+0x2ba/0x719 mm/kasan/report.c:433
       kasan_report+0xbe/0x1f0 mm/kasan/report.c:495
       usb_udc_uevent+0x11f/0x130 drivers/usb/gadget/udc/core.c:1732
       dev_uevent+0x290/0x770 drivers/base/core.c:2424
      ---------------------------------------------------------------
      
      The bug occurs because usb_udc_uevent() dereferences udc->driver but
      does so without acquiring the udc_lock mutex, which protects this
      field.  If the gadget driver is unbound from the udc concurrently with
      uevent processing, the driver structure may be accessed after it has
      been deallocated.
      
      To prevent the race, we make sure that the routine holds the mutex
      around the racing accesses.
      
      Link: <https://lore.kernel.org/all/0000000000004de90405a719c951@google.com>
      CC: stable@vger.kernel.org # fc274c1e
      
      
      Reported-and-tested-by: default avatar <syzbot+b0de012ceb1e2a97891b@syzkaller.appspotmail.com>
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Link: https://lore.kernel.org/r/YtlrnhHyrHsSky9m@rowland.harvard.edu
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f44b0b95
    • Dongliang Mu's avatar
      media: pvrusb2: fix memory leak in pvr_probe · c02d2a91
      Dongliang Mu authored
      commit 945a9a8e
      
       upstream.
      
      The error handling code in pvr2_hdw_create forgets to unregister the
      v4l2 device. When pvr2_hdw_create returns back to pvr2_context_create,
      it calls pvr2_context_destroy to destroy context, but mp->hdw is NULL,
      which leads to that pvr2_hdw_destroy directly returns.
      
      Fix this by adding v4l2_device_unregister to decrease the refcount of
      usb interface.
      
      Reported-by: default avatar <syzbot+77b432d57c4791183ed4@syzkaller.appspotmail.com>
      Signed-off-by: default avatarDongliang Mu <mudongliangabcd@gmail.com>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c02d2a91
    • Vivek Kasireddy's avatar
      udmabuf: Set the DMA mask for the udmabuf device (v2) · f2f6ea1a
      Vivek Kasireddy authored
      commit 9e9fa6a9
      
       upstream.
      
      If the DMA mask is not set explicitly, the following warning occurs
      when the userspace tries to access the dma-buf via the CPU as
      reported by syzbot here:
      
      WARNING: CPU: 1 PID: 3595 at kernel/dma/mapping.c:188
      __dma_map_sg_attrs+0x181/0x1f0 kernel/dma/mapping.c:188
      Modules linked in:
      CPU: 0 PID: 3595 Comm: syz-executor249 Not tainted
      5.17.0-rc2-syzkaller-00316-g0457e5153e0e #0
      Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
      Google 01/01/2011
      RIP: 0010:__dma_map_sg_attrs+0x181/0x1f0 kernel/dma/mapping.c:188
      Code: 00 00 00 00 00 fc ff df 48 c1 e8 03 80 3c 10 00 75 71 4c 8b 3d c0
      83 b5 0d e9 db fe ff ff e8 b6 0f 13 00 0f 0b e8 af 0f 13 00 <0f> 0b 45
         31 e4 e9 54 ff ff ff e8 a0 0f 13 00 49 8d 7f 50 48 b8 00
      RSP: 0018:ffffc90002a07d68 EFLAGS: 00010293
      RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
      RDX: ffff88807e25e2c0 RSI: ffffffff81649e91 RDI: ffff88801b848408
      RBP: ffff88801b848000 R08: 0000000000000002 R09: ffff88801d86c74f
      R10: ffffffff81649d72 R11: 0000000000000001 R12: 0000000000000002
      R13: ffff88801d86c680 R14: 0000000000000001 R15: 0000000000000000
      FS:  0000555556e30300(0000) GS:ffff8880b9d00000(0000)
      knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00000000200000cc CR3: 000000001d74a000 CR4: 00000000003506e0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      Call Trace:
       <TASK>
       dma_map_sgtable+0x70/0xf0 kernel/dma/mapping.c:264
       get_sg_table.isra.0+0xe0/0x160 drivers/dma-buf/udmabuf.c:72
       begin_cpu_udmabuf+0x130/0x1d0 drivers/dma-buf/udmabuf.c:126
       dma_buf_begin_cpu_access+0xfd/0x1d0 drivers/dma-buf/dma-buf.c:1164
       dma_buf_ioctl+0x259/0x2b0 drivers/dma-buf/dma-buf.c:363
       vfs_ioctl fs/ioctl.c:51 [inline]
       __do_sys_ioctl fs/ioctl.c:874 [inline]
       __se_sys_ioctl fs/ioctl.c:860 [inline]
       __x64_sys_ioctl+0x193/0x200 fs/ioctl.c:860
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x44/0xae
      RIP: 0033:0x7f62fcf530f9
      Code: 28 c3 e8 2a 14 00 00 66 2e 0f 1f 84 00 00 00 00 00 48 89 f8 48 89
      f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01
      f0 ff ff 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48
      RSP: 002b:00007ffe3edab9b8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
      RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f62fcf530f9
      RDX: 0000000020000200 RSI: 0000000040086200 RDI: 0000000000000006
      RBP: 00007f62fcf170e0 R08: 0000000000000000 R09: 0000000000000000
      R10: 0000000000000000 R11: 0000000000000246 R12: 00007f62fcf17170
      R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
       </TASK>
      
      v2: Dont't forget to deregister if DMA mask setup fails.
      
      Reported-by: default avatar <syzbot+10e27961f4da37c443b2@syzkaller.appspotmail.com>
      Cc: Gerd Hoffmann <kraxel@redhat.com>
      Signed-off-by: default avatarVivek Kasireddy <vivek.kasireddy@intel.com>
      Link: http://patchwork.freedesktop.org/patch/msgid/20220520205235.3687336-1-vivek.kasireddy@intel.com
      Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f2f6ea1a
    • Lee Jones's avatar
      HID: steam: Prevent NULL pointer dereference in steam_{recv,send}_report · dee1e51b
      Lee Jones authored
      commit cd11d1a6 upstream.
      
      It is possible for a malicious device to forgo submitting a Feature
      Report.  The HID Steam driver presently makes no prevision for this
      and de-references the 'struct hid_report' pointer obtained from the
      HID devices without first checking its validity.  Let's change that.
      
      Cc: Jiri Kosina <jikos@kernel.org>
      Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
      Cc: linux-input@vger.kernel.org
      Fixes: c164d6ab
      
       ("HID: add driver for Valve Steam Controller")
      Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
      Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dee1e51b
    • Greg Kroah-Hartman's avatar
      Revert "PCI/portdrv: Don't disable AER reporting in get_port_device_capability()" · adb9caab
      Greg Kroah-Hartman authored
      This reverts commit 65e393fd which is
      commit 8795e182
      
       upstream.
      
      It is reported to cause problems, so drop it from the stable trees for
      now until it gets sorted out.
      
      Link: https://lore.kernel.org/r/47b775c5-57fa-5edf-b59e-8a9041ffbee7@candelatech.com
      Reported-by: default avatarBen Greear <greearb@candelatech.com>
      Cc: Stefan Roese <sr@denx.de>
      Cc: Bjorn Helgaas <bhelgaas@google.com>
      Cc: Pali Rohár <pali@kernel.org>
      Cc: Rafael J. Wysocki <rjw@rjwysocki.net>
      Cc: Bharat Kumar Gogada <bharat.kumar.gogada@xilinx.com>
      Cc: Michal Simek <michal.simek@xilinx.com>
      Cc: Yao Hongbo <yaohongbo@linux.alibaba.com>
      Cc: Naveen Naidu <naveennaidu479@gmail.com>
      Cc: Sasha Levin <sashal@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      adb9caab
    • Luiz Augusto von Dentz's avatar
      Bluetooth: L2CAP: Fix build errors in some archs · e8fcbce5
      Luiz Augusto von Dentz authored
      commit b840304f upstream.
      
      This attempts to fix the follow errors:
      
      In function 'memcmp',
          inlined from 'bacmp' at ./include/net/bluetooth/bluetooth.h:347:9,
          inlined from 'l2cap_global_chan_by_psm' at
          net/bluetooth/l2cap_core.c:2003:15:
      ./include/linux/fortify-string.h:44:33: error: '__builtin_memcmp'
      specified bound 6 exceeds source size 0 [-Werror=stringop-overread]
         44 | #define __underlying_memcmp     __builtin_memcmp
            |                                 ^
      ./include/linux/fortify-string.h:420:16: note: in expansion of macro
      '__underlying_memcmp'
        420 |         return __underlying_memcmp(p, q, size);
            |                ^~~~~~~~~~~~~~~~~~~
      In function 'memcmp',
          inlined from 'bacmp' at ./include/net/bluetooth/bluetooth.h:347:9,
          inlined from 'l2cap_global_chan_by_psm' at
          net/bluetooth/l2cap_core.c:2004:15:
      ./include/linux/fortify-string.h:44:33: error: '__builtin_memcmp'
      specified bound 6 exceeds source size 0 [-Werror=stringop-overread]
         44 | #define __underlying_memcmp     __builtin_memcmp
            |                                 ^
      ./include/linux/fortify-string.h:420:16: note: in expansion of macro
      '__underlying_memcmp'
        420 |         return __underlying_memcmp(p, q, size);
            |                ^~~~~~~~~~~~~~~~~~~
      
      Fixes: 332f1795
      
       ("Bluetooth: L2CAP: Fix l2cap_global_chan_by_psm regression")
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e8fcbce5
    • James Morse's avatar
      arm64: errata: Add Cortex-A510 to the repeat tlbi list · d3916da4
      James Morse authored
      commit 39fdb65f
      
       upstream.
      
      Cortex-A510 is affected by an erratum where in rare circumstances the
      CPUs may not handle a race between a break-before-make sequence on one
      CPU, and another CPU accessing the same page. This could allow a store
      to a page that has been unmapped.
      
      Work around this by adding the affected CPUs to the list that needs
      TLB sequences to be done twice.
      
      Signed-off-by: default avatarJames Morse <james.morse@arm.com>
      Link: https://lore.kernel.org/r/20220704155732.21216-1-james.morse@arm.com
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      Cc: Lucas Wei <lucaswei@google.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d3916da4
    • Akira Yokosawa's avatar
      docs: kerneldoc-preamble: Test xeCJK.sty before loading · a8ba16e9
      Akira Yokosawa authored
      commit cee7db1b upstream.
      
      On distros whose texlive packaging is fine-grained, texlive-xecjk
      can be installed/removed independently of other texlive packages.
      Conditionally loading xeCJK depending only on the existence of the
      "Noto Sans CJK SC" font might end up in xelatex error of
      "xeCJK.sty not found!".
      
      Improve the situation by testing existence of xeCJK.sty before
      loading it.
      
      This is useful on RHEL 9 and its clone distros where texlive-xecjk
      doesn't work at the moment due to a missing dependency [1].
      "make pdfdocs" for non-CJK contents should work after removing
      texlive-xecjk.
      
      Link: [1] https://bugzilla.redhat.com/show_bug.cgi?id=2086254
      Fixes: 398f7abd
      
       ("docs: pdfdocs: Pull LaTeX preamble part out of conf.py")
      Cc: stable@vger.kernel.org # v5.18+
      Signed-off-by: default avatarAkira Yokosawa <akiyks@gmail.com>
      Acked-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
      Link: https://lore.kernel.org/r/c24c2a87-70b2-5342-bcc9-de467940466e@gmail.com
      Signed-off-by: default avatarJonathan Corbet <corbet@lwn.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a8ba16e9
    • Eric Biggers's avatar
      crypto: lib - remove unneeded selection of XOR_BLOCKS · e120a635
      Eric Biggers authored
      commit 874b3019 upstream.
      
      CRYPTO_LIB_CHACHA_GENERIC doesn't need to select XOR_BLOCKS.  It perhaps
      was thought that it's needed for __crypto_xor, but that's not the case.
      
      Enabling XOR_BLOCKS is problematic because the XOR_BLOCKS code runs a
      benchmark when it is initialized.  That causes a boot time regression on
      systems that didn't have it enabled before.
      
      Therefore, remove this unnecessary and problematic selection.
      
      Fixes: e56e1898
      
       ("lib/crypto: add prompts back to crypto libraries")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e120a635
    • Timo Alho's avatar
      firmware: tegra: bpmp: Do only aligned access to IPC memory area · 515af71a
      Timo Alho authored
      commit a4740b14
      
       upstream.
      
      Use memcpy_toio and memcpy_fromio variants of memcpy to guarantee no
      unaligned access to IPC memory area. This is to allow the IPC memory to
      be mapped as Device memory to further suppress speculative reads from
      happening within the 64 kB memory area above the IPC memory when 64 kB
      memory pages are used.
      
      Signed-off-by: default avatarTimo Alho <talho@nvidia.com>
      Signed-off-by: default avatarMikko Perttunen <mperttunen@nvidia.com>
      Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
      Cc: Jon Hunter <jonathanh@nvidia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      515af71a
    • Maxime Ripard's avatar
      drm/vc4: hdmi: Depends on CONFIG_PM · 1cf82931
      Maxime Ripard authored
      commit 72e2329e
      
       upstream.
      
      We already depend on runtime PM to get the power domains and clocks for
      most of the devices supported by the vc4 driver, so let's just select it
      to make sure it's there.
      
      Link: https://lore.kernel.org/r/20220629123510.1915022-38-maxime@cerno.tech
      Acked-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
      Tested-by: default avatarStefan Wahren <stefan.wahren@i2se.com>
      Signed-off-by: default avatarMaxime Ripard <maxime@cerno.tech>
      (cherry picked from commit f1bc386b
      
      )
      Signed-off-by: default avatarMaxime Ripard <maxime@cerno.tech>
      Cc: "Sudip Mukherjee (Codethink)" <sudipm.mukherjee@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1cf82931
    • Maxime Ripard's avatar
      drm/vc4: hdmi: Rework power up · 1a289a16
      Maxime Ripard authored
      commit 258e483a
      
       upstream.
      
      The current code tries to handle the case where CONFIG_PM isn't selected
      by first calling our runtime_resume implementation and then properly
      report the power state to the runtime_pm core.
      
      This allows to have a functionning device even if pm_runtime_get_*
      functions are nops.
      
      However, the device power state if CONFIG_PM is enabled is
      RPM_SUSPENDED, and thus our vc4_hdmi_write() and vc4_hdmi_read() calls
      in the runtime_pm hooks will now report a warning since the device might
      not be properly powered.
      
      Even more so, we need CONFIG_PM enabled since the previous RaspberryPi
      have a power domain that needs to be powered up for the HDMI controller
      to be usable.
      
      The previous patch has created a dependency on CONFIG_PM, now we can
      just assume it's there and only call pm_runtime_resume_and_get() to make
      sure our device is powered in bind.
      
      Link: https://lore.kernel.org/r/20220629123510.1915022-39-maxime@cerno.tech
      Acked-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
      Tested-by: default avatarStefan Wahren <stefan.wahren@i2se.com>
      Signed-off-by: default avatarMaxime Ripard <maxime@cerno.tech>
      (cherry picked from commit 53565c28
      
      )
      Signed-off-by: default avatarMaxime Ripard <maxime@cerno.tech>
      Cc: "Sudip Mukherjee (Codethink)" <sudipm.mukherjee@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1a289a16
  2. Aug 31, 2022
    • Greg Kroah-Hartman's avatar
    • Daniel Borkmann's avatar
      bpf: Don't use tnum_range on array range checking for poke descriptors · a36df92c
      Daniel Borkmann authored
      commit a657182a upstream.
      
      Hsin-Wei reported a KASAN splat triggered by their BPF runtime fuzzer which
      is based on a customized syzkaller:
      
        BUG: KASAN: slab-out-of-bounds in bpf_int_jit_compile+0x1257/0x13f0
        Read of size 8 at addr ffff888004e90b58 by task syz-executor.0/1489
        CPU: 1 PID: 1489 Comm: syz-executor.0 Not tainted 5.19.0 #1
        Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
        1.13.0-1ubuntu1.1 04/01/2014
        Call Trace:
         <TASK>
         dump_stack_lvl+0x9c/0xc9
         print_address_description.constprop.0+0x1f/0x1f0
         ? bpf_int_jit_compile+0x1257/0x13f0
         kasan_report.cold+0xeb/0x197
         ? kvmalloc_node+0x170/0x200
         ? bpf_int_jit_compile+0x1257/0x13f0
         bpf_int_jit_compile+0x1257/0x13f0
         ? arch_prepare_bpf_dispatcher+0xd0/0xd0
         ? rcu_read_lock_sched_held+0x43/0x70
         bpf_prog_select_runtime+0x3e8/0x640
         ? bpf_obj_name_cpy+0x149/0x1b0
         bpf_prog_load+0x102f/0x2220
         ? __bpf_prog_put.constprop.0+0x220/0x220
         ? find_held_lock+0x2c/0x110
         ? __might_fault+0xd6/0x180
         ? lock_downgrade+0x6e0/0x6e0
         ? lock_is_held_type+0xa6/0x120
         ? __might_fault+0x147/0x180
         __sys_bpf+0x137b/0x6070
         ? bpf_perf_link_attach+0x530/0x530
         ? new_sync_read+0x600/0x600
         ? __fget_files+0x255/0x450
         ? lock_downgrade+0x6e0/0x6e0
         ? fput+0x30/0x1a0
         ? ksys_write+0x1a8/0x260
         __x64_sys_bpf+0x7a/0xc0
         ? syscall_enter_from_user_mode+0x21/0x70
         do_syscall_64+0x3b/0x90
         entry_SYSCALL_64_after_hwframe+0x63/0xcd
        RIP: 0033:0x7f917c4e2c2d
      
      The problem here is that a range of tnum_range(0, map->max_entries - 1) has
      limited ability to represent the concrete tight range with the tnum as the
      set of resulting states from value + mask can result in a superset of the
      actual intended range, and as such a tnum_in(range, reg->var_off) check may
      yield true when it shouldn't, for example tnum_range(0, 2) would result in
      00XX -> v = 0000, m = 0011 such that the intended set of {0, 1, 2} is here
      represented by a less precise superset of {0, 1, 2, 3}. As the register is
      known const scalar, really just use the concrete reg->var_off.value for the
      upper index check.
      
      Fixes: d2e4c1e6
      
       ("bpf: Constant map key tracking for prog array pokes")
      Reported-by: default avatarHsin-Wei Hung <hsinweih@uci.edu>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Cc: Shung-Hsi Yu <shung-hsi.yu@suse.com>
      Acked-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Link: https://lore.kernel.org/r/984b37f9fdf7ac36831d2137415a4a915744c1b6.1661462653.git.daniel@iogearbox.net
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a36df92c
    • Conor Dooley's avatar
      riscv: dts: microchip: mpfs: remove pci axi address translation property · f0e5ce88
      Conor Dooley authored
      commit e4009c5f upstream.
      
      An AXI master address translation table property was inadvertently
      added to the device tree & this was not caught by dtbs_check at the
      time. Remove the property - it should not be in mpfs.dtsi anyway as
      it would be more suitable in -fabric.dtsi nor does it actually apply
      to the version of the reference design we are using for upstream.
      
      Link: https://www.microsemi.com/document-portal/doc_download/1245812-polarfire-fpga-and-polarfire-soc-fpga-pci-express-user-guide # Section 1.3.3
      Fixes: 528a5b1f
      
       ("riscv: dts: microchip: add new peripherals to icicle kit device tree")
      Signed-off-by: default avatarConor Dooley <conor.dooley@microchip.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f0e5ce88
    • Conor Dooley's avatar
      riscv: dts: microchip: mpfs: remove bogus card-detect-delay · 14f158b9
      Conor Dooley authored
      commit 2b55915d upstream.
      
      Recent versions of dt-schema warn about a previously undetected
      undocumented property:
      arch/riscv/boot/dts/microchip/mpfs-icicle-kit.dtb: mmc@20008000: Unevaluated properties are not allowed ('card-detect-delay' was unexpected)
              From schema: Documentation/devicetree/bindings/mmc/cdns,sdhci.yaml
      
      There are no GPIOs connected to MSSIO6B4 pin K3 so adding the common
      cd-debounce-delay-ms property makes no sense. The Cadence IP has a
      register that sets the card detect delay as "DP * tclk". On MPFS, this
      clock frequency is not configurable (it must be 200 MHz) & the FPGA
      comes out of reset with this register already set.
      
      Fixes: bc47b221 ("riscv: dts: microchip: add the sundance polarberry")
      Fixes: 0fa6107e
      
       ("RISC-V: Initial DTS for Microchip ICICLE board")
      Signed-off-by: default avatarConor Dooley <conor.dooley@microchip.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      14f158b9
    • Conor Dooley's avatar
      riscv: dts: microchip: mpfs: remove ti,fifo-depth property · a8604d23
      Conor Dooley authored
      commit 72a05748 upstream.
      
      Recent versions of dt-schema warn about a previously undetected
      undocument property on the icicle & polarberry devicetrees:
      
      arch/riscv/boot/dts/microchip/mpfs-icicle-kit.dtb: ethernet@20112000: ethernet-phy@8: Unevaluated properties are not allowed ('ti,fifo-depth' was unexpected)
              From schema: Documentation/devicetree/bindings/net/cdns,macb.yaml
      
      I know what you're thinking, the binding doesn't look to be the problem
      and I agree. I am not sure why a TI vendor property was ever actually
      added since it has no meaning... just get rid of it.
      
      Fixes: bc47b221 ("riscv: dts: microchip: add the sundance polarberry")
      Fixes: 0fa6107e
      
       ("RISC-V: Initial DTS for Microchip ICICLE board")
      Signed-off-by: default avatarConor Dooley <conor.dooley@microchip.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a8604d23
    • Conor Dooley's avatar
      riscv: dts: microchip: mpfs: fix incorrect pcie child node name · 5977375a
      Conor Dooley authored
      commit 3f67e699 upstream.
      
      Recent versions of dt-schema complain about the PCIe controller's child
      node name:
      arch/riscv/boot/dts/microchip/mpfs-icicle-kit.dtb: pcie@2000000000: Unevaluated properties are not allowed ('clock-names', 'clocks', 'legacy-interrupt-controller', 'microchip,axi-m-atr0' were unexpected)
                  From schema: Documentation/devicetree/bindings/pci/microchip,pcie-host.yaml
      Make the dts match the correct property name in the dts.
      
      Fixes: 528a5b1f
      
       ("riscv: dts: microchip: add new peripherals to icicle kit device tree")
      Signed-off-by: default avatarConor Dooley <conor.dooley@microchip.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5977375a
    • Mike Christie's avatar
      scsi: core: Fix passthrough retry counter handling · f24ee739
      Mike Christie authored
      commit fac8e558 upstream.
      
      Passthrough users will set the scsi_cmnd->allowed value and were expecting
      up to $allowed retries. The problem is that before:
      
      commit 6aded12b ("scsi: core: Remove struct scsi_request")
      
      we used to set the retries on the scsi_request then copy them over to
      scsi_cmnd->allowed in scsi_setup_scsi_cmnd. With that patch we now set
      scsi_cmnd->allowed to 0 in scsi_prepare_cmd and overwrite what the
      passthrough user set.
      
      This moves the allowed initialization to after the blk_rq_is_passthrough()
      check so it's only done for the non-passthrough path where the ULD
      init_command will normally set an allowed value it prefers.
      
      Link: https://lore.kernel.org/r/20220812011206.9157-1-michael.christie@oracle.com
      Fixes: 6aded12b
      
       ("scsi: core: Remove struct scsi_request")
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarMike Christie <michael.christie@oracle.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f24ee739
    • Saurabh Sengar's avatar
      scsi: storvsc: Remove WQ_MEM_RECLAIM from storvsc_error_wq · 828f57ac
      Saurabh Sengar authored
      commit d957e7ff upstream.
      
      storvsc_error_wq workqueue should not be marked as WQ_MEM_RECLAIM as it
      doesn't need to make forward progress under memory pressure.  Marking this
      workqueue as WQ_MEM_RECLAIM may cause deadlock while flushing a
      non-WQ_MEM_RECLAIM workqueue.  In the current state it causes the following
      warning:
      
      [   14.506347] ------------[ cut here ]------------
      [   14.506354] workqueue: WQ_MEM_RECLAIM storvsc_error_wq_0:storvsc_remove_lun is flushing !WQ_MEM_RECLAIM events_freezable_power_:disk_events_workfn
      [   14.506360] WARNING: CPU: 0 PID: 8 at <-snip->kernel/workqueue.c:2623 check_flush_dependency+0xb5/0x130
      [   14.506390] CPU: 0 PID: 8 Comm: kworker/u4:0 Not tainted 5.4.0-1086-azure #91~18.04.1-Ubuntu
      [   14.506391] Hardware name: Microsoft Corporation Virtual Machine/Virtual Machine, BIOS Hyper-V UEFI Release v4.1 05/09/2022
      [   14.506393] Workqueue: storvsc_error_wq_0 storvsc_remove_lun
      [   14.506395] RIP: 0010:check_flush_dependency+0xb5/0x130
      		<-snip->
      [   14.506408] Call Trace:
      [   14.506412]  __flush_work+0xf1/0x1c0
      [   14.506414]  __cancel_work_timer+0x12f/0x1b0
      [   14.506417]  ? kernfs_put+0xf0/0x190
      [   14.506418]  cancel_delayed_work_sync+0x13/0x20
      [   14.506420]  disk_block_events+0x78/0x80
      [   14.506421]  del_gendisk+0x3d/0x2f0
      [   14.506423]  sr_remove+0x28/0x70
      [   14.506427]  device_release_driver_internal+0xef/0x1c0
      [   14.506428]  device_release_driver+0x12/0x20
      [   14.506429]  bus_remove_device+0xe1/0x150
      [   14.506431]  device_del+0x167/0x380
      [   14.506432]  __scsi_remove_device+0x11d/0x150
      [   14.506433]  scsi_remove_device+0x26/0x40
      [   14.506434]  storvsc_remove_lun+0x40/0x60
      [   14.506436]  process_one_work+0x209/0x400
      [   14.506437]  worker_thread+0x34/0x400
      [   14.506439]  kthread+0x121/0x140
      [   14.506440]  ? process_one_work+0x400/0x400
      [   14.506441]  ? kthread_park+0x90/0x90
      [   14.506443]  ret_from_fork+0x35/0x40
      [   14.506445] ---[ end trace 2d9633159fdc6ee7 ]---
      
      Link: https://lore.kernel.org/r/1659628534-17539-1-git-send-email-ssengar@linux.microsoft.com
      Fixes: 436ad941
      
       ("scsi: storvsc: Allow only one remove lun work item to be issued per lun")
      Reviewed-by: default avatarMichael Kelley <mikelley@microsoft.com>
      Signed-off-by: default avatarSaurabh Sengar <ssengar@linux.microsoft.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      828f57ac
    • Kiwoong Kim's avatar
      scsi: ufs: core: Enable link lost interrupt · a292244e
      Kiwoong Kim authored
      commit 6d17a112 upstream.
      
      Link lost is treated as fatal error with commit c99b9b23 ("scsi: ufs:
      Treat link loss as fatal error"), but the event isn't registered as
      interrupt source. Enable it.
      
      Link: https://lore.kernel.org/r/1659404551-160958-1-git-send-email-kwmad.kim@samsung.com
      Fixes: c99b9b23
      
       ("scsi: ufs: Treat link loss as fatal error")
      Reviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarKiwoong Kim <kwmad.kim@samsung.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a292244e
    • Mark Brown's avatar
      arm64/sme: Don't flush SVE register state when handling SME traps · 0761b0e8
      Mark Brown authored
      commit 714f3cbd upstream.
      
      Currently as part of handling a SME access trap we flush the SVE register
      state. This is not needed and would corrupt register state if the task has
      access to the SVE registers already. For non-streaming mode accesses the
      required flushing will be done in the SVE access trap. For streaming
      mode SVE register accesses the architecture guarantees that the register
      state will be flushed when streaming mode is entered or exited so there is
      no need for us to do so. Simply remove the register initialisation.
      
      Fixes: 8bd7f91c
      
       ("arm64/sme: Implement traps and syscall handling for SME")
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Reviewed-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Link: https://lore.kernel.org/r/20220817182324.638214-5-broonie@kernel.org
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0761b0e8
    • Mark Brown's avatar
      arm64/sme: Don't flush SVE register state when allocating SME storage · a8d79f9d
      Mark Brown authored
      commit 826a4fdd upstream.
      
      Currently when taking a SME access trap we allocate storage for the SVE
      register state in order to be able to handle storage of streaming mode SVE.
      Due to the original usage in a purely SVE context the SVE register state
      allocation this also flushes the register state for SVE if storage was
      already allocated but in the SME context this is not desirable. For a SME
      access trap to be taken the task must not be in streaming mode so either
      there already is SVE register state present for regular SVE mode which would
      be corrupted or the task does not have TIF_SVE and the flush is redundant.
      
      Fix this by adding a flag to sve_alloc() indicating if we are in a SVE
      context and need to flush the state. Freshly allocated storage is always
      zeroed either way.
      
      Fixes: 8bd7f91c
      
       ("arm64/sme: Implement traps and syscall handling for SME")
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Reviewed-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Link: https://lore.kernel.org/r/20220817182324.638214-4-broonie@kernel.org
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a8d79f9d
    • Mark Brown's avatar
      arm64/signal: Flush FPSIMD register state when disabling streaming mode · 913fe86a
      Mark Brown authored
      commit ea64baac upstream.
      
      When handling a signal delivered to a context with streaming mode enabled
      we will disable streaming mode for the signal handler, when doing so we
      should also flush the saved FPSIMD register state like exiting streaming
      mode in the hardware would do so that if that state is reloaded we get the
      same behaviour. Without this we will reload whatever the last FPSIMD state
      that was saved for the task was.
      
      Fixes: 40a8e87b
      
       ("arm64/sme: Disable ZA and streaming mode when handling signals")
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Reviewed-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Link: https://lore.kernel.org/r/20220817182324.638214-3-broonie@kernel.org
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      913fe86a
    • Mark Rutland's avatar
      arm64: fix rodata=full · f83cbd14
      Mark Rutland authored
      commit 2e8cff0a upstream.
      
      On arm64, "rodata=full" has been suppored (but not documented) since
      commit:
      
        c55191e9 ("arm64: mm: apply r/o permissions of VM areas to its linear alias as well")
      
      As it's necessary to determine the rodata configuration early during
      boot, arm64 has an early_param() handler for this, whereas init/main.c
      has a __setup() handler which is run later.
      
      Unfortunately, this split meant that since commit:
      
        f9a40b08 ("init/main.c: return 1 from handled __setup() functions")
      
      ... passing "rodata=full" would result in a spurious warning from the
      __setup() handler (though RO permissions would be configured
      appropriately).
      
      Further, "rodata=full" has been broken since commit:
      
        0d6ea3ac ("lib/kstrtox.c: add "false"/"true" support to kstrtobool()")
      
      ... which caused strtobool() to parse "full" as false (in addition to
      many other values not documented for the "rodata=" kernel parameter.
      
      This patch fixes this breakage by:
      
      * Moving the core parameter parser to an __early_param(), such that it
        is available early.
      
      * Adding an (optional) arch hook which arm64 can use to parse "full".
      
      * Updating the documentation to mention that "full" is valid for arm64.
      
      * Having the core parameter parser handle "on" and "off" explicitly,
        such that any undocumented values (e.g. typos such as "ful") are
        reported as errors rather than being silently accepted.
      
      Note that __setup() and early_param() have opposite conventions for
      their return values, where __setup() uses 1 to indicate a parameter was
      handled and early_param() uses 0 to indicate a parameter was handled.
      
      Fixes: f9a40b08 ("init/main.c: return 1 from handled __setup() functions")
      Fixes: 0d6ea3ac
      
       ("lib/kstrtox.c: add "false"/"true" support to kstrtobool()")
      Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
      Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
      Cc: Ard Biesheuvel <ardb@kernel.org>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Jagdish Gediya <jvgediya@linux.ibm.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: Will Deacon <will@kernel.org>
      Reviewed-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Link: https://lore.kernel.org/r/20220817154022.3974645-1-mark.rutland@arm.com
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f83cbd14
    • Ian Rogers's avatar
      perf stat: Clear evsel->reset_group for each stat run · ec76a1de
      Ian Rogers authored
      commit bf515f02 upstream.
      
      If a weak group is broken then the reset_group flag remains set for
      the next run. Having reset_group set means the counter isn't created
      and ultimately a segfault.
      
      A simple reproduction of this is:
      
        # perf stat -r2 -e '{cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles,cycles}:W
      
      which will be added as a test in the next patch.
      
      Fixes: 4804e011
      
       ("perf stat: Use affinity for opening events")
      Reviewed-by: default avatarAndi Kleen <ak@linux.intel.com>
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Tested-by: default avatarXing Zhengjun <zhengjun.xing@linux.intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: https://lore.kernel.org/r/20220822213352.75721-1-irogers@google.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ec76a1de
    • Stephane Eranian's avatar
      perf/x86/intel/ds: Fix precise store latency handling · 6d7a4a14
      Stephane Eranian authored
      commit d4bdb0be upstream.
      
      With the existing code in store_latency_data(), the memory operation (mem_op)
      returned to the user is always OP_LOAD where in fact, it should be OP_STORE.
      This comes from the fact that the function is simply grabbing the information
      from a data source map which covers only load accesses. Intel 12th gen CPU
      offers precise store sampling that captures both the data source and latency.
      Therefore it can use the data source mapping table but must override the
      memory operation to reflect stores instead of loads.
      
      Fixes: 61b985e3
      
       ("perf/x86/intel: Add perf core PMU support for Sapphire Rapids")
      Signed-off-by: default avatarStephane Eranian <eranian@google.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/20220818054613.1548130-1-eranian@google.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6d7a4a14
    • Stephane Eranian's avatar
      perf/x86/intel/uncore: Fix broken read_counter() for SNB IMC PMU · 291f8bae
      Stephane Eranian authored
      commit 11745ecf upstream.
      
      Existing code was generating bogus counts for the SNB IMC bandwidth counters:
      
      $ perf stat -a -I 1000 -e uncore_imc/data_reads/,uncore_imc/data_writes/
           1.000327813           1,024.03 MiB  uncore_imc/data_reads/
           1.000327813              20.73 MiB  uncore_imc/data_writes/
           2.000580153         261,120.00 MiB  uncore_imc/data_reads/
           2.000580153              23.28 MiB  uncore_imc/data_writes/
      
      The problem was introduced by commit:
        07ce734d ("perf/x86/intel/uncore: Clean up client IMC")
      
      Where the read_counter callback was replace to point to the generic
      uncore_mmio_read_counter() function.
      
      The SNB IMC counters are freerunnig 32-bit counters laid out contiguously in
      MMIO. But uncore_mmio_read_counter() is using a readq() call to read from
      MMIO therefore reading 64-bit from MMIO. Although this is okay for the
      uncore_perf_event_update() function because it is shifting the value based
      on the actual counter width to compute a delta, it is not okay for the
      uncore_pmu_event_start() which is simply reading the counter  and therefore
      priming the event->prev_count with a bogus value which is responsible for
      causing bogus deltas in the perf stat command above.
      
      The fix is to reintroduce the custom callback for read_counter for the SNB
      IMC PMU and use readl() instead of readq(). With the change the output of
      perf stat is back to normal:
      $ perf stat -a -I 1000 -e uncore_imc/data_reads/,uncore_imc/data_writes/
           1.000120987             296.94 MiB  uncore_imc/data_reads/
           1.000120987             138.42 MiB  uncore_imc/data_writes/
           2.000403144             175.91 MiB  uncore_imc/data_reads/
           2.000403144              68.50 MiB  uncore_imc/data_writes/
      
      Fixes: 07ce734d
      
       ("perf/x86/intel/uncore: Clean up client IMC")
      Signed-off-by: default avatarStephane Eranian <eranian@google.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Reviewed-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Link: https://lore.kernel.org/r/20220803160031.1379788-1-eranian@google.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      291f8bae
    • James Clark's avatar
      perf python: Fix build when PYTHON_CONFIG is user supplied · a9271d39
      James Clark authored
      commit bc9e7fe3 upstream.
      
      The previous change to Python autodetection had a small mistake where
      the auto value was used to determine the Python binary, rather than the
      user supplied value. The Python binary is only used for one part of the
      build process, rather than the final linking, so it was producing
      correct builds in most scenarios, especially when the auto detected
      value matched what the user wanted, or the system only had a valid set
      of Pythons.
      
      Change it so that the Python binary path is derived from either the
      PYTHON_CONFIG value or PYTHON value, depending on what is specified by
      the user. This was the original intention.
      
      This error was spotted in a build failure an odd cross compilation
      environment after commit 4c41cb46 ("perf python: Prefer
      python3") was merged.
      
      Fixes: 630af16e
      
       ("perf tools: Use Python devtools for version autodetection rather than runtime")
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20220728093946.1337642-1-james.clark@arm.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a9271d39
    • Yu Kuai's avatar
      blk-mq: fix io hung due to missing commit_rqs · b2f10baf
      Yu Kuai authored
      commit 65fac0d5 upstream.
      
      Currently, in virtio_scsi, if 'bd->last' is not set to true while
      dispatching request, such io will stay in driver's queue, and driver
      will wait for block layer to dispatch more rqs. However, if block
      layer failed to dispatch more rq, it should trigger commit_rqs to
      inform driver.
      
      There is a problem in blk_mq_try_issue_list_directly() that commit_rqs
      won't be called:
      
      // assume that queue_depth is set to 1, list contains two rq
      blk_mq_try_issue_list_directly
       blk_mq_request_issue_directly
       // dispatch first rq
       // last is false
        __blk_mq_try_issue_directly
         blk_mq_get_dispatch_budget
         // succeed to get first budget
         __blk_mq_issue_directly
          scsi_queue_rq
           cmd->flags |= SCMD_LAST
            virtscsi_queuecommand
             kick = (sc->flags & SCMD_LAST) != 0
             // kick is false, first rq won't issue to disk
       queued++
      
       blk_mq_request_issue_directly
       // dispatch second rq
        __blk_mq_try_issue_directly
         blk_mq_get_dispatch_budget
         // failed to get second budget
       ret == BLK_STS_RESOURCE
        blk_mq_request_bypass_insert
       // errors is still 0
      
       if (!list_empty(list) || errors && ...)
        // won't pass, commit_rqs won't be called
      
      In this situation, first rq relied on second rq to dispatch, while
      second rq relied on first rq to complete, thus they will both hung.
      
      Fix the problem by also treat 'BLK_STS_*RESOURCE' as 'errors' since
      it means that request is not queued successfully.
      
      Same problem exists in blk_mq_dispatch_rq_list(), 'BLK_STS_*RESOURCE'
      can't be treated as 'errors' here, fix the problem by calling
      commit_rqs if queue_rq return 'BLK_STS_*RESOURCE'.
      
      Fixes: d666ba98
      
       ("blk-mq: add mq_ops->commit_rqs()")
      Signed-off-by: default avatarYu Kuai <yukuai3@huawei.com>
      Reviewed-by: default avatarMing Lei <ming.lei@redhat.com>
      Link: https://lore.kernel.org/r/20220726122224.1790882-1-yukuai1@huaweicloud.com
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b2f10baf
    • Salvatore Bonaccorso's avatar
      Documentation/ABI: Mention retbleed vulnerability info file for sysfs · ca949183
      Salvatore Bonaccorso authored
      commit 00da0cb3 upstream.
      
      While reporting for the AMD retbleed vulnerability was added in
      
        6b80b59b ("x86/bugs: Report AMD retbleed vulnerability")
      
      the new sysfs file was not mentioned so far in the ABI documentation for
      sysfs-devices-system-cpu. Fix that.
      
      Fixes: 6b80b59b
      
       ("x86/bugs: Report AMD retbleed vulnerability")
      Signed-off-by: default avatarSalvatore Bonaccorso <carnil@debian.org>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Link: https://lore.kernel.org/r/20220801091529.325327-1-carnil@debian.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ca949183
    • Prike Liang's avatar
      drm/amdkfd: Fix isa version for the GC 10.3.7 · 43365c8f
      Prike Liang authored
      commit ee8086db upstream.
      
      Correct the isa version for handling KFD test.
      
      Fixes: 7c4f4f19
      
       ("drm/amdkfd: Add GC 10.3.6 and 10.3.7 KFD definitions")
      Signed-off-by: default avatarPrike Liang <Prike.Liang@amd.com>
      Reviewed-by: default avatarAaron Liu <aaron.liu@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      43365c8f
    • Peter Zijlstra's avatar
      x86/nospec: Fix i386 RSB stuffing · b864bc2a
      Peter Zijlstra authored
      commit 33292497 upstream.
      
      Turns out that i386 doesn't unconditionally have LFENCE, as such the
      loop in __FILL_RETURN_BUFFER isn't actually speculation safe on such
      chips.
      
      Fixes: ba6e31af
      
       ("x86/speculation: Add LFENCE to RSB fill sequence")
      Reported-by: default avatarBen Hutchings <ben@decadent.org.uk>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/Yv9tj9vbQ9nNlXoY@worktop.programming.kicks-ass.net
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b864bc2a
    • Liam Howlett's avatar
      binder_alloc: add missing mmap_lock calls when using the VMA · 7b0163c1
      Liam Howlett authored
      commit 44e602b4 upstream.
      
      Take the mmap_read_lock() when using the VMA in binder_alloc_print_pages()
      and when checking for a VMA in binder_alloc_new_buf_locked().
      
      It is worth noting binder_alloc_new_buf_locked() drops the VMA read lock
      after it verifies a VMA exists, but may be taken again deeper in the call
      stack, if necessary.
      
      Link: https://lkml.kernel.org/r/20220810160209.1630707-1-Liam.Howlett@oracle.com
      Fixes: a43cfc87
      
       (android: binder: stop saving a pointer to the VMA)
      Signed-off-by: default avatarLiam R. Howlett <Liam.Howlett@oracle.com>
      Reported-by: default avatarOndrej Mosnacek <omosnace@redhat.com>
      Reported-by: default avatar <syzbot+a7b60a176ec13cafb793@syzkaller.appspotmail.com>
      Acked-by: default avatarCarlos Llamas <cmllamas@google.com>
      Tested-by: default avatarOndrej Mosnacek <omosnace@redhat.com>
      Cc: Minchan Kim <minchan@kernel.org>
      Cc: Christian Brauner (Microsoft) <brauner@kernel.org>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Hridya Valsaraju <hridya@google.com>
      Cc: Joel Fernandes <joel@joelfernandes.org>
      Cc: Martijn Coenen <maco@android.com>
      Cc: Suren Baghdasaryan <surenb@google.com>
      Cc: Todd Kjos <tkjos@android.com>
      Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
      Cc: "Arve Hjønnevåg" <arve@android.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7b0163c1
    • Zenghui Yu's avatar
      arm64: Fix match_list for erratum 1286807 on Arm Cortex-A76 · b887868c
      Zenghui Yu authored
      commit 5e1e0874 upstream.
      
      Since commit 51f559d6 ("arm64: Enable repeat tlbi workaround on KRYO4XX
      gold CPUs"), we failed to detect erratum 1286807 on Cortex-A76 because its
      entry in arm64_repeat_tlbi_list[] was accidently corrupted by this commit.
      
      Fix this issue by creating a separate entry for Kryo4xx Gold.
      
      Fixes: 51f559d6
      
       ("arm64: Enable repeat tlbi workaround on KRYO4XX gold CPUs")
      Cc: Shreyas K K <quic_shrekk@quicinc.com>
      Signed-off-by: default avatarZenghui Yu <yuzenghui@huawei.com>
      Acked-by: default avatarMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/20220809043848.969-1-yuzenghui@huawei.com
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b887868c
    • Guoqing Jiang's avatar
      md: call __md_stop_writes in md_stop · f42a9819
      Guoqing Jiang authored
      commit 0dd84b31 upstream.
      
      From the link [1], we can see raid1d was running even after the path
      raid_dtr -> md_stop -> __md_stop.
      
      Let's stop write first in destructor to align with normal md-raid to
      fix the KASAN issue.
      
      [1]. https://lore.kernel.org/linux-raid/CAPhsuW5gc4AakdGNdF8ubpezAuDLFOYUO_sfMZcec6hQFm8nhg@mail.gmail.com/T/#m7f12bf90481c02c6d2da68c64aeed4779b7df74a
      
      Fixes: 48df498d
      
       ("md: move bitmap_destroy to the beginning of __md_stop")
      Reported-by: default avatarMikulas Patocka <mpatocka@redhat.com>
      Signed-off-by: default avatarGuoqing Jiang <guoqing.jiang@linux.dev>
      Signed-off-by: default avatarSong Liu <song@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f42a9819
    • Guoqing Jiang's avatar
      Revert "md-raid: destroy the bitmap after destroying the thread" · 4d83d9b7
      Guoqing Jiang authored
      commit 1d258758 upstream.
      
      This reverts commit e151db8e. Because it
      obviously breaks clustered raid as noticed by Neil though it fixed KASAN
      issue for dm-raid, let's revert it and fix KASAN issue in next commit.
      
      [1]. https://lore.kernel.org/linux-raid/a6657e08-b6a7-358b-2d2a-0ac37d49d23a@linux.dev/T/#m95ac225cab7409f66c295772483d091084a6d470
      
      Fixes: e151db8e
      
       ("md-raid: destroy the bitmap after destroying the thread")
      Signed-off-by: default avatarGuoqing Jiang <guoqing.jiang@linux.dev>
      Signed-off-by: default avatarSong Liu <song@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4d83d9b7