Skip to content
  1. Aug 23, 2023
    • Filipe Manana's avatar
      btrfs: fix use-after-free of new block group that became unused · 6297644d
      Filipe Manana authored
      [ Upstream commit 0657b20c ]
      
      If a task creates a new block group and that block group becomes unused
      before we finish its creation, at btrfs_create_pending_block_groups(),
      then when btrfs_mark_bg_unused() is called against the block group, we
      assume that the block group is currently in the list of block groups to
      reclaim, and we move it out of the list of new block groups and into the
      list of unused block groups. This has two consequences:
      
      1) We move it out of the list of new block groups associated to the
         current transaction. So the block group creation is not finished and
         if we attempt to delete the bg because it's unused, we will not find
         the block group item in the extent tree (or the new block group tree),
         its device extent items in the device tree etc, resulting in the
         deletion to fail due to the missing items;
      
      2) We don't increment the reference count on the block group when we
         move it to the list of unused block groups, because we assumed the
         block group was on the list of block groups to reclaim, and in that
         case it already has the correct reference count. However the block
         group was on the list of new block groups, in which case no extra
         reference was taken because it's local to the current task. This
         later results in doing an extra reference count decrement when
         removing the block group from the unused list, eventually leading the
         reference count to 0.
      
      This second case was caught when running generic/297 from fstests, which
      produced the following assertion failure and stack trace:
      
        [589.559] assertion failed: refcount_read(&block_group->refs) == 1, in fs/btrfs/block-group.c:4299
        [589.559] ------------[ cut here ]------------
        [589.559] kernel BUG at fs/btrfs/block-group.c:4299!
        [589.560] invalid opcode: 0000 [#1] PREEMPT SMP PTI
        [589.560] CPU: 8 PID: 2819134 Comm: umount Tainted: G        W          6.4.0-rc6-btrfs-next-134+ #1
        [589.560] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.2-0-gea1b7a073390-prebuilt.qemu.org 04/01/2014
        [589.560] RIP: 0010:btrfs_free_block_groups+0x449/0x4a0 [btrfs]
        [589.561] Code: 68 62 da c0 (...)
        [589.561] RSP: 0018:ffffa55a8c3b3d98 EFLAGS: 00010246
        [589.561] RAX: 0000000000000058 RBX: ffff8f030d7f2000 RCX: 0000000000000000
        [589.562] RDX: 0000000000000000 RSI: ffffffff953f0878 RDI: 00000000ffffffff
        [589.562] RBP: ffff8f030d7f2088 R08: 0000000000000000 R09: ffffa55a8c3b3c50
        [589.562] R10: 0000000000000001 R11: 0000000000000001 R12: ffff8f05850b4c00
        [589.562] R13: ffff8f030d7f2090 R14: ffff8f05850b4cd8 R15: dead000000000100
        [589.563] FS:  00007f497fd2e840(0000) GS:ffff8f09dfc00000(0000) knlGS:0000000000000000
        [589.563] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        [589.563] CR2: 00007f497ff8ec10 CR3: 0000000271472006 CR4: 0000000000370ee0
        [589.563] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
        [589.564] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
        [589.564] Call Trace:
        [589.564]  <TASK>
        [589.565]  ? __die_body+0x1b/0x60
        [589.565]  ? die+0x39/0x60
        [589.565]  ? do_trap+0xeb/0x110
        [589.565]  ? btrfs_free_block_groups+0x449/0x4a0 [btrfs]
        [589.566]  ? do_error_trap+0x6a/0x90
        [589.566]  ? btrfs_free_block_groups+0x449/0x4a0 [btrfs]
        [589.566]  ? exc_invalid_op+0x4e/0x70
        [589.566]  ? btrfs_free_block_groups+0x449/0x4a0 [btrfs]
        [589.567]  ? asm_exc_invalid_op+0x16/0x20
        [589.567]  ? btrfs_free_block_groups+0x449/0x4a0 [btrfs]
        [589.567]  ? btrfs_free_block_groups+0x449/0x4a0 [btrfs]
        [589.567]  close_ctree+0x35d/0x560 [btrfs]
        [589.568]  ? fsnotify_sb_delete+0x13e/0x1d0
        [589.568]  ? dispose_list+0x3a/0x50
        [589.568]  ? evict_inodes+0x151/0x1a0
        [589.568]  generic_shutdown_super+0x73/0x1a0
        [589.569]  kill_anon_super+0x14/0x30
        [589.569]  btrfs_kill_super+0x12/0x20 [btrfs]
        [589.569]  deactivate_locked_super+0x2e/0x70
        [589.569]  cleanup_mnt+0x104/0x160
        [589.570]  task_work_run+0x56/0x90
        [589.570]  exit_to_user_mode_prepare+0x160/0x170
        [589.570]  syscall_exit_to_user_mode+0x22/0x50
        [589.570]  ? __x64_sys_umount+0x12/0x20
        [589.571]  do_syscall_64+0x48/0x90
        [589.571]  entry_SYSCALL_64_after_hwframe+0x72/0xdc
        [589.571] RIP: 0033:0x7f497ff0a567
        [589.571] Code: af 98 0e (...)
        [589.572] RSP: 002b:00007ffc98347358 EFLAGS: 00000246 ORIG_RAX: 00000000000000a6
        [589.572] RAX: 0000000000000000 RBX: 00007f49800b8264 RCX: 00007f497ff0a567
        [589.572] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000557f558abfa0
        [589.573] RBP: 0000557f558a6ba0 R08: 0000000000000000 R09: 00007ffc98346100
        [589.573] R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
        [589.573] R13: 0000557f558abfa0 R14: 0000557f558a6cb0 R15: 0000557f558a6dd0
        [589.573]  </TASK>
        [589.574] Modules linked in: dm_snapshot dm_thin_pool (...)
        [589.576] ---[ end trace 0000000000000000 ]---
      
      Fix this by adding a runtime flag to the block group to tell that the
      block group is still in the list of new block groups, and therefore it
      should not be moved to the list of unused block groups, at
      btrfs_mark_bg_unused(), until the flag is cleared, when we finish the
      creation of the block group at btrfs_create_pending_block_groups().
      
      Fixes: a9f18971
      
       ("btrfs: move out now unused BG from the reclaim list")
      CC: stable@vger.kernel.org # 5.15+
      Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6297644d
    • David Sterba's avatar
      btrfs: convert btrfs_block_group::seq_zone to runtime flag · 29cebf80
      David Sterba authored
      [ Upstream commit 961f5b8b
      
       ]
      
      In zoned mode the sequential status of zone can be also tracked in the
      runtime flags of block group.
      
      Reviewed-by: default avatarAnand Jain <anand.jain@oracle.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Stable-dep-of: 0657b20c
      
       ("btrfs: fix use-after-free of new block group that became unused")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      29cebf80
    • David Sterba's avatar
      btrfs: convert btrfs_block_group::needs_free_space to runtime flag · 94cde941
      David Sterba authored
      [ Upstream commit 0d7764ff
      
       ]
      
      We already have flags in block group to track various status bits,
      convert needs_free_space as well and reduce size of btrfs_block_group.
      
      Reviewed-by: default avatarAnand Jain <anand.jain@oracle.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Stable-dep-of: 0657b20c
      
       ("btrfs: fix use-after-free of new block group that became unused")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      94cde941
    • Naohiro Aota's avatar
      btrfs: move out now unused BG from the reclaim list · 01eca70e
      Naohiro Aota authored
      [ Upstream commit a9f18971 ]
      
      An unused block group is easy to remove to free up space and should be
      reclaimed fast. Such block group can often already be a target of the
      reclaim process. As we check list_empty(&bg->bg_list), we keep it in the
      reclaim list. That block group is never reclaimed until the file system
      is filled e.g. up to 75%.
      
      Instead, we can move unused block group to the unused list and delete it
      fast.
      
      Fixes: 18bb8bbf
      
       ("btrfs: zoned: automatically reclaim zones")
      CC: stable@vger.kernel.org # 5.15+
      Reviewed-by: default avatarFilipe Manana <fdmanana@suse.com>
      Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
      Signed-off-by: default avatarNaohiro Aota <naohiro.aota@wdc.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      01eca70e
    • Daniel Vetter's avatar
      video/aperture: Only remove sysfb on the default vga pci device · 485ec8f8
      Daniel Vetter authored
      [ Upstream commit 5ae3716c ]
      
      Instead of calling aperture_remove_conflicting_devices() to remove the
      conflicting devices, just call to aperture_detach_devices() to detach
      the device that matches the same PCI BAR / aperture range. Since the
      former is just a wrapper of the latter plus a sysfb_disable() call,
      and now that's done in this function but only for the primary devices.
      
      This fixes a regression introduced by commit ee7a69aa ("fbdev:
      Disable sysfb device registration when removing conflicting FBs"),
      where we remove the sysfb when loading a driver for an unrelated pci
      device, resulting in the user losing their efifb console or similar.
      
      Note that in practice this only is a problem with the nvidia blob,
      because that's the only gpu driver people might install which does not
      come with an fbdev driver of it's own. For everyone else the real gpu
      driver will restore a working console.
      
      Also note that in the referenced bug there's confusion that this same
      bug also happens on amdgpu. But that was just another amdgpu specific
      regression, which just happened to happen at roughly the same time and
      with the same user-observable symptoms. That bug is fixed now, see
      https://bugzilla.kernel.org/show_bug.cgi?id=216331#c15
      
      Note that we should not have any such issues on non-pci multi-gpu
      issues, because I could only find two such cases:
      - SoC with some external panel over spi or similar. These panel
        drivers do not use drm_aperture_remove_conflicting_framebuffers(),
        so no problem.
      - vga+mga, which is a direct console driver and entirely bypasses all
        this.
      
      For the above reasons the cc: stable is just notionally, this patch
      will need a backport and that's up to nvidia if they care enough.
      
      v2:
      - Explain a bit better why other multi-gpu that aren't pci shouldn't
        have any issues with making all this fully pci specific.
      
      v3
      - polish commit message (Javier)
      
      v4:
      - Fix commit message style (i.e., commit 1234 ("..."))
      - fix Daniel's S-o-b address
      
      v5:
      - add back an S-o-b tag with Daniel's Intel address
      
      Fixes: ee7a69aa
      
       ("fbdev: Disable sysfb device registration when removing conflicting FBs")
      Tested-by: default avatarAaron Plattner <aplattner@nvidia.com>
      Reviewed-by: default avatarJavier Martinez Canillas <javierm@redhat.com>
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=216303#c28
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
      Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
      Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
      Cc: Aaron Plattner <aplattner@nvidia.com>
      Cc: Javier Martinez Canillas <javierm@redhat.com>
      Cc: Thomas Zimmermann <tzimmermann@suse.de>
      Cc: Helge Deller <deller@gmx.de>
      Cc: Sam Ravnborg <sam@ravnborg.org>
      Cc: Alex Deucher <alexander.deucher@amd.com>
      Cc: <stable@vger.kernel.org> # v5.19+ (if someone else does the backport)
      Link: https://patchwork.freedesktop.org/patch/msgid/20230406132109.32050-8-tzimmermann@suse.de
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      485ec8f8
    • Thomas Zimmermann's avatar
      fbdev/hyperv-fb: Do not set struct fb_info.apertures · f83ab817
      Thomas Zimmermann authored
      [ Upstream commit 81d23934
      
       ]
      
      Generic fbdev drivers use the apertures field in struct fb_info to
      control ownership of the framebuffer memory and graphics device. Do
      not set the values in hyperv-fb.
      
      Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
      Reviewed-by: default avatarJavier Martinez Canillas <javierm@redhat.com>
      Reviewed-by: default avatarMichael Kelley <mikelley@microsoft.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20221219160516.23436-9-tzimmermann@suse.de
      Stable-dep-of: 5ae3716c
      
       ("video/aperture: Only remove sysfb on the default vga pci device")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f83ab817
    • Xu Yang's avatar
      ARM: dts: nxp/imx6sll: fix wrong property name in usbphy node · e41170d1
      Xu Yang authored
      [ Upstream commit ee70b908 ]
      
      Property name "phy-3p0-supply" is used instead of "phy-reg_3p0-supply".
      
      Fixes: 9f30b6b1
      
       ("ARM: dts: imx: Add basic dtsi file for imx6sll")
      cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarXu Yang <xu.yang_2@nxp.com>
      Signed-off-by: default avatarShawn Guo <shawnguo@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e41170d1
    • Marc Zyngier's avatar
      KVM: arm64: vgic-v4: Make the doorbell request robust w.r.t preemption · 3d2d051b
      Marc Zyngier authored
      [ Upstream commit b321c31c ]
      
      Xiang reports that VMs occasionally fail to boot on GICv4.1 systems when
      running a preemptible kernel, as it is possible that a vCPU is blocked
      without requesting a doorbell interrupt.
      
      The issue is that any preemption that occurs between vgic_v4_put() and
      schedule() on the block path will mark the vPE as nonresident and *not*
      request a doorbell irq. This occurs because when the vcpu thread is
      resumed on its way to block, vcpu_load() will make the vPE resident
      again. Once the vcpu actually blocks, we don't request a doorbell
      anymore, and the vcpu won't be woken up on interrupt delivery.
      
      Fix it by tracking that we're entering WFI, and key the doorbell
      request on that flag. This allows us not to make the vPE resident
      when going through a preempt/schedule cycle, meaning we don't lose
      any state.
      
      Cc: stable@vger.kernel.org
      Fixes: 8e01d9a3
      
       ("KVM: arm64: vgic-v4: Move the GICv4 residency flow to be driven by vcpu_load/put")
      Reported-by: default avatarXiang Chen <chenxiang66@hisilicon.com>
      Suggested-by: default avatarZenghui Yu <yuzenghui@huawei.com>
      Tested-by: default avatarXiang Chen <chenxiang66@hisilicon.com>
      Co-developed-by: default avatarOliver Upton <oliver.upton@linux.dev>
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      Acked-by: default avatarZenghui Yu <yuzenghui@huawei.com>
      Link: https://lore.kernel.org/r/20230713070657.3873244-1-maz@kernel.org
      Signed-off-by: default avatarOliver Upton <oliver.upton@linux.dev>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3d2d051b
    • Hersen Wu's avatar
      drm/amd/display: fix access hdcp_workqueue assert · 402f1d86
      Hersen Wu authored
      [ Upstream commit cdff36a0
      
       ]
      
      [Why] hdcp are enabled for asics from raven. for old asics
      which hdcp are not enabled, hdcp_workqueue are null. some
      access to hdcp work queue are not guarded with pointer check.
      
      [How] add hdcp_workqueue pointer check before access workqueue.
      
      Reviewed-by: default avatarBhawanpreet Lakha <Bhawanpreet.Lakha@amd.com>
      Acked-by: default avatarQingqing Zhuo <qingqing.zhuo@amd.com>
      Signed-off-by: default avatarHersen Wu <hersenxs.wu@amd.com>
      Tested-by: default avatarDaniel Wheeler <daniel.wheeler@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      402f1d86
    • hersen wu's avatar
      drm/amd/display: phase3 mst hdcp for multiple displays · 81e6cf44
      hersen wu authored
      [ Upstream commit e8fd3eeb
      
       ]
      
      [Why]
      multiple display hdcp are enabled within event_property_validate,
      event_property_update by looping all displays on mst hub. when
      one of display on mst hub in unplugged or disabled, hdcp are
      disabled for all displays on mst hub within hdcp_reset_display
      by looping all displays of mst link. for displays still active,
      their encryption status are off. kernel driver will not run hdcp
      authentication again. therefore, hdcp are not enabled automatically.
      
      [How]
      within is_content_protection_different, check drm_crtc_state changes
      of all displays on mst hub, if need, triger hdcp_update_display to
      re-run hdcp authentication.
      
      Acked-by: default avatarAurabindo Pillai <aurabindo.pillai@amd.com>
      Signed-off-by: default avatarhersen wu <hersenxs.wu@amd.com>
      Reviewed-by: default avatarBhawanpreet Lakha <Bhawanpreet.Lakha@amd.com>
      Tested-by: default avatarDaniel Wheeler <daniel.wheeler@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Stable-dep-of: cdff36a0
      
       ("drm/amd/display: fix access hdcp_workqueue assert")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      81e6cf44
    • hersen wu's avatar
      drm/amd/display: save restore hdcp state when display is unplugged from mst hub · d90f97cb
      hersen wu authored
      [ Upstream commit 82986fd6
      
       ]
      
      [Why]
      connector hdcp properties are lost after display is
      unplgged from mst hub. connector is destroyed with
      dm_dp_mst_connector_destroy. when display is plugged
      back, hdcp is not desired and it wouldnt be enabled.
      
      [How]
      save hdcp properties into hdcp_work within
      amdgpu_dm_atomic_commit_tail. If the same display is
      plugged back with same display index, its hdcp
      properties will be retrieved from hdcp_work within
      dm_dp_mst_get_modes.
      
      Acked-by: default avatarAurabindo Pillai <aurabindo.pillai@amd.com>
      Signed-off-by: default avatarhersen wu <hersenxs.wu@amd.com>
      Reviewed-by: default avatarBhawanpreet Lakha <Bhawanpreet.Lakha@amd.com>
      Tested-by: default avatarDaniel Wheeler <daniel.wheeler@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Stable-dep-of: cdff36a0
      
       ("drm/amd/display: fix access hdcp_workqueue assert")
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d90f97cb
    • Song Yoong Siang's avatar
      igc: read before write to SRRCTL register · 48f0671b
      Song Yoong Siang authored
      [ Upstream commit 3ce29c17 ]
      
      igc_configure_rx_ring() function will be called as part of XDP program
      setup. If Rx hardware timestamp is enabled prio to XDP program setup,
      this timestamp enablement will be overwritten when buffer size is
      written into SRRCTL register.
      
      Thus, this commit read the register value before write to SRRCTL
      register. This commit is tested by using xdp_hw_metadata bpf selftest
      tool. The tool enables Rx hardware timestamp and then attach XDP program
      to igc driver. It will display hardware timestamp of UDP packet with
      port number 9092. Below are detail of test steps and results.
      
      Command on DUT:
        sudo ./xdp_hw_metadata <interface name>
      
      Command on Link Partner:
        echo -n skb | nc -u -q1 <destination IPv4 addr> 9092
      
      Result before this patch:
        skb hwtstamp is not found!
      
      Result after this patch:
        found skb hwtstamp = 1677800973.642836757
      
      Optionally, read PHC to confirm the values obtained are almost the same:
      Command:
        sudo ./testptp -d /dev/ptp0 -g
      Result:
        clock time: 1677800973.913598978 or Fri Mar  3 07:49:33 2023
      
      Fixes: fc9df2a0
      
       ("igc: Enable RX via AF_XDP zero-copy")
      Cc: <stable@vger.kernel.org> # 5.14+
      Signed-off-by: default avatarSong Yoong Siang <yoong.siang.song@intel.com>
      Reviewed-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      Reviewed-by: default avatarJesper Dangaard Brouer <brouer@redhat.com>
      Tested-by: default avatarJesper Dangaard Brouer <brouer@redhat.com>
      Tested-by: default avatarNaama Meir <naamax.meir@linux.intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Reviewed-by: default avatarLeon Romanovsky <leonro@nvidia.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      48f0671b
    • Chen Lin's avatar
      ring-buffer: Do not swap cpu_buffer during resize process · 128c06a3
      Chen Lin authored
      [ Upstream commit 8a96c028
      
       ]
      
      When ring_buffer_swap_cpu was called during resize process,
      the cpu buffer was swapped in the middle, resulting in incorrect state.
      Continuing to run in the wrong state will result in oops.
      
      This issue can be easily reproduced using the following two scripts:
      /tmp # cat test1.sh
      //#! /bin/sh
      for i in `seq 0 100000`
      do
               echo 2000 > /sys/kernel/debug/tracing/buffer_size_kb
               sleep 0.5
               echo 5000 > /sys/kernel/debug/tracing/buffer_size_kb
               sleep 0.5
      done
      /tmp # cat test2.sh
      //#! /bin/sh
      for i in `seq 0 100000`
      do
              echo irqsoff > /sys/kernel/debug/tracing/current_tracer
              sleep 1
              echo nop > /sys/kernel/debug/tracing/current_tracer
              sleep 1
      done
      /tmp # ./test1.sh &
      /tmp # ./test2.sh &
      
      A typical oops log is as follows, sometimes with other different oops logs.
      
      [  231.711293] WARNING: CPU: 0 PID: 9 at kernel/trace/ring_buffer.c:2026 rb_update_pages+0x378/0x3f8
      [  231.713375] Modules linked in:
      [  231.714735] CPU: 0 PID: 9 Comm: kworker/0:1 Tainted: G        W          6.5.0-rc1-00276-g20edcec23f92 #15
      [  231.716750] Hardware name: linux,dummy-virt (DT)
      [  231.718152] Workqueue: events update_pages_handler
      [  231.719714] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
      [  231.721171] pc : rb_update_pages+0x378/0x3f8
      [  231.722212] lr : rb_update_pages+0x25c/0x3f8
      [  231.723248] sp : ffff800082b9bd50
      [  231.724169] x29: ffff800082b9bd50 x28: ffff8000825f7000 x27: 0000000000000000
      [  231.726102] x26: 0000000000000001 x25: fffffffffffff010 x24: 0000000000000ff0
      [  231.728122] x23: ffff0000c3a0b600 x22: ffff0000c3a0b5c0 x21: fffffffffffffe0a
      [  231.730203] x20: ffff0000c3a0b600 x19: ffff0000c0102400 x18: 0000000000000000
      [  231.732329] x17: 0000000000000000 x16: 0000000000000000 x15: 0000ffffe7aa8510
      [  231.734212] x14: 0000000000000000 x13: 0000000000000000 x12: 0000000000000002
      [  231.736291] x11: ffff8000826998a8 x10: ffff800082b9baf0 x9 : ffff800081137558
      [  231.738195] x8 : fffffc00030e82c8 x7 : 0000000000000000 x6 : 0000000000000001
      [  231.740192] x5 : ffff0000ffbafe00 x4 : 0000000000000000 x3 : 0000000000000000
      [  231.742118] x2 : 00000000000006aa x1 : 0000000000000001 x0 : ffff0000c0007208
      [  231.744196] Call trace:
      [  231.744892]  rb_update_pages+0x378/0x3f8
      [  231.745893]  update_pages_handler+0x1c/0x38
      [  231.746893]  process_one_work+0x1f0/0x468
      [  231.747852]  worker_thread+0x54/0x410
      [  231.748737]  kthread+0x124/0x138
      [  231.749549]  ret_from_fork+0x10/0x20
      [  231.750434] ---[ end trace 0000000000000000 ]---
      [  233.720486] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
      [  233.721696] Mem abort info:
      [  233.721935]   ESR = 0x0000000096000004
      [  233.722283]   EC = 0x25: DABT (current EL), IL = 32 bits
      [  233.722596]   SET = 0, FnV = 0
      [  233.722805]   EA = 0, S1PTW = 0
      [  233.723026]   FSC = 0x04: level 0 translation fault
      [  233.723458] Data abort info:
      [  233.723734]   ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000
      [  233.724176]   CM = 0, WnR = 0, TnD = 0, TagAccess = 0
      [  233.724589]   GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
      [  233.725075] user pgtable: 4k pages, 48-bit VAs, pgdp=0000000104943000
      [  233.725592] [0000000000000000] pgd=0000000000000000, p4d=0000000000000000
      [  233.726231] Internal error: Oops: 0000000096000004 [#1] PREEMPT SMP
      [  233.726720] Modules linked in:
      [  233.727007] CPU: 0 PID: 9 Comm: kworker/0:1 Tainted: G        W          6.5.0-rc1-00276-g20edcec23f92 #15
      [  233.727777] Hardware name: linux,dummy-virt (DT)
      [  233.728225] Workqueue: events update_pages_handler
      [  233.728655] pstate: 200000c5 (nzCv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
      [  233.729054] pc : rb_update_pages+0x1a8/0x3f8
      [  233.729334] lr : rb_update_pages+0x154/0x3f8
      [  233.729592] sp : ffff800082b9bd50
      [  233.729792] x29: ffff800082b9bd50 x28: ffff8000825f7000 x27: 0000000000000000
      [  233.730220] x26: 0000000000000000 x25: ffff800082a8b840 x24: ffff0000c0102418
      [  233.730653] x23: 0000000000000000 x22: fffffc000304c880 x21: 0000000000000003
      [  233.731105] x20: 00000000000001f4 x19: ffff0000c0102400 x18: ffff800082fcbc58
      [  233.731727] x17: 0000000000000000 x16: 0000000000000001 x15: 0000000000000001
      [  233.732282] x14: ffff8000825fe0c8 x13: 0000000000000001 x12: 0000000000000000
      [  233.732709] x11: ffff8000826998a8 x10: 0000000000000ae0 x9 : ffff8000801b760c
      [  233.733148] x8 : fefefefefefefeff x7 : 0000000000000018 x6 : ffff0000c03298c0
      [  233.733553] x5 : 0000000000000002 x4 : 0000000000000000 x3 : 0000000000000000
      [  233.733972] x2 : ffff0000c3a0b600 x1 : 0000000000000000 x0 : 0000000000000000
      [  233.734418] Call trace:
      [  233.734593]  rb_update_pages+0x1a8/0x3f8
      [  233.734853]  update_pages_handler+0x1c/0x38
      [  233.735148]  process_one_work+0x1f0/0x468
      [  233.735525]  worker_thread+0x54/0x410
      [  233.735852]  kthread+0x124/0x138
      [  233.736064]  ret_from_fork+0x10/0x20
      [  233.736387] Code: 92400000 910006b5 aa000021 aa0303f7 (f9400060)
      [  233.736959] ---[ end trace 0000000000000000 ]---
      
      After analysis, the seq of the error is as follows [1-5]:
      
      int ring_buffer_resize(struct trace_buffer *buffer, unsigned long size,
      			int cpu_id)
      {
      	for_each_buffer_cpu(buffer, cpu) {
      		cpu_buffer = buffer->buffers[cpu];
      		//1. get cpu_buffer, aka cpu_buffer(A)
      		...
      		...
      		schedule_work_on(cpu,
      		 &cpu_buffer->update_pages_work);
      		//2. 'update_pages_work' is queue on 'cpu', cpu_buffer(A) is passed to
      		// update_pages_handler, do the update process, set 'update_done' in
      		// complete(&cpu_buffer->update_done) and to wakeup resize process.
      	//---->
      		//3. Just at this moment, ring_buffer_swap_cpu is triggered,
      		//cpu_buffer(A) be swaped to cpu_buffer(B), the max_buffer.
      		//ring_buffer_swap_cpu is called as the 'Call trace' below.
      
      		Call trace:
      		 dump_backtrace+0x0/0x2f8
      		 show_stack+0x18/0x28
      		 dump_stack+0x12c/0x188
      		 ring_buffer_swap_cpu+0x2f8/0x328
      		 update_max_tr_single+0x180/0x210
      		 check_critical_timing+0x2b4/0x2c8
      		 tracer_hardirqs_on+0x1c0/0x200
      		 trace_hardirqs_on+0xec/0x378
      		 el0_svc_common+0x64/0x260
      		 do_el0_svc+0x90/0xf8
      		 el0_svc+0x20/0x30
      		 el0_sync_handler+0xb0/0xb8
      		 el0_sync+0x180/0x1c0
      	//<----
      
      	/* wait for all the updates to complete */
      	for_each_buffer_cpu(buffer, cpu) {
      		cpu_buffer = buffer->buffers[cpu];
      		//4. get cpu_buffer, cpu_buffer(B) is used in the following process,
      		//the state of cpu_buffer(A) and cpu_buffer(B) is totally wrong.
      		//for example, cpu_buffer(A)->update_done will leave be set 1, and will
      		//not 'wait_for_completion' at the next resize round.
      		  if (!cpu_buffer->nr_pages_to_update)
      			continue;
      
      		if (cpu_online(cpu))
      			wait_for_completion(&cpu_buffer->update_done);
      		cpu_buffer->nr_pages_to_update = 0;
      	}
      	...
      }
      	//5. the state of cpu_buffer(A) and cpu_buffer(B) is totally wrong,
      	//Continuing to run in the wrong state, then oops occurs.
      
      Link: https://lore.kernel.org/linux-trace-kernel/202307191558478409990@zte.com.cn
      
      Signed-off-by: default avatarChen Lin <chen.lin5@zte.com.cn>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      128c06a3
    • Andy Shevchenko's avatar
      Bluetooth: MGMT: Use correct address for memcpy() · 356fe907
      Andy Shevchenko authored
      [ Upstream commit d1f0a981
      
       ]
      
      In function ‘fortify_memcpy_chk’,
          inlined from ‘get_conn_info_complete’ at net/bluetooth/mgmt.c:7281:2:
      include/linux/fortify-string.h:592:25: error: call to
      ‘__read_overflow2_field’ declared with attribute warning: detected read
      beyond size of field (2nd parameter); maybe use struct_group()?
      [-Werror=attribute-warning]
        592 |                         __read_overflow2_field(q_size_field, size);
            |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      cc1: all warnings being treated as errors
      
      This is due to the wrong member is used for memcpy(). Use correct one.
      
      Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      356fe907
    • Benjamin Gray's avatar
      powerpc/kasan: Disable KCOV in KASAN code · a1ceb871
      Benjamin Gray authored
      [ Upstream commit ccb381e1
      
       ]
      
      As per the generic KASAN code in mm/kasan, disable KCOV with
      KCOV_INSTRUMENT := n in the makefile.
      
      This fixes a ppc64 boot hang when KCOV and KASAN are enabled.
      kasan_early_init() gets called before a PACA is initialised, but the
      KCOV hook expects a valid PACA.
      
      Suggested-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
      Signed-off-by: default avatarBenjamin Gray <bgray@linux.ibm.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://msgid.link/20230710044143.146840-1-bgray@linux.ibm.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a1ceb871
    • Luke D. Jones's avatar
      ALSA: hda/realtek: Add quirk for ASUS ROG GZ301V · 6d06cf0f
      Luke D. Jones authored
      [ Upstream commit 5251605f
      
       ]
      
      Adds the required quirk to enable the Cirrus amp and correct pins
      on the ASUS ROG GZ301V series which uses an SPI connected Cirrus amp.
      
      While this works if the related _DSD properties are made available, these
      aren't included in the ACPI of these laptops (yet).
      
      Signed-off-by: default avatarLuke D. Jones <luke@ljones.dev>
      Link: https://lore.kernel.org/r/20230706223323.30871-2-luke@ljones.dev
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6d06cf0f
    • Luke D. Jones's avatar
      ALSA: hda/realtek: Add quirk for ASUS ROG GA402X · 2b248cf8
      Luke D. Jones authored
      [ Upstream commit 9abc77fb
      
       ]
      
      Adds the required quirk to enable the Cirrus amp and correct pins
      on the ASUS ROG GA402X series which uses an I2C connected Cirrus amp.
      
      While this works if the related _DSD properties are made available, these
      aren't included in the ACPI of these laptops (yet).
      
      Signed-off-by: default avatarLuke D. Jones <luke@ljones.dev>
      Link: https://lore.kernel.org/r/20230704044619.19343-3-luke@ljones.dev
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2b248cf8
    • Luke D. Jones's avatar
      ALSA: hda/realtek: Add quirk for ASUS ROG GX650P · c48616e5
      Luke D. Jones authored
      [ Upstream commit 8cc87c05
      
       ]
      
      Adds the required quirk to enable the Cirrus amp and correct pins
      on the ASUS ROG GV601V series which uses an I2C connected Cirrus amp.
      
      While this works if the related _DSD properties are made available, these
      aren't included in the ACPI of these laptops (yet).
      
      Signed-off-by: default avatarLuke D. Jones <luke@ljones.dev>
      Link: https://lore.kernel.org/r/20230704044619.19343-2-luke@ljones.dev
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c48616e5
    • Tuo Li's avatar
      ALSA: hda: fix a possible null-pointer dereference due to data race in snd_hdac_regmap_sync() · cdd412b5
      Tuo Li authored
      [ Upstream commit 1f4a08fe
      
       ]
      
      The variable codec->regmap is often protected by the lock
      codec->regmap_lock when is accessed. However, it is accessed without
      holding the lock when is accessed in snd_hdac_regmap_sync():
      
        if (codec->regmap)
      
      In my opinion, this may be a harmful race, because if codec->regmap is
      set to NULL right after the condition is checked, a null-pointer
      dereference can occur in the called function regcache_sync():
      
        map->lock(map->lock_arg); --> Line 360 in drivers/base/regmap/regcache.c
      
      To fix this possible null-pointer dereference caused by data race, the
      mutex_lock coverage is extended to protect the if statement as well as the
      function call to regcache_sync().
      
      [ Note: the lack of the regmap_lock itself is harmless for the current
        codec driver implementations, as snd_hdac_regmap_sync() is only for
        PM runtime resume that is prohibited during the codec probe.
        But the change makes the whole code more consistent, so it's merged
        as is -- tiwai ]
      
      Reported-by: default avatarBassCheck <bass@buaa.edu.cn>
      Signed-off-by: default avatarTuo Li <islituo@gmail.com>
      Link: https://lore.kernel.org/r/20230703031016.1184711-1-islituo@gmail.com
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      cdd412b5
    • dengxiang's avatar
      ALSA: hda/realtek: Add quirks for Unis H3C Desktop B760 & Q760 · 63e0b5d7
      dengxiang authored
      [ Upstream commit 73f1c75d
      
       ]
      
      These models use NSIWAY amplifiers for internal speaker, but cannot put
      sound outside from these amplifiers. So eapd verbs are needed to initialize
      the amplifiers. They can be added during boot to get working sound out
      of internal speaker.
      
      Signed-off-by: default avatardengxiang <dengxiang@nfschina.com>
      Link: https://lore.kernel.org/r/20230703021751.2945750-1-dengxiang@nfschina.com
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      63e0b5d7
    • Konstantin Komarov's avatar
    • Jia-Ju Bai's avatar
      fs: ntfs3: Fix possible null-pointer dereferences in mi_read() · 1e220556
      Jia-Ju Bai authored
      [ Upstream commit 97498cd6 ]
      
      In a previous commit 2681631c
      
       ("fs/ntfs3: Add null pointer check to
      attr_load_runs_vcn"), ni can be NULL in attr_load_runs_vcn(), and thus it
      should be checked before being used.
      
      However, in the call stack of this commit, mft_ni in mi_read() is
      aliased with ni in attr_load_runs_vcn(), and it is also used in
      mi_read() at two places:
      
      mi_read()
        rw_lock = &mft_ni->file.run_lock -> No check
        attr_load_runs_vcn(mft_ni, ...)
          ni (namely mft_ni) is checked in the previous commit
        attr_load_runs_vcn(..., &mft_ni->file.run) -> No check
      
      Thus, to avoid possible null-pointer dereferences, the related checks
      should be added.
      
      These bugs are reported by a static analysis tool implemented by myself,
      and they are found by extending a known bug fixed in the previous commit.
      Thus, they could be theoretical bugs.
      
      Signed-off-by: default avatarJia-Ju Bai <baijiaju@buaa.edu.cn>
      Signed-off-by: default avatarKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1e220556
    • Edward Lo's avatar
      fs/ntfs3: Enhance sanity check while generating attr_list · 4246bbef
      Edward Lo authored
      [ Upstream commit fdec309c
      
       ]
      
      ni_create_attr_list uses WARN_ON to catch error cases while generating
      attribute list, which only prints out stack trace and may not be enough.
      This repalces them with more proper error handling flow.
      
      [   59.666332] BUG: kernel NULL pointer dereference, address: 000000000000000e
      [   59.673268] #PF: supervisor read access in kernel mode
      [   59.678354] #PF: error_code(0x0000) - not-present page
      [   59.682831] PGD 8000000005ff1067 P4D 8000000005ff1067 PUD 7dee067 PMD 0
      [   59.688556] Oops: 0000 [#1] PREEMPT SMP KASAN PTI
      [   59.692642] CPU: 0 PID: 198 Comm: poc Tainted: G    B   W          6.2.0-rc1+ #4
      [   59.698868] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014
      [   59.708795] RIP: 0010:ni_create_attr_list+0x505/0x860
      [   59.713657] Code: 7e 10 e8 5e d0 d0 ff 45 0f b7 76 10 48 8d 7b 16 e8 00 d1 d0 ff 66 44 89 73 16 4d 8d 75 0e 4c 89 f7 e8 3f d0 d0 ff 4c 8d8
      [   59.731559] RSP: 0018:ffff88800a56f1e0 EFLAGS: 00010282
      [   59.735691] RAX: 0000000000000001 RBX: ffff88800b7b5088 RCX: ffffffffb83079fe
      [   59.741792] RDX: 0000000000000001 RSI: 0000000000000008 RDI: ffffffffbb7f9fc0
      [   59.748423] RBP: ffff88800a56f3a8 R08: ffff88800b7b50a0 R09: fffffbfff76ff3f9
      [   59.754654] R10: ffffffffbb7f9fc7 R11: fffffbfff76ff3f8 R12: ffff88800b756180
      [   59.761552] R13: 0000000000000000 R14: 000000000000000e R15: 0000000000000050
      [   59.768323] FS:  00007feaa8c96440(0000) GS:ffff88806d400000(0000) knlGS:0000000000000000
      [   59.776027] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [   59.781395] CR2: 00007f3a2e0b1000 CR3: 000000000a5bc000 CR4: 00000000000006f0
      [   59.787607] Call Trace:
      [   59.790271]  <TASK>
      [   59.792488]  ? __pfx_ni_create_attr_list+0x10/0x10
      [   59.797235]  ? kernel_text_address+0xd3/0xe0
      [   59.800856]  ? unwind_get_return_address+0x3e/0x60
      [   59.805101]  ? __kasan_check_write+0x18/0x20
      [   59.809296]  ? preempt_count_sub+0x1c/0xd0
      [   59.813421]  ni_ins_attr_ext+0x52c/0x5c0
      [   59.817034]  ? __pfx_ni_ins_attr_ext+0x10/0x10
      [   59.821926]  ? __vfs_setxattr+0x121/0x170
      [   59.825718]  ? __vfs_setxattr_noperm+0x97/0x300
      [   59.829562]  ? __vfs_setxattr_locked+0x145/0x170
      [   59.833987]  ? vfs_setxattr+0x137/0x2a0
      [   59.836732]  ? do_setxattr+0xce/0x150
      [   59.839807]  ? setxattr+0x126/0x140
      [   59.842353]  ? path_setxattr+0x164/0x180
      [   59.845275]  ? __x64_sys_setxattr+0x71/0x90
      [   59.848838]  ? do_syscall_64+0x3f/0x90
      [   59.851898]  ? entry_SYSCALL_64_after_hwframe+0x72/0xdc
      [   59.857046]  ? stack_depot_save+0x17/0x20
      [   59.860299]  ni_insert_attr+0x1ba/0x420
      [   59.863104]  ? __pfx_ni_insert_attr+0x10/0x10
      [   59.867069]  ? preempt_count_sub+0x1c/0xd0
      [   59.869897]  ? _raw_spin_unlock_irqrestore+0x2b/0x50
      [   59.874088]  ? __create_object+0x3ae/0x5d0
      [   59.877865]  ni_insert_resident+0xc4/0x1c0
      [   59.881430]  ? __pfx_ni_insert_resident+0x10/0x10
      [   59.886355]  ? kasan_save_alloc_info+0x1f/0x30
      [   59.891117]  ? __kasan_kmalloc+0x8b/0xa0
      [   59.894383]  ntfs_set_ea+0x90d/0xbf0
      [   59.897703]  ? __pfx_ntfs_set_ea+0x10/0x10
      [   59.901011]  ? kernel_text_address+0xd3/0xe0
      [   59.905308]  ? __kernel_text_address+0x16/0x50
      [   59.909811]  ? unwind_get_return_address+0x3e/0x60
      [   59.914898]  ? __pfx_stack_trace_consume_entry+0x10/0x10
      [   59.920250]  ? arch_stack_walk+0xa2/0x100
      [   59.924560]  ? filter_irq_stacks+0x27/0x80
      [   59.928722]  ntfs_setxattr+0x405/0x440
      [   59.932512]  ? __pfx_ntfs_setxattr+0x10/0x10
      [   59.936634]  ? kvmalloc_node+0x2d/0x120
      [   59.940378]  ? kasan_save_stack+0x41/0x60
      [   59.943870]  ? kasan_save_stack+0x2a/0x60
      [   59.947719]  ? kasan_set_track+0x29/0x40
      [   59.951417]  ? kasan_save_alloc_info+0x1f/0x30
      [   59.955733]  ? __kasan_kmalloc+0x8b/0xa0
      [   59.959598]  ? __kmalloc_node+0x68/0x150
      [   59.963163]  ? kvmalloc_node+0x2d/0x120
      [   59.966490]  ? vmemdup_user+0x2b/0xa0
      [   59.969060]  __vfs_setxattr+0x121/0x170
      [   59.972456]  ? __pfx___vfs_setxattr+0x10/0x10
      [   59.976008]  __vfs_setxattr_noperm+0x97/0x300
      [   59.981562]  __vfs_setxattr_locked+0x145/0x170
      [   59.986100]  vfs_setxattr+0x137/0x2a0
      [   59.989964]  ? __pfx_vfs_setxattr+0x10/0x10
      [   59.993616]  ? __kasan_check_write+0x18/0x20
      [   59.997425]  do_setxattr+0xce/0x150
      [   60.000304]  setxattr+0x126/0x140
      [   60.002967]  ? __pfx_setxattr+0x10/0x10
      [   60.006471]  ? __virt_addr_valid+0xcb/0x140
      [   60.010461]  ? __call_rcu_common.constprop.0+0x1c7/0x330
      [   60.016037]  ? debug_smp_processor_id+0x1b/0x30
      [   60.021008]  ? kasan_quarantine_put+0x5b/0x190
      [   60.025545]  ? putname+0x84/0xa0
      [   60.027910]  ? __kasan_slab_free+0x11e/0x1b0
      [   60.031483]  ? putname+0x84/0xa0
      [   60.033986]  ? preempt_count_sub+0x1c/0xd0
      [   60.036876]  ? __mnt_want_write+0xae/0x100
      [   60.040738]  ? mnt_want_write+0x8f/0x150
      [   60.044317]  path_setxattr+0x164/0x180
      [   60.048096]  ? __pfx_path_setxattr+0x10/0x10
      [   60.052096]  ? strncpy_from_user+0x175/0x1c0
      [   60.056482]  ? debug_smp_processor_id+0x1b/0x30
      [   60.059848]  ? fpregs_assert_state_consistent+0x6b/0x80
      [   60.064557]  __x64_sys_setxattr+0x71/0x90
      [   60.068892]  do_syscall_64+0x3f/0x90
      [   60.072868]  entry_SYSCALL_64_after_hwframe+0x72/0xdc
      [   60.077523] RIP: 0033:0x7feaa86e4469
      [   60.080915] Code: 00 f3 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 088
      [   60.097353] RSP: 002b:00007ffdbd8311e8 EFLAGS: 00000286 ORIG_RAX: 00000000000000bc
      [   60.103386] RAX: ffffffffffffffda RBX: 9461c5e290baac00 RCX: 00007feaa86e4469
      [   60.110322] RDX: 00007ffdbd831fe0 RSI: 00007ffdbd831305 RDI: 00007ffdbd831263
      [   60.116808] RBP: 00007ffdbd836180 R08: 0000000000000001 R09: 00007ffdbd836268
      [   60.123879] R10: 000000000000007d R11: 0000000000000286 R12: 0000000000400500
      [   60.130540] R13: 00007ffdbd836260 R14: 0000000000000000 R15: 0000000000000000
      [   60.136553]  </TASK>
      [   60.138818] Modules linked in:
      [   60.141839] CR2: 000000000000000e
      [   60.144831] ---[ end trace 0000000000000000 ]---
      [   60.149058] RIP: 0010:ni_create_attr_list+0x505/0x860
      [   60.153975] Code: 7e 10 e8 5e d0 d0 ff 45 0f b7 76 10 48 8d 7b 16 e8 00 d1 d0 ff 66 44 89 73 16 4d 8d 75 0e 4c 89 f7 e8 3f d0 d0 ff 4c 8d8
      [   60.172443] RSP: 0018:ffff88800a56f1e0 EFLAGS: 00010282
      [   60.176246] RAX: 0000000000000001 RBX: ffff88800b7b5088 RCX: ffffffffb83079fe
      [   60.182752] RDX: 0000000000000001 RSI: 0000000000000008 RDI: ffffffffbb7f9fc0
      [   60.189949] RBP: ffff88800a56f3a8 R08: ffff88800b7b50a0 R09: fffffbfff76ff3f9
      [   60.196950] R10: ffffffffbb7f9fc7 R11: fffffbfff76ff3f8 R12: ffff88800b756180
      [   60.203671] R13: 0000000000000000 R14: 000000000000000e R15: 0000000000000050
      [   60.209595] FS:  00007feaa8c96440(0000) GS:ffff88806d400000(0000) knlGS:0000000000000000
      [   60.216299] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [   60.222276] CR2: 00007f3a2e0b1000 CR3: 000000000a5bc000 CR4: 00000000000006f0
      
      Signed-off-by: default avatarEdward Lo <loyuantsung@gmail.com>
      Signed-off-by: default avatarKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4246bbef
    • shanzhulig's avatar
      drm/amdgpu: Fix potential fence use-after-free v2 · dd0b3b36
      shanzhulig authored
      [ Upstream commit 2e54154b
      
       ]
      
      fence Decrements the reference count before exiting.
      Avoid Race Vulnerabilities for fence use-after-free.
      
      v2 (chk): actually fix the use after free and not just move it.
      
      Signed-off-by: default avatarshanzhulig <shanzhulig@gmail.com>
      Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
      Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      dd0b3b36
    • Xiubo Li's avatar
      ceph: try to dump the msgs when decoding fails · 3a89f3bf
      Xiubo Li authored
      [ Upstream commit 8b0da5c5
      
       ]
      
      When the msgs are corrupted we need to dump them and then it will
      be easier to dig what has happened and where the issue is.
      
      Signed-off-by: default avatarXiubo Li <xiubli@redhat.com>
      Reviewed-by: default avatarMilind Changire <mchangir@redhat.com>
      Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3a89f3bf
    • Matthew Anderson's avatar
      Bluetooth: btusb: Add MT7922 bluetooth ID for the Asus Ally · d92613aa
      Matthew Anderson authored
      [ Upstream commit fa01eba1
      
       ]
      
      Adding the device ID from the Asus Ally gets the bluetooth working
      on the device.
      
      Signed-off-by: default avatarMatthew Anderson <ruinairas1992@gmail.com>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d92613aa
    • Zhengping Jiang's avatar
      Bluetooth: L2CAP: Fix use-after-free · 149daab4
      Zhengping Jiang authored
      [ Upstream commit f752a0b3
      
       ]
      
      Fix potential use-after-free in l2cap_le_command_rej.
      
      Signed-off-by: default avatarZhengping Jiang <jiangzp@google.com>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      149daab4
    • Yuechao Zhao's avatar
      watchdog: sp5100_tco: support Hygon FCH/SCH (Server Controller Hub) · de8677cc
      Yuechao Zhao authored
      [ Upstream commit 009637de
      
       ]
      
      Add PCI_VENDOR_ID_HYGON(Hygon vendor id [0x1d94]) in this driver
      
      Signed-off-by: default avatarYuechao Zhao <yuechao.zhao@advantech.com.cn>
      Reviewed-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Link: https://lkml.kernel.org/r/20230612031907.796461-1-a345351830@gmail.com
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarWim Van Sebroeck <wim@linux-watchdog.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      de8677cc
    • Zhang Shurong's avatar
      firewire: net: fix use after free in fwnet_finish_incoming_packet() · 9040adc3
      Zhang Shurong authored
      [ Upstream commit 3ff25675
      
       ]
      
      The netif_rx() function frees the skb so we can't dereference it to
      save the skb->len.
      
      Signed-off-by: default avatarZhang Shurong <zhang_shurong@foxmail.com>
      Link: https://lore.kernel.org/r/tencent_3B3D24B66ED66A6BB73CC0E63C6A14E45109@qq.com
      Signed-off-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9040adc3
    • Mika Westerberg's avatar
      thunderbolt: Limit Intel Barlow Ridge USB3 bandwidth · ef87750c
      Mika Westerberg authored
      [ Upstream commit f2bfa944
      
       ]
      
      Intel Barlow Ridge discrete USB4 host router has the same limitation as
      the previous generations so make sure the USB3 bandwidth limitation
      quirk is applied to Barlow Ridge too.
      
      Signed-off-by: default avatarGil Fine <gil.fine@linux.intel.com>
      Signed-off-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ef87750c
    • Mika Westerberg's avatar
      thunderbolt: Add Intel Barlow Ridge PCI ID · acb9038e
      Mika Westerberg authored
      [ Upstream commit 6f14a210
      
       ]
      
      Intel Barlow Ridge is the first USB4 v2 controller from Intel. The
      controller exposes standard USB4 PCI class ID in typical configurations,
      however there is a way to configure it so that it uses a special class
      ID to allow using s different driver than the Windows inbox one. For
      this reason add the Barlow Ridge PCI ID to the Linux driver too so that
      the driver can attach regardless of the class ID.
      
      Tested-by: default avatarPengfei Xu <pengfei.xu@intel.com>
      Signed-off-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      acb9038e
    • Armin Wolf's avatar
      pcmcia: rsrc_nonstatic: Fix memory leak in nonstatic_release_resource_db() · e8a80cf0
      Armin Wolf authored
      [ Upstream commit c85fd942
      
       ]
      
      When nonstatic_release_resource_db() frees all resources associated
      with an PCMCIA socket, it forgets to free socket_data too, causing
      a memory leak observable with kmemleak:
      
      unreferenced object 0xc28d1000 (size 64):
        comm "systemd-udevd", pid 297, jiffies 4294898478 (age 194.484s)
        hex dump (first 32 bytes):
          00 00 00 00 00 00 00 00 f0 85 0e c3 00 00 00 00  ................
          00 00 00 00 0c 10 8d c2 00 00 00 00 00 00 00 00  ................
        backtrace:
          [<ffda4245>] __kmem_cache_alloc_node+0x2d7/0x4a0
          [<7e51f0c8>] kmalloc_trace+0x31/0xa4
          [<d52b4ca0>] nonstatic_init+0x24/0x1a4 [pcmcia_rsrc]
          [<a2f13e08>] pcmcia_register_socket+0x200/0x35c [pcmcia_core]
          [<a728be1b>] yenta_probe+0x4d8/0xa70 [yenta_socket]
          [<c48fac39>] pci_device_probe+0x99/0x194
          [<84b7c690>] really_probe+0x181/0x45c
          [<8060fe6e>] __driver_probe_device+0x75/0x1f4
          [<b9b76f43>] driver_probe_device+0x28/0xac
          [<648b766f>] __driver_attach+0xeb/0x1e4
          [<6e9659eb>] bus_for_each_dev+0x61/0xb4
          [<25a669f3>] driver_attach+0x1e/0x28
          [<d8671d6b>] bus_add_driver+0x102/0x20c
          [<df0d323c>] driver_register+0x5b/0x120
          [<942cd8a4>] __pci_register_driver+0x44/0x4c
          [<e536027e>] __UNIQUE_ID___addressable_cleanup_module188+0x1c/0xfffff000 [iTCO_vendor_support]
      
      Fix this by freeing socket_data too.
      
      Tested on a Acer Travelmate 4002WLMi by manually binding/unbinding
      the yenta_cardbus driver (yenta_socket).
      
      Signed-off-by: default avatarArmin Wolf <W_Armin@gmx.de>
      Message-ID: <20230512184529.5094-1-W_Armin@gmx.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e8a80cf0
    • Tuo Li's avatar
      gfs2: Fix possible data races in gfs2_show_options() · a4f71523
      Tuo Li authored
      [ Upstream commit 6fa0a72c
      
       ]
      
      Some fields such as gt_logd_secs of the struct gfs2_tune are accessed
      without holding the lock gt_spin in gfs2_show_options():
      
        val = sdp->sd_tune.gt_logd_secs;
        if (val != 30)
          seq_printf(s, ",commit=%d", val);
      
      And thus can cause data races when gfs2_show_options() and other functions
      such as gfs2_reconfigure() are concurrently executed:
      
        spin_lock(&gt->gt_spin);
        gt->gt_logd_secs = newargs->ar_commit;
      
      To fix these possible data races, the lock sdp->sd_tune.gt_spin is
      acquired before accessing the fields of gfs2_tune and released after these
      accesses.
      
      Further changes by Andreas:
      
      - Don't hold the spin lock over the seq_printf operations.
      
      Reported-by: default avatarBassCheck <bass@buaa.edu.cn>
      Signed-off-by: default avatarTuo Li <islituo@gmail.com>
      Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a4f71523
    • Xu Yang's avatar
      usb: chipidea: imx: add missing USB PHY DPDM wakeup setting · 8277a215
      Xu Yang authored
      [ Upstream commit 53d061c1
      
       ]
      
      USB PHY DPDM wakeup bit is enabled by default, when USB wakeup
      is not required(/sys/.../wakeup is disabled), this bit should be
      disabled, otherwise we will have unexpected wakeup if do USB device
      connect/disconnect while system sleep.
      This bit can be enabled for both host and device mode.
      
      Signed-off-by: default avatarLi Jun <jun.li@nxp.com>
      Signed-off-by: default avatarXu Yang <xu.yang_2@nxp.com>
      Acked-by: default avatarPeter Chen <peter.chen@kernel.org>
      Message-ID: <20230517081907.3410465-3-xu.yang_2@nxp.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8277a215
    • Xu Yang's avatar
      usb: chipidea: imx: don't request QoS for imx8ulp · 31f8efef
      Xu Yang authored
      [ Upstream commit 9a070e8e
      
       ]
      
      Use dedicated imx8ulp usb compatible to remove QoS request
      since imx8ulp has no such limitation of imx7ulp: DMA will
      not work if system enters idle.
      
      Signed-off-by: default avatarXu Yang <xu.yang_2@nxp.com>
      Signed-off-by: default avatarLi Jun <jun.li@nxp.com>
      Acked-by: default avatarPeter Chen <peter.chen@kernel.org>
      Message-ID: <20230530104007.1294702-2-xu.yang_2@nxp.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      31f8efef
    • Mika Westerberg's avatar
      thunderbolt: Read retimer NVM authentication status prior tb_retimer_set_inbound_sbtx() · 809625f4
      Mika Westerberg authored
      [ Upstream commit 1402ba08
      
       ]
      
      According to the USB4 retimer guide the correct order is immediately
      after sending ENUMERATE_RETIMERS so update the code to follow this.
      
      Signed-off-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      809625f4
    • Hans Verkuil's avatar
      media: platform: mediatek: vpu: fix NULL ptr dereference · b7bd48f0
      Hans Verkuil authored
      [ Upstream commit 3df55cd7
      
       ]
      
      If pdev is NULL, then it is still dereferenced.
      
      This fixes this smatch warning:
      
      drivers/media/platform/mediatek/vpu/mtk_vpu.c:570 vpu_load_firmware() warn: address of NULL pointer 'pdev'
      
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Cc: Yunfei Dong <yunfei.dong@mediatek.com>
      Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b7bd48f0
    • Avichal Rakesh's avatar
      usb: gadget: uvc: queue empty isoc requests if no video buffer is available · 28d90083
      Avichal Rakesh authored
      [ Upstream commit c3ff12a9
      
       ]
      
      ISOC transfers expect a certain cadence of requests being queued. Not
      keeping up with the expected rate of requests results in missed ISOC
      transfers (EXDEV). The application layer may or may not produce video
      frames to match this expectation, so uvc gadget driver must handle cases
      where the application is not queuing up buffers fast enough to fulfill
      ISOC requirements.
      
      Currently, uvc gadget driver waits for new video buffer to become available
      before queuing up usb requests. With this patch the gadget driver queues up
      0 length usb requests whenever there are no video buffers available. The
      USB controller's complete callback is used as the limiter for how quickly
      the 0 length packets will be queued. Video buffers are still queued as
      soon as they become available.
      
      Link: https://lore.kernel.org/CAMHf4WKbi6KBPQztj9FA4kPvESc1fVKrC8G73-cs6tTeQby9=w@mail.gmail.com/
      Signed-off-by: default avatarAvichal Rakesh <arakesh@google.com>
      Link: https://lore.kernel.org/r/20230508231103.1621375-1-arakesh@google.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      28d90083
    • Prashanth K's avatar
      usb: gadget: u_serial: Avoid spinlock recursion in __gs_console_push · 49038877
      Prashanth K authored
      [ Upstream commit e5990469
      
       ]
      
      When serial console over USB is enabled, gs_console_connect
      queues gs_console_work, where it acquires the spinlock and
      queues the usb request, and this request goes to gadget layer.
      Now consider a situation where gadget layer prints something
      to dmesg, this will eventually call gs_console_write() which
      requires cons->lock. And this causes spinlock recursion. Avoid
      this by excluding usb_ep_queue from the spinlock.
      
       spin_lock_irqsave //needs cons->lock
       gs_console_write
      	.
      	.
       _printk
       __warn_printk
       dev_warn/pr_err
      	.
      	.
       [USB Gadget Layer]
      	.
      	.
       usb_ep_queue
       gs_console_work
       __gs_console_push // acquires cons->lock
       process_one_work
      
      Signed-off-by: default avatarPrashanth K <quic_prashk@quicinc.com>
      Link: https://lore.kernel.org/r/1683638872-6885-1-git-send-email-quic_prashk@quicinc.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      49038877
    • Andrey Konovalov's avatar
      media: camss: set VFE bpl_alignment to 16 for sdm845 and sm8250 · 54a55c34
      Andrey Konovalov authored
      [ Upstream commit d5b7eb47
      
       ]
      
      From the experiments with camera sensors using SGRBG10_1X10/3280x2464 and
      SRGGB10_1X10/3280x2464 formats, it becomes clear that on sdm845 and sm8250
      VFE outputs the lines padded to a length multiple of 16 bytes. As in the
      current driver the value of the bpl_alignment is set to 8 bytes, the frames
      captured in formats with the bytes-per-line value being not a multiple of
      16 get corrupted.
      
      Set the bpl_alignment of the camss video output device to 16 for sdm845 and
      sm8250 to fix that.
      
      Signed-off-by: default avatarAndrey Konovalov <andrey.konovalov@linaro.org>
      Tested-by: default avatarBryan O'Donoghue <bryan.odonoghue@linaro.org>
      Acked-by: default avatarBryan O'Donoghue <bryan.odonoghue@linaro.org>
      Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      54a55c34