Skip to content
  1. Sep 15, 2022
    • Bart Van Assche's avatar
      nvmet: fix a use-after-free · ebf46da5
      Bart Van Assche authored
      commit 6a02a61e upstream.
      
      Fix the following use-after-free complaint triggered by blktests nvme/004:
      
      BUG: KASAN: user-memory-access in blk_mq_complete_request_remote+0xac/0x350
      Read of size 4 at addr 0000607bd1835943 by task kworker/13:1/460
      Workqueue: nvmet-wq nvme_loop_execute_work [nvme_loop]
      Call Trace:
       show_stack+0x52/0x58
       dump_stack_lvl+0x49/0x5e
       print_report.cold+0x36/0x1e2
       kasan_report+0xb9/0xf0
       __asan_load4+0x6b/0x80
       blk_mq_complete_request_remote+0xac/0x350
       nvme_loop_queue_response+0x1df/0x275 [nvme_loop]
       __nvmet_req_complete+0x132/0x4f0 [nvmet]
       nvmet_req_complete+0x15/0x40 [nvmet]
       nvmet_execute_io_connect+0x18a/0x1f0 [nvmet]
       nvme_loop_execute_work+0x20/0x30 [nvme_loop]
       process_one_work+0x56e/0xa70
       worker_thread+0x2d1/0x640
       kthread+0x183/0x1c0
       ret_from_fork+0x1f/0x30
      
      Cc: stable@vger.kernel.org
      Fixes: a07b4970
      
       ("nvmet: add a generic NVMe target")
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ebf46da5
    • Greg Kroah-Hartman's avatar
      drm/amd/display: fix memory leak when using debugfs_lookup() · 58acd2eb
      Greg Kroah-Hartman authored
      commit cbfac7fa
      
       upstream.
      
      When calling debugfs_lookup() the result must have dput() called on it,
      otherwise the memory will leak over time.  Fix this up by properly
      calling dput().
      
      Cc: Harry Wentland <harry.wentland@amd.com>
      Cc: Leo Li <sunpeng.li@amd.com>
      Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
      Cc: Alex Deucher <alexander.deucher@amd.com>
      Cc: "Christian König" <christian.koenig@amd.com>
      Cc: "Pan, Xinhui" <Xinhui.Pan@amd.com>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Daniel Vetter <daniel@ffwll.ch>
      Cc: Wayne Lin <Wayne.Lin@amd.com>
      Cc: hersen wu <hersenxs.wu@amd.com>
      Cc: Wenjing Liu <wenjing.liu@amd.com>
      Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
      Cc: Thelford Williams <tdwilliamsiv@gmail.com>
      Cc: Fangzhi Zuo <Jerry.Zuo@amd.com>
      Cc: Yongzhi Liu <lyz_cs@pku.edu.cn>
      Cc: Mikita Lipski <mikita.lipski@amd.com>
      Cc: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
      Cc: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
      Cc: Sean Paul <seanpaul@chromium.org>
      Cc: amd-gfx@lists.freedesktop.org
      Cc: dri-devel@lists.freedesktop.org
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarRodrigo Siqueira <Rodrigo.Siqueira@amd.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarRodrigo Siqueira <Rodrigo.Siqueira@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      58acd2eb
    • Greg Kroah-Hartman's avatar
      sched/debug: fix dentry leak in update_sched_domain_debugfs · 26e9a1de
      Greg Kroah-Hartman authored
      commit c2e40659
      
       upstream.
      
      Kuyo reports that the pattern of using debugfs_remove(debugfs_lookup())
      leaks a dentry and with a hotplug stress test, the machine eventually
      runs out of memory.
      
      Fix this up by using the newly created debugfs_lookup_and_remove() call
      instead which properly handles the dentry reference counting logic.
      
      Cc: Major Chen <major.chen@samsung.com>
      Cc: stable <stable@kernel.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Juri Lelli <juri.lelli@redhat.com>
      Cc: Vincent Guittot <vincent.guittot@linaro.org>
      Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Ben Segall <bsegall@google.com>
      Cc: Mel Gorman <mgorman@suse.de>
      Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
      Cc: Valentin Schneider <vschneid@redhat.com>
      Cc: Matthias Brugger <matthias.bgg@gmail.com>
      Reported-by: default avatarKuyo Chang <kuyo.chang@mediatek.com>
      Tested-by: default avatarKuyo Chang <kuyo.chang@mediatek.com>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20220902123107.109274-2-gregkh@linuxfoundation.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      26e9a1de
    • Greg Kroah-Hartman's avatar
      debugfs: add debugfs_lookup_and_remove() · 94c84128
      Greg Kroah-Hartman authored
      commit dec9b2f1
      
       upstream.
      
      There is a very common pattern of using
      debugfs_remove(debufs_lookup(..)) which results in a dentry leak of the
      dentry that was looked up.  Instead of having to open-code the correct
      pattern of calling dput() on the dentry, create
      debugfs_lookup_and_remove() to handle this pattern automatically and
      properly without any memory leaks.
      
      Cc: stable <stable@kernel.org>
      Reported-by: default avatarKuyo Chang <kuyo.chang@mediatek.com>
      Tested-by: default avatarKuyo Chang <kuyo.chang@mediatek.com>
      Link: https://lore.kernel.org/r/YxIaQ8cSinDR881k@kroah.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      94c84128
    • Christian A. Ehrhardt's avatar
      kprobes: Prohibit probes in gate area · 8875d606
      Christian A. Ehrhardt authored
      commit 1efda38d upstream.
      
      The system call gate area counts as kernel text but trying
      to install a kprobe in this area fails with an Oops later on.
      To fix this explicitly disallow the gate area for kprobes.
      
      Found by syzkaller with the following reproducer:
      perf_event_open$cgroup(&(0x7f00000001c0)={0x6, 0x80, 0x0, 0x0, 0x0, 0x0, 0x80ffff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, @perf_config_ext={0x0, 0xffffffffff600000}}, 0xffffffffffffffff, 0x0, 0xffffffffffffffff, 0x0)
      
      Sample report:
      BUG: unable to handle page fault for address: fffffbfff3ac6000
      PGD 6dfcb067 P4D 6dfcb067 PUD 6df8f067 PMD 6de4d067 PTE 0
      Oops: 0000 [#1] PREEMPT SMP KASAN NOPTI
      CPU: 0 PID: 21978 Comm: syz-executor.2 Not tainted 6.0.0-rc3-00363-g7726d4c3e60b-dirty #6
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
      RIP: 0010:__insn_get_emulate_prefix arch/x86/lib/insn.c:91 [inline]
      RIP: 0010:insn_get_emulate_prefix arch/x86/lib/insn.c:106 [inline]
      RIP: 0010:insn_get_prefixes.part.0+0xa8/0x1110 arch/x86/lib/insn.c:134
      Code: 49 be 00 00 00 00 00 fc ff df 48 8b 40 60 48 89 44 24 08 e9 81 00 00 00 e8 e5 4b 39 ff 4c 89 fa 4c 89 f9 48 c1 ea 03 83 e1 07 <42> 0f b6 14 32 38 ca 7f 08 84 d2 0f 85 06 10 00 00 48 89 d8 48 89
      RSP: 0018:ffffc900088bf860 EFLAGS: 00010246
      RAX: 0000000000040000 RBX: ffffffff9b9bebc0 RCX: 0000000000000000
      RDX: 1ffffffff3ac6000 RSI: ffffc90002d82000 RDI: ffffc900088bf9e8
      RBP: ffffffff9d630001 R08: 0000000000000000 R09: ffffc900088bf9e8
      R10: 0000000000000000 R11: 0000000000000001 R12: 0000000000000001
      R13: ffffffff9d630000 R14: dffffc0000000000 R15: ffffffff9d630000
      FS:  00007f63eef63640(0000) GS:ffff88806d000000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: fffffbfff3ac6000 CR3: 0000000029d90005 CR4: 0000000000770ef0
      PKRU: 55555554
      Call Trace:
       <TASK>
       insn_get_prefixes arch/x86/lib/insn.c:131 [inline]
       insn_get_opcode arch/x86/lib/insn.c:272 [inline]
       insn_get_modrm+0x64a/0x7b0 arch/x86/lib/insn.c:343
       insn_get_sib+0x29a/0x330 arch/x86/lib/insn.c:421
       insn_get_displacement+0x350/0x6b0 arch/x86/lib/insn.c:464
       insn_get_immediate arch/x86/lib/insn.c:632 [inline]
       insn_get_length arch/x86/lib/insn.c:707 [inline]
       insn_decode+0x43a/0x490 arch/x86/lib/insn.c:747
       can_probe+0xfc/0x1d0 arch/x86/kernel/kprobes/core.c:282
       arch_prepare_kprobe+0x79/0x1c0 arch/x86/kernel/kprobes/core.c:739
       prepare_kprobe kernel/kprobes.c:1160 [inline]
       register_kprobe kernel/kprobes.c:1641 [inline]
       register_kprobe+0xb6e/0x1690 kernel/kprobes.c:1603
       __register_trace_kprobe kernel/trace/trace_kprobe.c:509 [inline]
       __register_trace_kprobe+0x26a/0x2d0 kernel/trace/trace_kprobe.c:477
       create_local_trace_kprobe+0x1f7/0x350 kernel/trace/trace_kprobe.c:1833
       perf_kprobe_init+0x18c/0x280 kernel/trace/trace_event_perf.c:271
       perf_kprobe_event_init+0xf8/0x1c0 kernel/events/core.c:9888
       perf_try_init_event+0x12d/0x570 kernel/events/core.c:11261
       perf_init_event kernel/events/core.c:11325 [inline]
       perf_event_alloc.part.0+0xf7f/0x36a0 kernel/events/core.c:11619
       perf_event_alloc kernel/events/core.c:12059 [inline]
       __do_sys_perf_event_open+0x4a8/0x2a00 kernel/events/core.c:12157
       do_syscall_x64 arch/x86/entry/common.c:50 [inline]
       do_syscall_64+0x38/0x90 arch/x86/entry/common.c:80
       entry_SYSCALL_64_after_hwframe+0x63/0xcd
      RIP: 0033:0x7f63ef7efaed
      Code: 02 b8 ff ff ff ff c3 66 0f 1f 44 00 00 f3 0f 1e fa 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 b0 ff ff ff f7 d8 64 89 01 48
      RSP: 002b:00007f63eef63028 EFLAGS: 00000246 ORIG_RAX: 000000000000012a
      RAX: ffffffffffffffda RBX: 00007f63ef90ff80 RCX: 00007f63ef7efaed
      RDX: 0000000000000000 RSI: ffffffffffffffff RDI: 00000000200001c0
      RBP: 00007f63ef86019c R08: 0000000000000000 R09: 0000000000000000
      R10: ffffffffffffffff R11: 0000000000000246 R12: 0000000000000000
      R13: 0000000000000002 R14: 00007f63ef90ff80 R15: 00007f63eef43000
       </TASK>
      Modules linked in:
      CR2: fffffbfff3ac6000
      ---[ end trace 0000000000000000 ]---
      RIP: 0010:__insn_get_emulate_prefix arch/x86/lib/insn.c:91 [inline]
      RIP: 0010:insn_get_emulate_prefix arch/x86/lib/insn.c:106 [inline]
      RIP: 0010:insn_get_prefixes.part.0+0xa8/0x1110 arch/x86/lib/insn.c:134
      Code: 49 be 00 00 00 00 00 fc ff df 48 8b 40 60 48 89 44 24 08 e9 81 00 00 00 e8 e5 4b 39 ff 4c 89 fa 4c 89 f9 48 c1 ea 03 83 e1 07 <42> 0f b6 14 32 38 ca 7f 08 84 d2 0f 85 06 10 00 00 48 89 d8 48 89
      RSP: 0018:ffffc900088bf860 EFLAGS: 00010246
      RAX: 0000000000040000 RBX: ffffffff9b9bebc0 RCX: 0000000000000000
      RDX: 1ffffffff3ac6000 RSI: ffffc90002d82000 RDI: ffffc900088bf9e8
      RBP: ffffffff9d630001 R08: 0000000000000000 R09: ffffc900088bf9e8
      R10: 0000000000000000 R11: 0000000000000001 R12: 0000000000000001
      R13: ffffffff9d630000 R14: dffffc0000000000 R15: ffffffff9d630000
      FS:  00007f63eef63640(0000) GS:ffff88806d000000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: fffffbfff3ac6000 CR3: 0000000029d90005 CR4: 0000000000770ef0
      PKRU: 55555554
      ==================================================================
      
      Link: https://lkml.kernel.org/r/20220907200917.654103-1-lk@c--e.de
      
      cc: "Naveen N. Rao" <naveen.n.rao@linux.ibm.com>
      cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
      cc: "David S. Miller" <davem@davemloft.net>
      Cc: stable@vger.kernel.org
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Acked-by: default avatarMasami Hiramatsu (Google) <mhiramat@kernel.org>
      Signed-off-by: default avatarChristian A. Ehrhardt <lk@c--e.de>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8875d606
    • Alex Williamson's avatar
      vfio/type1: Unpin zero pages · 5321908e
      Alex Williamson authored
      commit 873aefb3
      
       upstream.
      
      There's currently a reference count leak on the zero page.  We increment
      the reference via pin_user_pages_remote(), but the page is later handled
      as an invalid/reserved page, therefore it's not accounted against the
      user and not unpinned by our put_pfn().
      
      Introducing special zero page handling in put_pfn() would resolve the
      leak, but without accounting of the zero page, a single user could
      still create enough mappings to generate a reference count overflow.
      
      The zero page is always resident, so for our purposes there's no reason
      to keep it pinned.  Therefore, add a loop to walk pages returned from
      pin_user_pages_remote() and unpin any zero pages.
      
      Cc: stable@vger.kernel.org
      Reported-by: default avatarLuboslav Pivarc <lpivarc@redhat.com>
      Reviewed-by: default avatarDavid Hildenbrand <david@redhat.com>
      Link: https://lore.kernel.org/r/166182871735.3518559.8884121293045337358.stgit@omen
      Signed-off-by: default avatarAlex Williamson <alex.williamson@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5321908e
    • Shin'ichiro Kawasaki's avatar
      btrfs: zoned: set pseudo max append zone limit in zone emulation mode · 7da1afa4
      Shin'ichiro Kawasaki authored
      commit cac5c44c upstream.
      
      The commit 7d7672bc ("btrfs: convert count_max_extents() to use
      fs_info->max_extent_size") introduced a division by
      fs_info->max_extent_size. This max_extent_size is initialized with max
      zone append limit size of the device btrfs runs on. However, in zone
      emulation mode, the device is not zoned then its zone append limit is
      zero. This resulted in zero value of fs_info->max_extent_size and caused
      zero division error.
      
      Fix the error by setting non-zero pseudo value to max append zone limit
      in zone emulation mode. Set the pseudo value based on max_segments as
      suggested in the commit c2ae7b77 ("btrfs: zoned: revive
      max_zone_append_bytes").
      
      Fixes: 7d7672bc
      
       ("btrfs: convert count_max_extents() to use fs_info->max_extent_size")
      CC: stable@vger.kernel.org # 5.12+
      Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
      Reviewed-by: default avatarNaohiro Aota <naohiro.aota@wdc.com>
      Signed-off-by: default avatarShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7da1afa4
    • Masami Hiramatsu (Google)'s avatar
      tracing: Fix to check event_mutex is held while accessing trigger list · 75082ade
      Masami Hiramatsu (Google) authored
      commit cecf8e12 upstream.
      
      Since the check_user_trigger() is called outside of RCU
      read lock, this list_for_each_entry_rcu() caused a suspicious
      RCU usage warning.
      
       # echo hist:keys=pid > events/sched/sched_stat_runtime/trigger
       # cat events/sched/sched_stat_runtime/trigger
      [   43.167032]
      [   43.167418] =============================
      [   43.167992] WARNING: suspicious RCU usage
      [   43.168567] 5.19.0-rc5-00029-g19ebe4651abf #59 Not tainted
      [   43.169283] -----------------------------
      [   43.169863] kernel/trace/trace_events_trigger.c:145 RCU-list traversed in non-reader section!!
      ...
      
      However, this file->triggers list is safe when it is accessed
      under event_mutex is held.
      To fix this warning, adds a lockdep_is_held check to the
      list_for_each_entry_rcu().
      
      Link: https://lkml.kernel.org/r/166226474977.223837.1992182913048377113.stgit@devnote2
      
      Cc: stable@vger.kernel.org
      Fixes: 7491e2c4
      
       ("tracing: Add a probe that attaches to trace events")
      Signed-off-by: default avatarMasami Hiramatsu (Google) <mhiramat@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      75082ade
    • Dongxiang Ke's avatar
      ALSA: usb-audio: Fix an out-of-bounds bug in __snd_usb_parse_audio_interface() · 98e8e673
      Dongxiang Ke authored
      commit e53f47f6
      
       upstream.
      
      There may be a bad USB audio device with a USB ID of (0x04fa, 0x4201) and
      the number of it's interfaces less than 4, an out-of-bounds read bug occurs
      when parsing the interface descriptor for this device.
      
      Fix this by checking the number of interfaces.
      
      Signed-off-by: default avatarDongxiang Ke <kdx.glider@gmail.com>
      Link: https://lore.kernel.org/r/20220906024928.10951-1-kdx.glider@gmail.com
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      98e8e673
    • Takashi Iwai's avatar
      ALSA: usb-audio: Split endpoint setups for hw_params and prepare · df5ec554
      Takashi Iwai authored
      commit ff878b40 upstream.
      
      One of the former changes for the endpoint management was the more
      consistent setup of endpoints at hw_params.
      snd_usb_endpoint_configure() is a single function that does the full
      setup, and it's called from both PCM hw_params and prepare callbacks.
      Although the EP setup at the prepare phase is usually skipped (by
      checking need_setup flag), it may be still effective in some cases
      like suspend/resume that requires the interface setup again.
      
      As it's a full and single setup, the invocation of
      snd_usb_endpoint_configure() includes not only the USB interface setup
      but also the buffer release and allocation.  OTOH, doing the buffer
      release and re-allocation at PCM prepare phase is rather superfluous,
      and better to be done only in the hw_params phase.
      
      For those optimizations, this patch splits the endpoint setup to two
      phases: snd_usb_endpoint_set_params() and snd_usb_endpoint_prepare(),
      to be called from hw_params and from prepare, respectively.
      
      Note that this patch changes the driver operation slightly,
      effectively moving the USB interface setup again to PCM prepare stage
      instead of hw_params stage, while the buffer allocation and such
      initializations are still done at hw_params stage.
      
      And, the change of the USB interface setup timing (moving to prepare)
      gave an interesting "fix", too: it was reported that the recent
      kernels caused silent output at the beginning on playbacks on some
      devices on Android, and this change casually fixed the regression.
      It seems that those devices are picky about the sample rate change (or
      the interface change?), and don't follow the too immediate rate
      changes.
      
      Meanwhile, Android operates the PCM in the following order:
      - open, then hw_params with the possibly highest sample rate
      - close without prepare
      - re-open, hw_params with the normal sample rate
      - prepare, and start streaming
      This procedure ended up the hw_params twice with different rates, and
      because the recent kernel did set up the sample rate twice one and
      after, it screwed up the device.  OTOH, the earlier kernels didn't set
      up the USB interface at hw_params, hence this problem didn't appear.
      
      Now, with this patch, the USB interface setup is again back to the
      prepare phase, and it works around the problem automagically.
      Although we should address the sample rate problem in a more solid
      way in future, let's keep things working as before for now.
      
      Fixes: bf6313a0
      
       ("ALSA: usb-audio: Refactor endpoint management")
      Cc: <stable@vger.kernel.org>
      Reported-by: default avatarchihhao chen <chihhao.chen@mediatek.com>
      Link: https://lore.kernel.org/r/87e6d6ae69d68dc588ac9acc8c0f24d6188375c3.camel@mediatek.com
      Link: https://lore.kernel.org/r/20220901124136.4984-1-tiwai@suse.de
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      df5ec554
    • Pattara Teerapong's avatar
      ALSA: aloop: Fix random zeros in capture data when using jiffies timer · d1118465
      Pattara Teerapong authored
      commit 3e48940a
      
       upstream.
      
      In loopback_jiffies_timer_pos_update(), we are getting jiffies twice.
      First time for playback, second time for capture. Jiffies can be updated
      between these two calls and if the capture jiffies is larger, extra zeros
      will be filled in the capture buffer.
      
      Change to get jiffies once and use it for both playback and capture.
      
      Signed-off-by: default avatarPattara Teerapong <pteerapong@chromium.org>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20220901144036.4049060-1-pteerapong@chromium.org
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d1118465
    • Tasos Sahanidis's avatar
      ALSA: emu10k1: Fix out of bounds access in snd_emu10k1_pcm_channel_alloc() · 45814a53
      Tasos Sahanidis authored
      commit d29f5905
      
       upstream.
      
      The voice allocator sometimes begins allocating from near the end of the
      array and then wraps around, however snd_emu10k1_pcm_channel_alloc()
      accesses the newly allocated voices as if it never wrapped around.
      
      This results in out of bounds access if the first voice has a high enough
      index so that first_voice + requested_voice_count > NUM_G (64).
      The more voices are requested, the more likely it is for this to occur.
      
      This was initially discovered using PipeWire, however it can be reproduced
      by calling aplay multiple times with 16 channels:
      aplay -r 48000 -D plughw:CARD=Live,DEV=3 -c 16 /dev/zero
      
      UBSAN: array-index-out-of-bounds in sound/pci/emu10k1/emupcm.c:127:40
      index 65 is out of range for type 'snd_emu10k1_voice [64]'
      CPU: 1 PID: 31977 Comm: aplay Tainted: G        W IOE      6.0.0-rc2-emu10k1+ #7
      Hardware name: ASUSTEK COMPUTER INC P5W DH Deluxe/P5W DH Deluxe, BIOS 3002    07/22/2010
      Call Trace:
      <TASK>
      dump_stack_lvl+0x49/0x63
      dump_stack+0x10/0x16
      ubsan_epilogue+0x9/0x3f
      __ubsan_handle_out_of_bounds.cold+0x44/0x49
      snd_emu10k1_playback_hw_params+0x3bc/0x420 [snd_emu10k1]
      snd_pcm_hw_params+0x29f/0x600 [snd_pcm]
      snd_pcm_common_ioctl+0x188/0x1410 [snd_pcm]
      ? exit_to_user_mode_prepare+0x35/0x170
      ? do_syscall_64+0x69/0x90
      ? syscall_exit_to_user_mode+0x26/0x50
      ? do_syscall_64+0x69/0x90
      ? exit_to_user_mode_prepare+0x35/0x170
      snd_pcm_ioctl+0x27/0x40 [snd_pcm]
      __x64_sys_ioctl+0x95/0xd0
      do_syscall_64+0x5c/0x90
      ? do_syscall_64+0x69/0x90
      ? do_syscall_64+0x69/0x90
      entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      Signed-off-by: default avatarTasos Sahanidis <tasos@tasossah.com>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/3707dcab-320a-62ff-63c0-73fc201ef756@tasossah.com
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      45814a53
    • Takashi Iwai's avatar
      ALSA: pcm: oss: Fix race at SNDCTL_DSP_SYNC · 8015ef9e
      Takashi Iwai authored
      commit 8423f0b6
      
       upstream.
      
      There is a small race window at snd_pcm_oss_sync() that is called from
      OSS PCM SNDCTL_DSP_SYNC ioctl; namely the function calls
      snd_pcm_oss_make_ready() at first, then takes the params_lock mutex
      for the rest.  When the stream is set up again by another thread
      between them, it leads to inconsistency, and may result in unexpected
      results such as NULL dereference of OSS buffer as a fuzzer spotted
      recently.
      
      The fix is simply to cover snd_pcm_oss_make_ready() call into the same
      params_lock mutex with snd_pcm_oss_make_ready_locked() variant.
      
      Reported-and-tested-by: default avatarbutt3rflyh4ck <butterflyhuangxx@gmail.com>
      Reviewed-by: default avatarJaroslav Kysela <perex@perex.cz>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/CAFcO6XN7JDM4xSXGhtusQfS2mSBcx50VJKwQpCq=WeLt57aaZA@mail.gmail.com
      Link: https://lore.kernel.org/r/20220905060714.22549-1-tiwai@suse.de
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8015ef9e
    • Qu Huang's avatar
      drm/amdgpu: mmVM_L2_CNTL3 register not initialized correctly · ad5ef763
      Qu Huang authored
      [ Upstream commit b8983d42
      
       ]
      
      The mmVM_L2_CNTL3 register is not assigned an initial value
      
      Signed-off-by: default avatarQu Huang <jinsdb@126.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ad5ef763
    • Yang Yingliang's avatar
      fbdev: chipsfb: Add missing pci_disable_device() in chipsfb_pci_init() · fc5a2a96
      Yang Yingliang authored
      [ Upstream commit 07c55c98
      
       ]
      
      Add missing pci_disable_device() in error path in chipsfb_pci_init().
      
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fc5a2a96
    • Shigeru Yoshida's avatar
      fbdev: fbcon: Destroy mutex on freeing struct fb_info · c3abfd6c
      Shigeru Yoshida authored
      [ Upstream commit 58559dfc
      
       ]
      
      It's needed to destroy bl_curve_mutex on freeing struct fb_info since
      the mutex is embedded in the structure and initialized when it's
      allocated.
      
      Signed-off-by: default avatarShigeru Yoshida <syoshida@redhat.com>
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c3abfd6c
    • David Sloan's avatar
      md: Flush workqueue md_rdev_misc_wq in md_alloc() · a7dff6f4
      David Sloan authored
      [ Upstream commit 5e8daf90
      
       ]
      
      A race condition still exists when removing and re-creating md devices
      in test cases. However, it is only seen on some setups.
      
      The race condition was tracked down to a reference still being held
      to the kobject by the rdev in the md_rdev_misc_wq which will be released
      in rdev_delayed_delete().
      
      md_alloc() waits for previous deletions by waiting on the md_misc_wq,
      but the md_rdev_misc_wq may still be holding a reference to a recently
      removed device.
      
      To fix this, also flush the md_rdev_misc_wq in md_alloc().
      
      Signed-off-by: default avatarDavid Sloan <david.sloan@eideticom.com>
      [logang@deltatee.com: rewrote commit message]
      Signed-off-by: default avatarLogan Gunthorpe <logang@deltatee.com>
      Signed-off-by: default avatarSong Liu <song@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a7dff6f4
    • lily's avatar
      net/core/skbuff: Check the return value of skb_copy_bits() · 0b705806
      lily authored
      [ Upstream commit c624c58e
      
       ]
      
      skb_copy_bits() could fail, which requires a check on the return
      value.
      
      Signed-off-by: default avatarLi Zhong <floridsleeves@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0b705806
    • Lukasz Luba's avatar
      cpufreq: check only freq_table in __resolve_freq() · bd1b7695
      Lukasz Luba authored
      [ Upstream commit 6ca7076f
      
       ]
      
      There is no need to check if the cpufreq driver implements callback
      cpufreq_driver::target_index. The logic in the __resolve_freq uses
      the frequency table available in the policy. It doesn't matter if the
      driver provides 'target_index' or 'target' callback. It just has to
      populate the 'policy->freq_table'.
      
      Thus, check only frequency table during the frequency resolving call.
      
      Acked-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: default avatarLukasz Luba <lukasz.luba@arm.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bd1b7695
    • Florian Westphal's avatar
      netfilter: conntrack: work around exceeded receive window · e928cf25
      Florian Westphal authored
      [ Upstream commit cf97769c
      
       ]
      
      When a TCP sends more bytes than allowed by the receive window, all future
      packets can be marked as invalid.
      This can clog up the conntrack table because of 5-day default timeout.
      
      Sequence of packets:
       01 initiator > responder: [S], seq 171, win 5840, options [mss 1330,sackOK,TS val 63 ecr 0,nop,wscale 1]
       02 responder > initiator: [S.], seq 33211, ack 172, win 65535, options [mss 1460,sackOK,TS val 010 ecr 63,nop,wscale 8]
       03 initiator > responder: [.], ack 33212, win 2920, options [nop,nop,TS val 068 ecr 010], length 0
       04 initiator > responder: [P.], seq 172:240, ack 33212, win 2920, options [nop,nop,TS val 279 ecr 010], length 68
      
      Window is 5840 starting from 33212 -> 39052.
      
       05 responder > initiator: [.], ack 240, win 256, options [nop,nop,TS val 872 ecr 279], length 0
       06 responder > initiator: [.], seq 33212:34530, ack 240, win 256, options [nop,nop,TS val 892 ecr 279], length 1318
      
      This is fine, conntrack will flag the connection as having outstanding
      data (UNACKED), which lowers the conntrack timeout to 300s.
      
       07 responder > initiator: [.], seq 34530:35848, ack 240, win 256, options [nop,nop,TS val 892 ecr 279], length 1318
       08 responder > initiator: [.], seq 35848:37166, ack 240, win 256, options [nop,nop,TS val 892 ecr 279], length 1318
       09 responder > initiator: [.], seq 37166:38484, ack 240, win 256, options [nop,nop,TS val 892 ecr 279], length 1318
       10 responder > initiator: [.], seq 38484:39802, ack 240, win 256, options [nop,nop,TS val 892 ecr 279], length 1318
      
      Packet 10 is already sending more than permitted, but conntrack doesn't
      validate this (only seq is tested vs. maxend, not 'seq+len').
      
      38484 is acceptable, but only up to 39052, so this packet should
      not have been sent (or only 568 bytes, not 1318).
      
      At this point, connection is still in '300s' mode.
      
      Next packet however will get flagged:
       11 responder > initiator: [P.], seq 39802:40128, ack 240, win 256, options [nop,nop,TS val 892 ecr 279], length 326
      
      nf_ct_proto_6: SEQ is over the upper bound (over the window of the receiver) .. LEN=378 .. SEQ=39802 ACK=240 ACK PSH ..
      
      Now, a couple of replies/acks comes in:
      
       12 initiator > responder: [.], ack 34530, win 4368,
      [.. irrelevant acks removed ]
       16 initiator > responder: [.], ack 39802, win 8712, options [nop,nop,TS val 296201291 ecr 2982371892], length 0
      
      This ack is significant -- this acks the last packet send by the
      responder that conntrack considered valid.
      
      This means that ack == td_end.  This will withdraw the
      'unacked data' flag, the connection moves back to the 5-day timeout
      of established conntracks.
      
       17 initiator > responder: ack 40128, win 10030, ...
      
      This packet is also flagged as invalid.
      
      Because conntrack only updates state based on packets that are
      considered valid, packet 11 'did not exist' and that gets us:
      
      nf_ct_proto_6: ACK is over upper bound 39803 (ACKed data not seen yet) .. SEQ=240 ACK=40128 WINDOW=10030 RES=0x00 ACK URG
      
      Because this received and processed by the endpoints, the conntrack entry
      remains in a bad state, no packets will ever be considered valid again:
      
       30 responder > initiator: [F.], seq 40432, ack 2045, win 391, ..
       31 initiator > responder: [.], ack 40433, win 11348, ..
       32 initiator > responder: [F.], seq 2045, ack 40433, win 11348 ..
      
      ... all trigger 'ACK is over bound' test and we end up with
      non-early-evictable 5-day default timeout.
      
      NB: This patch triggers a bunch of checkpatch warnings because of silly
      indent.  I will resend the cleanup series linked below to reduce the
      indent level once this change has propagated to net-next.
      
      I could route the cleanup via nf but that causes extra backport work for
      stable maintainers.
      
      Link: https://lore.kernel.org/netfilter-devel/20220720175228.17880-1-fw@strlen.de/T/#mb1d7147d36294573cc4f81d00f9f8dadfdd06cd8
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e928cf25
    • Sudeep Holla's avatar
      arm64: cacheinfo: Fix incorrect assignment of signed error value to unsigned fw_level · 29906311
      Sudeep Holla authored
      [ Upstream commit e75d18ce ]
      
      Though acpi_find_last_cache_level() always returned signed value and the
      document states it will return any errors caused by lack of a PPTT table,
      it never returned negative values before.
      
      Commit 0c80f9e1
      
       ("ACPI: PPTT: Leave the table mapped for the runtime usage")
      however changed it by returning -ENOENT if no PPTT was found. The value
      returned from acpi_find_last_cache_level() is then assigned to unsigned
      fw_level.
      
      It will result in the number of cache leaves calculated incorrectly as
      a huge value which will then cause the following warning from __alloc_pages
      as the order would be great than MAX_ORDER because of incorrect and huge
      cache leaves value.
      
        |  WARNING: CPU: 0 PID: 1 at mm/page_alloc.c:5407 __alloc_pages+0x74/0x314
        |  Modules linked in:
        |  CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.19.0-10393-g7c2a8d3ac4c0 #73
        |  pstate: 20000005 (nzCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
        |  pc : __alloc_pages+0x74/0x314
        |  lr : alloc_pages+0xe8/0x318
        |  Call trace:
        |   __alloc_pages+0x74/0x314
        |   alloc_pages+0xe8/0x318
        |   kmalloc_order_trace+0x68/0x1dc
        |   __kmalloc+0x240/0x338
        |   detect_cache_attributes+0xe0/0x56c
        |   update_siblings_masks+0x38/0x284
        |   store_cpu_topology+0x78/0x84
        |   smp_prepare_cpus+0x48/0x134
        |   kernel_init_freeable+0xc4/0x14c
        |   kernel_init+0x2c/0x1b4
        |   ret_from_fork+0x10/0x20
      
      Fix the same by changing fw_level to be signed integer and return the
      error from init_cache_level() early in case of error.
      
      Reported-and-Tested-by: default avatarBruno Goncalves <bgoncalv@redhat.com>
      Signed-off-by: default avatarSudeep Holla <sudeep.holla@arm.com>
      Link: https://lore.kernel.org/r/20220808084640.3165368-1-sudeep.holla@arm.com
      Signed-off-by: default avatarWill Deacon <will@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      29906311
    • Helge Deller's avatar
      parisc: Add runtime check to prevent PA2.0 kernels on PA1.x machines · 27092358
      Helge Deller authored
      [ Upstream commit 591d2108
      
       ]
      
      If a 32-bit kernel was compiled for PA2.0 CPUs, it won't be able to run
      on machines with PA1.x CPUs. Add a check and bail out early if a PA1.x
      machine is detected.
      
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      27092358
    • Li Qiong's avatar
      parisc: ccio-dma: Handle kmalloc failure in ccio_init_resources() · deb2c9c0
      Li Qiong authored
      [ Upstream commit d46c742f
      
       ]
      
      As the possible failure of the kmalloc(), it should be better
      to fix this error path, check and return '-ENOMEM' error code.
      
      Signed-off-by: default avatarLi Qiong <liqiong@nfschina.com>
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      deb2c9c0
    • Helge Deller's avatar
      Revert "parisc: Show error if wrong 32/64-bit compiler is being used" · c63ff388
      Helge Deller authored
      [ Upstream commit b4b18f47 ]
      
      This reverts commit b160628e
      
      .
      
      There is no need any longer to have this sanity check, because the
      previous commit ("parisc: Make CONFIG_64BIT available for ARCH=parisc64
      only") prevents that CONFIG_64BIT is set if ARCH==parisc.
      
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c63ff388
    • Bart Van Assche's avatar
      scsi: ufs: core: Reduce the power mode change timeout · c5018912
      Bart Van Assche authored
      [ Upstream commit 8f2c9642
      
       ]
      
      The current power mode change timeout (180 s) is so large that it can cause
      a watchdog timer to fire. Reduce the power mode change timeout to 10
      seconds.
      
      Link: https://lore.kernel.org/r/20220811234401.1957911-1-bvanassche@acm.org
      Reviewed-by: default avatarStanley Chu <stanley.chu@mediatek.com>
      Signed-off-by: default avatarBart Van Assche <bvanassche@acm.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c5018912
    • Zhenneng Li's avatar
      drm/radeon: add a force flush to delay work when radeon · 5a7a5b2e
      Zhenneng Li authored
      [ Upstream commit f461950f
      
       ]
      
      Although radeon card fence and wait for gpu to finish processing current batch rings,
      there is still a corner case that radeon lockup work queue may not be fully flushed,
      and meanwhile the radeon_suspend_kms() function has called pci_set_power_state() to
      put device in D3hot state.
      Per PCI spec rev 4.0 on 5.3.1.4.1 D3hot State.
      > Configuration and Message requests are the only TLPs accepted by a Function in
      > the D3hot state. All other received Requests must be handled as Unsupported Requests,
      > and all received Completions may optionally be handled as Unexpected Completions.
      This issue will happen in following logs:
      Unable to handle kernel paging request at virtual address 00008800e0008010
      CPU 0 kworker/0:3(131): Oops 0
      pc = [<ffffffff811bea5c>]  ra = [<ffffffff81240844>]  ps = 0000 Tainted: G        W
      pc is at si_gpu_check_soft_reset+0x3c/0x240
      ra is at si_dma_is_lockup+0x34/0xd0
      v0 = 0000000000000000  t0 = fff08800e0008010  t1 = 0000000000010000
      t2 = 0000000000008010  t3 = fff00007e3c00000  t4 = fff00007e3c00258
      t5 = 000000000000ffff  t6 = 0000000000000001  t7 = fff00007ef078000
      s0 = fff00007e3c016e8  s1 = fff00007e3c00000  s2 = fff00007e3c00018
      s3 = fff00007e3c00000  s4 = fff00007fff59d80  s5 = 0000000000000000
      s6 = fff00007ef07bd98
      a0 = fff00007e3c00000  a1 = fff00007e3c016e8  a2 = 0000000000000008
      a3 = 0000000000000001  a4 = 8f5c28f5c28f5c29  a5 = ffffffff810f4338
      t8 = 0000000000000275  t9 = ffffffff809b66f8  t10 = ff6769c5d964b800
      t11= 000000000000b886  pv = ffffffff811bea20  at = 0000000000000000
      gp = ffffffff81d89690  sp = 00000000aa814126
      Disabling lock debugging due to kernel taint
      Trace:
      [<ffffffff81240844>] si_dma_is_lockup+0x34/0xd0
      [<ffffffff81119610>] radeon_fence_check_lockup+0xd0/0x290
      [<ffffffff80977010>] process_one_work+0x280/0x550
      [<ffffffff80977350>] worker_thread+0x70/0x7c0
      [<ffffffff80977410>] worker_thread+0x130/0x7c0
      [<ffffffff80982040>] kthread+0x200/0x210
      [<ffffffff809772e0>] worker_thread+0x0/0x7c0
      [<ffffffff80981f8c>] kthread+0x14c/0x210
      [<ffffffff80911658>] ret_from_kernel_thread+0x18/0x20
      [<ffffffff80981e40>] kthread+0x0/0x210
       Code: ad3e0008  43f0074a  ad7e0018  ad9e0020  8c3001e8  40230101
       <88210000> 4821ed21
      So force lockup work queue flush to fix this problem.
      
      Acked-by: default avatarChristian König <christian.koenig@amd.com>
      Signed-off-by: default avatarZhenneng Li <lizhenneng@kylinos.cn>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      5a7a5b2e
    • Candice Li's avatar
      drm/amdgpu: Check num_gfx_rings for gfx v9_0 rb setup. · 622a557b
      Candice Li authored
      [ Upstream commit c3519383
      
       ]
      
      No need to set up rb when no gfx rings.
      
      Signed-off-by: default avatarCandice Li <candice.li@amd.com>
      Reviewed-by: default avatarHawking Zhang <Hawking.Zhang@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      622a557b
    • YiPeng Chai's avatar
      drm/amdgpu: Move psp_xgmi_terminate call from amdgpu_xgmi_remove_device to psp_hw_fini · c15c2c2c
      YiPeng Chai authored
      [ Upstream commit 9d705d77
      
       ]
      
      V1:
      The amdgpu_xgmi_remove_device function will send unload command
      to psp through psp ring to terminate xgmi, but psp ring has been
      destroyed in psp_hw_fini.
      
      V2:
      1. Change the commit title.
      2. Restore amdgpu_xgmi_remove_device to its original calling location.
         Move psp_xgmi_terminate call from amdgpu_xgmi_remove_device to
         psp_hw_fini.
      
      Signed-off-by: default avatarYiPeng Chai <YiPeng.Chai@amd.com>
      Reviewed-by: default avatarHawking Zhang <Hawking.Zhang@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c15c2c2c
    • Jeffy Chen's avatar
      drm/gem: Fix GEM handle release errors · 1f574fbe
      Jeffy Chen authored
      [ Upstream commit ea2aa97c
      
       ]
      
      Currently we are assuming a one to one mapping between dmabuf and
      GEM handle when releasing GEM handles.
      
      But that is not always true, since we would create extra handles for the
      GEM obj in cases like gem_open() and getfb{,2}().
      
      A similar issue was reported at:
      https://lore.kernel.org/all/20211105083308.392156-1-jay.xu@rock-chips.com/
      
      Another problem is that the imported dmabuf might not always have
      gem_obj->dma_buf set, which would cause leaks in
      drm_gem_remove_prime_handles().
      
      Let's fix these for now by using handle to find the exact map to remove.
      
      Signed-off-by: default avatarJeffy Chen <jeffy.chen@rock-chips.com>
      Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
      Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220819072834.17888-1-jeffy.chen@rock-chips.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1f574fbe
    • Guixin Liu's avatar
      scsi: megaraid_sas: Fix double kfree() · bbfd857a
      Guixin Liu authored
      [ Upstream commit 8c499e49
      
       ]
      
      When allocating log_to_span fails, kfree(instance->ctrl_context) is called
      twice. Remove redundant call.
      
      Link: https://lore.kernel.org/r/1659424729-46502-1-git-send-email-kanie@linux.alibaba.com
      Acked-by: default avatarSumit Saxena <sumit.saxena@broadcom.com>
      Signed-off-by: default avatarGuixin Liu <kanie@linux.alibaba.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      bbfd857a
    • Tony Battersby's avatar
      scsi: qla2xxx: Disable ATIO interrupt coalesce for quad port ISP27XX · 8179f0e0
      Tony Battersby authored
      [ Upstream commit 53661ded ]
      
      This partially reverts commit d2b292c3
      
       ("scsi: qla2xxx: Enable ATIO
      interrupt handshake for ISP27XX")
      
      For some workloads where the host sends a batch of commands and then
      pauses, ATIO interrupt coalesce can cause some incoming ATIO entries to be
      ignored for extended periods of time, resulting in slow performance,
      timeouts, and aborted commands.
      
      Disable interrupt coalesce and re-enable the dedicated ATIO MSI-X
      interrupt.
      
      Link: https://lore.kernel.org/r/97dcf365-89ff-014d-a3e5-1404c6af511c@cybernetics.com
      Reviewed-by: default avatarHimanshu Madhani <himanshu.madhani@oracle.com>
      Reviewed-by: default avatarNilesh Javali <njavali@marvell.com>
      Signed-off-by: default avatarTony Battersby <tonyb@cybernetics.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8179f0e0
    • Yee Lee's avatar
      Revert "mm: kmemleak: take a full lowmem check in kmemleak_*_phys()" · 625c78e1
      Yee Lee authored
      This reverts commit 23c2d497.
      
      Commit 23c2d497 ("mm: kmemleak: take a full lowmem check in
      kmemleak_*_phys()") brought false leak alarms on some archs like arm64
      that does not init pfn boundary in early booting. The final solution
      lands on linux-6.0: commit 0c24e061
      
       ("mm: kmemleak: add rbtree and
      store physical address for objects allocated with PA").
      
      Revert this commit before linux-6.0. The original issue of invalid PA
      can be mitigated by additional check in devicetree.
      
      The false alarm report is as following: Kmemleak output: (Qemu/arm64)
      unreferenced object 0xffff0000c0170a00 (size 128):
        comm "swapper/0", pid 1, jiffies 4294892404 (age 126.208s)
        hex dump (first 32 bytes):
       62 61 73 65 00 00 00 00 00 00 00 00 00 00 00 00  base............
          00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
        backtrace:
          [<(____ptrval____)>] __kmalloc_track_caller+0x1b0/0x2e4
          [<(____ptrval____)>] kstrdup_const+0x8c/0xc4
          [<(____ptrval____)>] kvasprintf_const+0xbc/0xec
          [<(____ptrval____)>] kobject_set_name_vargs+0x58/0xe4
          [<(____ptrval____)>] kobject_add+0x84/0x100
          [<(____ptrval____)>] __of_attach_node_sysfs+0x78/0xec
          [<(____ptrval____)>] of_core_init+0x68/0x104
          [<(____ptrval____)>] driver_init+0x28/0x48
          [<(____ptrval____)>] do_basic_setup+0x14/0x28
          [<(____ptrval____)>] kernel_init_freeable+0x110/0x178
          [<(____ptrval____)>] kernel_init+0x20/0x1a0
          [<(____ptrval____)>] ret_from_fork+0x10/0x20
      
      This pacth is also applicable to linux-5.17.y/linux-5.18.y/linux-5.19.y
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarYee Lee <yee.lee@mediatek.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      625c78e1
    • Linus Torvalds's avatar
      fs: only do a memory barrier for the first set_buffer_uptodate() · 7c633341
      Linus Torvalds authored
      commit 2f79cdfe upstream.
      
      Commit d4252071
      
       ("add barriers to buffer_uptodate and
      set_buffer_uptodate") added proper memory barriers to the buffer head
      BH_Uptodate bit, so that anybody who tests a buffer for being up-to-date
      will be guaranteed to actually see initialized state.
      
      However, that commit didn't _just_ add the memory barrier, it also ended
      up dropping the "was it already set" logic that the BUFFER_FNS() macro
      had.
      
      That's conceptually the right thing for a generic "this is a memory
      barrier" operation, but in the case of the buffer contents, we really
      only care about the memory barrier for the _first_ time we set the bit,
      in that the only memory ordering protection we need is to avoid anybody
      seeing uninitialized memory contents.
      
      Any other access ordering wouldn't be about the BH_Uptodate bit anyway,
      and would require some other proper lock (typically BH_Lock or the folio
      lock).  A reader that races with somebody invalidating the buffer head
      isn't an issue wrt the memory ordering, it's a serialization issue.
      
      Now, you'd think that the buffer head operations don't matter in this
      day and age (and I certainly thought so), but apparently some loads
      still end up being heavy users of buffer heads.  In particular, the
      kernel test robot reported that not having this bit access optimization
      in place caused a noticeable direct IO performance regression on ext4:
      
        fxmark.ssd_ext4_no_jnl_DWTL_54_directio.works/sec -26.5% regression
      
      although you presumably need a fast disk and a lot of cores to actually
      notice.
      
      Link: https://lore.kernel.org/all/Yw8L7HTZ%2FdE2%2Fo9C@xsang-OptiPlex-9020/
      Reported-by: default avatarkernel test robot <oliver.sang@intel.com>
      Tested-by: default avatarFengwei Yin <fengwei.yin@intel.com>
      Cc: Mikulas Patocka <mpatocka@redhat.com>
      Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
      Cc: stable@kernel.org
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7c633341
    • Stanislaw Gruszka's avatar
      wifi: iwlegacy: 4965: corrected fix for potential off-by-one overflow in il4965_rs_fill_link_cmd() · 44b402da
      Stanislaw Gruszka authored
      commit 6d0ef724 upstream.
      
      This reverts commit a8eb8e6f as
      it can cause invalid link quality command sent to the firmware
      and address the off-by-one issue by fixing condition of while loop.
      
      Cc: stable@vger.kernel.org
      Fixes: a8eb8e6f
      
       ("wifi: iwlegacy: 4965: fix potential off-by-one overflow in il4965_rs_fill_link_cmd()")
      Signed-off-by: default avatarStanislaw Gruszka <stf_xl@wp.pl>
      Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
      Link: https://lore.kernel.org/r/20220815073737.GA999388@wp.pl
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      44b402da
    • Hyunwoo Kim's avatar
      efi: capsule-loader: Fix use-after-free in efi_capsule_write · dd291e07
      Hyunwoo Kim authored
      commit 9cb636b5
      
       upstream.
      
      A race condition may occur if the user calls close() on another thread
      during a write() operation on the device node of the efi capsule.
      
      This is a race condition that occurs between the efi_capsule_write() and
      efi_capsule_flush() functions of efi_capsule_fops, which ultimately
      results in UAF.
      
      So, the page freeing process is modified to be done in
      efi_capsule_release() instead of efi_capsule_flush().
      
      Cc: <stable@vger.kernel.org> # v4.9+
      Signed-off-by: default avatarHyunwoo Kim <imv4bel@gmail.com>
      Link: https://lore.kernel.org/all/20220907102920.GA88602@ubuntu/
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dd291e07
    • Ard Biesheuvel's avatar
      efi: libstub: Disable struct randomization · ee06f081
      Ard Biesheuvel authored
      commit 1a388792
      
       upstream.
      
      The EFI stub is a wrapper around the core kernel that makes it look like
      a EFI compatible PE/COFF application to the EFI firmware. EFI
      applications run on top of the EFI runtime, which is heavily based on
      so-called protocols, which are struct types consisting [mostly] of
      function pointer members that are instantiated and recorded in a
      protocol database.
      
      These structs look like the ideal randomization candidates to the
      randstruct plugin (as they only carry function pointers), but of course,
      these protocols are contracts between the firmware that exposes them,
      and the EFI applications (including our stubbed kernel) that invoke
      them. This means that struct randomization for EFI protocols is not a
      great idea, and given that the stub shares very little data with the
      core kernel that is represented as a randomizable struct, we're better
      off just disabling it completely here.
      
      Cc: <stable@vger.kernel.org> # v4.14+
      Reported-by: default avatarDaniel Marth <daniel.marth@inso.tuwien.ac.at>
      Tested-by: default avatarDaniel Marth <daniel.marth@inso.tuwien.ac.at>
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Acked-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ee06f081
    • Jakub Kicinski's avatar
      net: wwan: iosm: remove pointless null check · 6427605f
      Jakub Kicinski authored
      commit dbbc7d04
      
       upstream.
      
      GCC 12 warns:
      
      drivers/net/wwan/iosm/iosm_ipc_protocol_ops.c: In function ‘ipc_protocol_dl_td_process’:
      drivers/net/wwan/iosm/iosm_ipc_protocol_ops.c:406:13: warning: the comparison will always evaluate as ‘true’ for the address of ‘cb’ will never be NULL [-Waddress]
        406 |         if (!IPC_CB(skb)) {
            |             ^
      
      Indeed the check seems entirely pointless. Hopefully the other
      validation checks will catch if the cb is bad, but it can't be
      NULL.
      
      Reviewed-by: default avatarM Chetan Kumar <m.chetan.kumar@intel.com>
      Link: https://lore.kernel.org/r/20220519004342.2109832-1-kuba@kernel.org
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Cc: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6427605f
  2. Sep 08, 2022