Skip to content
  1. Sep 15, 2022
    • Andrew Halaney's avatar
      regulator: core: Clean up on enable failure · d80ad999
      Andrew Halaney authored
      [ Upstream commit c32f1ebf ]
      
      If regulator_enable() fails, enable_count is incremented still.
      A consumer, assuming no matching regulator_disable() is necessary on
      failure, will then get this error message upon regulator_put()
      since enable_count is non-zero:
      
          [    1.277418] WARNING: CPU: 3 PID: 1 at drivers/regulator/core.c:2304 _regulator_put.part.0+0x168/0x170
      
      The consumer could try to fix this in their driver by cleaning up on
      error from regulator_enable() (i.e. call regulator_disable()), but that
      results in the following since regulator_enable() failed and didn't
      increment user_count:
      
          [    1.258112] unbalanced disables for vreg_l17c
          [    1.262606] WARNING: CPU: 4 PID: 1 at drivers/regulator/core.c:2899 _regulator_disable+0xd4/0x190
      
      Fix this by decrementing enable_count upon failure to enable.
      
      With this in place, just the reason for failure to enable is printed
      as expected and developers can focus on the root cause of their issue
      instead of thinking their usage of the regulator consumer api is
      incorrect. For example, in my case:
      
          [    1.240426] vreg_l17c: invalid input voltage found
      
      Fixes: 5451781d
      
       ("regulator: core: Only count load for enabled consumers")
      Signed-off-by: default avatarAndrew Halaney <ahalaney@redhat.com>
      Reviewed-by: default avatarDouglas Anderson <dianders@chromium.org>
      Reviewed-by: default avatarBrian Masney <bmasney@redhat.com>
      Link: https://lore.kernel.org/r/20220819194336.382740-1-ahalaney@redhat.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d80ad999
    • Marco Felsch's avatar
      ARM: dts: imx6qdl-kontron-samx6i: remove duplicated node · c108e203
      Marco Felsch authored
      [ Upstream commit 204f67d8 ]
      
      The regulator node 'regulator-3p3v-s0' was dupplicated. Remove it to
      clean the DTS.
      
      Fixes: 2a51f9da
      
       ("ARM: dts: imx6qdl-kontron-samx6i: Add iMX6-based Kontron SMARC-sAMX6i module")
      Signed-off-by: default avatarMarco Felsch <m.felsch@pengutronix.de>
      Signed-off-by: default avatarShawn Guo <shawnguo@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c108e203
    • David Howells's avatar
      smb3: missing inode locks in punch hole · e192a08f
      David Howells authored
      [ Upstream commit ba080305
      
       ]
      
      smb3 fallocate punch hole was not grabbing the inode or filemap_invalidate
      locks so could have race with pagemap reinstantiating the page.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e192a08f
    • Tejun Heo's avatar
      cgroup: Fix threadgroup_rwsem <-> cpus_read_lock() deadlock · 59c6902a
      Tejun Heo authored
      [ Upstream commit 4f7e7236
      
       ]
      
      Bringing up a CPU may involve creating and destroying tasks which requires
      read-locking threadgroup_rwsem, so threadgroup_rwsem nests inside
      cpus_read_lock(). However, cpuset's ->attach(), which may be called with
      thredagroup_rwsem write-locked, also wants to disable CPU hotplug and
      acquires cpus_read_lock(), leading to a deadlock.
      
      Fix it by guaranteeing that ->attach() is always called with CPU hotplug
      disabled and removing cpus_read_lock() call from cpuset_attach().
      
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Reviewed-and-tested-by: default avatarImran Khan <imran.f.khan@oracle.com>
      Reported-and-tested-by: default avatarXuewen Yan <xuewen.yan@unisoc.com>
      Fixes: 05c7b7a9
      
       ("cgroup/cpuset: Fix a race between cpuset_attach() and cpu hotplug")
      Cc: stable@vger.kernel.org # v5.17+
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      59c6902a
    • Tejun Heo's avatar
      cgroup: Elide write-locking threadgroup_rwsem when updating csses on an empty subtree · 13d67aad
      Tejun Heo authored
      [ Upstream commit 671c11f0
      
       ]
      
      cgroup_update_dfl_csses() write-lock the threadgroup_rwsem as updating the
      csses can trigger process migrations. However, if the subtree doesn't
      contain any tasks, there aren't gonna be any cgroup migrations. This
      condition can be trivially detected by testing whether
      mgctx.preloaded_src_csets is empty. Elide write-locking threadgroup_rwsem if
      the subtree is empty.
      
      After this optimization, the usage pattern of creating a cgroup, enabling
      the necessary controllers, and then seeding it with CLONE_INTO_CGROUP and
      then removing the cgroup after it becomes empty doesn't need to write-lock
      threadgroup_rwsem at all.
      
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Christian Brauner <brauner@kernel.org>
      Cc: Michal Koutný <mkoutny@suse.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      13d67aad
    • Michal Koutný's avatar
      cgroup: Optimize single thread migration · 05951695
      Michal Koutný authored
      [ Upstream commit 9a3284fa ]
      
      There are reports of users who use thread migrations between cgroups and
      they report performance drop after d59cfc09
      
       ("sched, cgroup: replace
      signal_struct->group_rwsem with a global percpu_rwsem"). The effect is
      pronounced on machines with more CPUs.
      
      The migration is affected by forking noise happening in the background,
      after the mentioned commit a migrating thread must wait for all
      (forking) processes on the system, not only of its threadgroup.
      
      There are several places that need to synchronize with migration:
      	a) do_exit,
      	b) de_thread,
      	c) copy_process,
      	d) cgroup_update_dfl_csses,
      	e) parallel migration (cgroup_{proc,thread}s_write).
      
      In the case of self-migrating thread, we relax the synchronization on
      cgroup_threadgroup_rwsem to avoid the cost of waiting. d) and e) are
      excluded with cgroup_mutex, c) does not matter in case of single thread
      migration and the executing thread cannot exec(2) or exit(2) while it is
      writing into cgroup.threads. In case of do_exit because of signal
      delivery, we either exit before the migration or finish the migration
      (of not yet PF_EXITING thread) and die afterwards.
      
      This patch handles only the case of self-migration by writing "0" into
      cgroup.threads. For simplicity, we always take cgroup_threadgroup_rwsem
      with numeric PIDs.
      
      This change improves migration dependent workload performance similar
      to per-signal_struct state.
      
      Signed-off-by: default avatarMichal Koutný <mkoutny@suse.com>
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      05951695
    • Yang Yingliang's avatar
      scsi: lpfc: Add missing destroy_workqueue() in error path · d0e7be0d
      Yang Yingliang authored
      commit da6d507f upstream.
      
      Add the missing destroy_workqueue() before return from
      lpfc_sli4_driver_resource_setup() in the error path.
      
      Link: https://lore.kernel.org/r/20220823044237.285643-1-yangyingliang@huawei.com
      Fixes: 3cee98db
      
       ("scsi: lpfc: Fix crash on driver unload in wq free")
      Reviewed-by: default avatarJames Smart <jsmart2021@gmail.com>
      Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d0e7be0d
    • Sreekanth Reddy's avatar
      scsi: mpt3sas: Fix use-after-free warning · 5682c946
      Sreekanth Reddy authored
      commit 991df3dd
      
       upstream.
      
      Fix the following use-after-free warning which is observed during
      controller reset:
      
      refcount_t: underflow; use-after-free.
      WARNING: CPU: 23 PID: 5399 at lib/refcount.c:28 refcount_warn_saturate+0xa6/0xf0
      
      Link: https://lore.kernel.org/r/20220906134908.1039-2-sreekanth.reddy@broadcom.com
      Signed-off-by: default avatarSreekanth Reddy <sreekanth.reddy@broadcom.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5682c946
    • Bart Van Assche's avatar
      nvmet: fix a use-after-free · 8d66989b
      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>
      8d66989b
    • Greg Kroah-Hartman's avatar
      debugfs: add debugfs_lookup_and_remove() · 9fc8c5fa
      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>
      9fc8c5fa
    • Christian A. Ehrhardt's avatar
      kprobes: Prohibit probes in gate area · 0d895d2b
      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>
      0d895d2b
    • Dongxiang Ke's avatar
      ALSA: usb-audio: Fix an out-of-bounds bug in __snd_usb_parse_audio_interface() · 0492798b
      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>
      0492798b
    • Pattara Teerapong's avatar
      ALSA: aloop: Fix random zeros in capture data when using jiffies timer · e275cf33
      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>
      e275cf33
    • Tasos Sahanidis's avatar
      ALSA: emu10k1: Fix out of bounds access in snd_emu10k1_pcm_channel_alloc() · 45321a7d
      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>
      45321a7d
    • Qu Huang's avatar
      drm/amdgpu: mmVM_L2_CNTL3 register not initialized correctly · adbbc1a8
      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>
      adbbc1a8
    • Yang Yingliang's avatar
      fbdev: chipsfb: Add missing pci_disable_device() in chipsfb_pci_init() · e1955cdd
      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>
      e1955cdd
    • Sudeep Holla's avatar
      arm64: cacheinfo: Fix incorrect assignment of signed error value to unsigned fw_level · fcab25a6
      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>
      fcab25a6
    • Helge Deller's avatar
      parisc: Add runtime check to prevent PA2.0 kernels on PA1.x machines · a3714415
      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>
      a3714415
    • Li Qiong's avatar
      parisc: ccio-dma: Handle kmalloc failure in ccio_init_resources() · dcf54e6c
      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>
      dcf54e6c
    • Zhenneng Li's avatar
      drm/radeon: add a force flush to delay work when radeon · c72d9714
      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>
      c72d9714
    • Candice Li's avatar
      drm/amdgpu: Check num_gfx_rings for gfx v9_0 rb setup. · ae2c6cc8
      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>
      ae2c6cc8
    • Jeffy Chen's avatar
      drm/gem: Fix GEM handle release errors · bca46f22
      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>
      bca46f22
    • Guixin Liu's avatar
      scsi: megaraid_sas: Fix double kfree() · bd2a3bff
      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>
      bd2a3bff
    • Johan Hovold's avatar
      USB: serial: ch341: fix disabled rx timer on older devices · 944f276c
      Johan Hovold authored
      commit 41ca302a
      
       upstream.
      
      At least one older CH341 appears to have the RX timer enable bit
      inverted so that setting it disables the RX timer and prevents the FIFO
      from emptying until it is full.
      
      Only set the RX timer enable bit for devices with version newer than
      0x27 (even though this probably affects all pre-0x30 devices).
      
      Reported-by: default avatarJonathan Woithe <jwoithe@just42.net>
      Tested-by: default avatarJonathan Woithe <jwoithe@just42.net>
      Link: https://lore.kernel.org/r/Ys1iPTfiZRWj2gXs@marvin.atrad.com.au
      Fixes: 4e46c410
      
       ("USB: serial: ch341: reinitialize chip on reconfiguration")
      Cc: stable@vger.kernel.org      # 4.10
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      [ johan: backport to 5.4 ]
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      944f276c
    • Johan Hovold's avatar
      USB: serial: ch341: fix lost character on LCR updates · f0003ab9
      Johan Hovold authored
      commit 8e83622a
      
       upstream.
      
      Disable LCR updates for pre-0x30 devices which use a different (unknown)
      protocol for line control and where the current register write causes
      the next received character to be lost.
      
      Note that updating LCR using the INIT command has no effect on these
      devices either.
      
      Reported-by: default avatarJonathan Woithe <jwoithe@just42.net>
      Tested-by: default avatarJonathan Woithe <jwoithe@just42.net>
      Link: https://lore.kernel.org/r/Ys1iPTfiZRWj2gXs@marvin.atrad.com.au
      Fixes: 4e46c410 ("USB: serial: ch341: reinitialize chip on reconfiguration")
      Fixes: 55fa15b5
      
       ("USB: serial: ch341: fix baud rate and line-control handling")
      Cc: stable@vger.kernel.org      # 4.10
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      [ johan: adjust context to 5.4 ]
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f0003ab9
    • Johan Hovold's avatar
      usb: dwc3: disable USB core PHY management · d288c638
      Johan Hovold authored
      commit 6000b8d9 upstream.
      
      The dwc3 driver manages its PHYs itself so the USB core PHY management
      needs to be disabled.
      
      Use the struct xhci_plat_priv hack added by commits 46034a99 ("usb:
      host: xhci-plat: add platform data support") and f768e718 ("usb:
      host: xhci-plat: add priv quirk for skip PHY initialization") to
      propagate the setting for now.
      
      Fixes: 4e88d4c0 ("usb: add a flag to skip PHY initialization to struct usb_hcd")
      Fixes: 178a0bce
      
       ("usb: core: hcd: integrate the PHY wrapper into the HCD core")
      Tested-by: default avatarMatthias Kaehlcke <mka@chromium.org>
      Cc: stable <stable@kernel.org>
      Reviewed-by: default avatarMatthias Kaehlcke <mka@chromium.org>
      Signed-off-by: default avatarJohan Hovold <johan+linaro@kernel.org>
      Link: https://lore.kernel.org/r/20220825131836.19769-1-johan+linaro@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      [ johan: adjust context to 5.15 ]
      Signed-off-by: default avatarJohan Hovold <johan+linaro@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d288c638
    • Johan Hovold's avatar
      usb: dwc3: fix PHY disable sequence · 9c670d0b
      Johan Hovold authored
      commit d2ac7bef upstream.
      
      Generic PHYs must be powered-off before they can be tore down.
      
      Similarly, suspending legacy PHYs after having powered them off makes no
      sense.
      
      Fix the dwc3_core_exit() (e.g. called during suspend) and open-coded
      dwc3_probe() error-path sequences that got this wrong.
      
      Note that this makes dwc3_core_exit() match the dwc3_core_init() error
      path with respect to powering off the PHYs.
      
      Fixes: 03c1fd62 ("usb: dwc3: core: add phy cleanup for probe error handling")
      Fixes: c499ff71
      
       ("usb: dwc3: core: re-factor init and exit paths")
      Cc: stable@vger.kernel.org      # 4.8
      Reviewed-by: default avatarAndrew Halaney <ahalaney@redhat.com>
      Reviewed-by: default avatarMatthias Kaehlcke <mka@chromium.org>
      Reviewed-by: default avatarManivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
      Signed-off-by: default avatarJohan Hovold <johan+linaro@kernel.org>
      Link: https://lore.kernel.org/r/20220804151001.23612-2-johan+linaro@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      [ johan: adjust context to 5.15 ]
      Signed-off-by: default avatarJohan Hovold <johan+linaro@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9c670d0b
    • Anand Jain's avatar
      btrfs: harden identification of a stale device · 9ab0c653
      Anand Jain authored
      commit 770c79fb
      
       upstream.
      
      Identifying and removing the stale device from the fs_uuids list is done
      by btrfs_free_stale_devices().  btrfs_free_stale_devices() in turn
      depends on device_path_matched() to check if the device appears in more
      than one btrfs_device structure.
      
      The matching of the device happens by its path, the device path. However,
      when device mapper is in use, the dm device paths are nothing but a link
      to the actual block device, which leads to the device_path_matched()
      failing to match.
      
      Fix this by matching the dev_t as provided by lookup_bdev() instead of
      plain string compare of the device paths.
      
      Reported-by: default avatarJosef Bacik <josef@toxicpanda.com>
      Signed-off-by: default avatarAnand Jain <anand.jain@oracle.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9ab0c653
    • Diego Santa Cruz's avatar
      drm/i915/glk: ECS Liva Q2 needs GLK HDMI port timing quirk · 4e5ba186
      Diego Santa Cruz authored
      commit 919bef7a upstream.
      
      The quirk added in upstream commit 90c3e219
      
       ("drm/i915/glk: Add
      Quirk for GLK NUC HDMI port issues.") is also required on the ECS Liva
      Q2.
      
      Note: Would be nicer to figure out the extra delay required for the
      retimer without quirks, however don't know how to check for that.
      
      Cc: stable@vger.kernel.org
      Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/1326
      Signed-off-by: default avatarDiego Santa Cruz <Diego.SantaCruz@spinetix.com>
      Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20220616124137.3184371-1-jani.nikula@intel.com
      (cherry picked from commit 08e9505f
      
      )
      Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4e5ba186
    • Takashi Iwai's avatar
      ALSA: seq: Fix data-race at module auto-loading · 3af1316d
      Takashi Iwai authored
      commit 3e7e04b7
      
       upstream.
      
      It's been reported that there is a possible data-race accessing to the
      global card_requested[] array at ALSA sequencer core, which is used
      for determining whether to call request_module() for the card or not.
      This data race itself is almost harmless, as it might end up with one
      extra request_module() call for the already loaded module at most.
      But it's still better to fix.
      
      This patch addresses the possible data race of card_requested[] and
      client_requested[] arrays by replacing them with bitmask.
      It's an atomic operation and can work without locks.
      
      Reported-by: default avatarAbhishek Shah <abhishek.shah@columbia.edu>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/CAEHB24_ay6YzARpA1zgCsE7=H9CSJJzux618E=Ka4h0YdKn=qA@mail.gmail.com
      Link: https://lore.kernel.org/r/20220823072717.1706-2-tiwai@suse.de
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3af1316d
    • Takashi Iwai's avatar
      ALSA: seq: oss: Fix data-race for max_midi_devs access · 4fa63d52
      Takashi Iwai authored
      commit 22dec134
      
       upstream.
      
      ALSA OSS sequencer refers to a global variable max_midi_devs at
      creating a new port, storing it to its own field.  Meanwhile this
      variable may be changed by other sequencer events at
      snd_seq_oss_midi_check_exit_port() in parallel, which may cause a data
      race.
      
      OTOH, this data race itself is almost harmless, as the access to the
      MIDI device is done via get_mdev() and it's protected with a refcount,
      hence its presence is guaranteed.
      
      Though, it's sill better to address the data-race from the code sanity
      POV, and this patch adds the proper spinlock for the protection.
      
      Reported-by: default avatarAbhishek Shah <abhishek.shah@columbia.edu>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/CAEHB2493pZRXs863w58QWnUTtv3HHfg85aYhLn5HJHCwxqtHQg@mail.gmail.com
      Link: https://lore.kernel.org/r/20220823072717.1706-1-tiwai@suse.de
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4fa63d52
    • Miquel Raynal's avatar
      net: mac802154: Fix a condition in the receive path · 82a86f82
      Miquel Raynal authored
      commit f0da4711 upstream.
      
      Upon reception, a packet must be categorized, either it's destination is
      the host, or it is another host. A packet with no destination addressing
      fields may be valid in two situations:
      - the packet has no source field: only ACKs are built like that, we
        consider the host as the destination.
      - the packet has a valid source field: it is directed to the PAN
        coordinator, as for know we don't have this information we consider we
        are not the PAN coordinator.
      
      There was likely a copy/paste error made during a previous cleanup
      because the if clause is now containing exactly the same condition as in
      the switch case, which can never be true. In the past the destination
      address was used in the switch and the source address was used in the
      if, which matches what the spec says.
      
      Cc: stable@vger.kernel.org
      Fixes: ae531b94
      
       ("ieee802154: use ieee802154_addr instead of *_sa variants")
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Link: https://lore.kernel.org/r/20220826142954.254853-1-miquel.raynal@bootlin.com
      Signed-off-by: default avatarStefan Schmidt <stefan@datenfreihafen.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      82a86f82
    • Nicolas Dichtel's avatar
      ip: fix triggering of 'icmp redirect' · d228b897
      Nicolas Dichtel authored
      commit eb55dc09 upstream.
      
      __mkroute_input() uses fib_validate_source() to trigger an icmp redirect.
      My understanding is that fib_validate_source() is used to know if the src
      address and the gateway address are on the same link. For that,
      fib_validate_source() returns 1 (same link) or 0 (not the same network).
      __mkroute_input() is the only user of these positive values, all other
      callers only look if the returned value is negative.
      
      Since the below patch, fib_validate_source() didn't return anymore 1 when
      both addresses are on the same network, because the route lookup returns
      RT_SCOPE_LINK instead of RT_SCOPE_HOST. But this is, in fact, right.
      Let's adapat the test to return 1 again when both addresses are on the same
      link.
      
      CC: stable@vger.kernel.org
      Fixes: 747c1430
      
       ("ip: fix dflt addr selection for connected nexthop")
      Reported-by: default avatarkernel test robot <yujie.liu@intel.com>
      Reported-by: default avatarHeng Qi <hengqi@linux.alibaba.com>
      Signed-off-by: default avatarNicolas Dichtel <nicolas.dichtel@6wind.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Link: https://lore.kernel.org/r/20220829100121.3821-1-nicolas.dichtel@6wind.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d228b897
    • Siddh Raman Pant's avatar
      wifi: mac80211: Don't finalize CSA in IBSS mode if state is disconnected · 66689c5c
      Siddh Raman Pant authored
      commit 15bc8966 upstream.
      
      When we are not connected to a channel, sending channel "switch"
      announcement doesn't make any sense.
      
      The BSS list is empty in that case. This causes the for loop in
      cfg80211_get_bss() to be bypassed, so the function returns NULL
      (check line 1424 of net/wireless/scan.c), causing the WARN_ON()
      in ieee80211_ibss_csa_beacon() to get triggered (check line 500
      of net/mac80211/ibss.c), which was consequently reported on the
      syzkaller dashboard.
      
      Thus, check if we have an existing connection before generating
      the CSA beacon in ieee80211_ibss_finish_csa().
      
      Cc: stable@vger.kernel.org
      Fixes: cd7760e6
      
       ("mac80211: add support for CSA in IBSS mode")
      Link: https://syzkaller.appspot.com/bug?id=05603ef4ae8926761b678d2939a3b2ad28ab9ca6
      Reported-by: default avatar <syzbot+b6c9fe29aefe68e4ad34@syzkaller.appspotmail.com>
      Signed-off-by: default avatarSiddh Raman Pant <code@siddh.me>
      Tested-by: default avatar <syzbot+b6c9fe29aefe68e4ad34@syzkaller.appspotmail.com>
      Link: https://lore.kernel.org/r/20220814151512.9985-1-code@siddh.me
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      66689c5c
    • Isaac J. Manjarres's avatar
      driver core: Don't probe devices after bus_type.match() probe deferral · 1142f04f
      Isaac J. Manjarres authored
      commit 25e9fbf0 upstream.
      
      Both __device_attach_driver() and __driver_attach() check the return
      code of the bus_type.match() function to see if the device needs to be
      added to the deferred probe list. After adding the device to the list,
      the logic attempts to bind the device to the driver anyway, as if the
      device had matched with the driver, which is not correct.
      
      If __device_attach_driver() detects that the device in question is not
      ready to match with a driver on the bus, then it doesn't make sense for
      the device to attempt to bind with the current driver or continue
      attempting to match with any of the other drivers on the bus. So, update
      the logic in __device_attach_driver() to reflect this.
      
      If __driver_attach() detects that a driver tried to match with a device
      that is not ready to match yet, then the driver should not attempt to bind
      with the device. However, the driver can still attempt to match and bind
      with other devices on the bus, as drivers can be bound to multiple
      devices. So, update the logic in __driver_attach() to reflect this.
      
      Fixes: 656b8035
      
       ("ARM: 8524/1: driver cohandle -EPROBE_DEFER from bus_type.match()")
      Cc: stable@vger.kernel.org
      Cc: Saravana Kannan <saravanak@google.com>
      Reported-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Tested-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Tested-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Reviewed-by: default avatarSaravana Kannan <saravanak@google.com>
      Signed-off-by: default avatarIsaac J. Manjarres <isaacmanjarres@google.com>
      Link: https://lore.kernel.org/r/20220817184026.3468620-1-isaacmanjarres@google.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1142f04f
    • Krishna Kurapati's avatar
      usb: gadget: mass_storage: Fix cdrom data transfers on MAC-OS · bb87fe79
      Krishna Kurapati authored
      commit 9d4dc16e upstream.
      
      During cdrom emulation, the response to read_toc command must contain
      the cdrom address as the number of sectors (2048 byte sized blocks)
      represented either as an absolute value (when MSF bit is '0') or in
      terms of PMin/PSec/PFrame (when MSF bit is set to '1'). Incase of
      cdrom, the fsg_lun_open call sets the sector size to 2048 bytes.
      
      When MAC OS sends a read_toc request with MSF set to '1', the
      store_cdrom_address assumes that the address being provided is the
      LUN size represented in 512 byte sized blocks instead of 2048. It
      tries to modify the address further to convert it to 2048 byte sized
      blocks and store it in MSF format. This results in data transfer
      failures as the cdrom address being provided in the read_toc response
      is incorrect.
      
      Fixes: 3f565a36
      
       ("usb: gadget: storage: adapt logic block size to bound block devices")
      Cc: stable@vger.kernel.org
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarKrishna Kurapati <quic_kriskura@quicinc.com>
      Link: https://lore.kernel.org/r/1661570110-19127-1-git-send-email-quic_kriskura@quicinc.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bb87fe79
    • Alan Stern's avatar
      USB: core: Prevent nested device-reset calls · df187508
      Alan Stern authored
      commit 9c6d7788
      
       upstream.
      
      Automatic kernel fuzzing revealed a recursive locking violation in
      usb-storage:
      
      ============================================
      WARNING: possible recursive locking detected
      5.18.0 #3 Not tainted
      --------------------------------------------
      kworker/1:3/1205 is trying to acquire lock:
      ffff888018638db8 (&us_interface_key[i]){+.+.}-{3:3}, at:
      usb_stor_pre_reset+0x35/0x40 drivers/usb/storage/usb.c:230
      
      but task is already holding lock:
      ffff888018638db8 (&us_interface_key[i]){+.+.}-{3:3}, at:
      usb_stor_pre_reset+0x35/0x40 drivers/usb/storage/usb.c:230
      
      ...
      
      stack backtrace:
      CPU: 1 PID: 1205 Comm: kworker/1:3 Not tainted 5.18.0 #3
      Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
      1.13.0-1ubuntu1.1 04/01/2014
      Workqueue: usb_hub_wq hub_event
      Call Trace:
      <TASK>
      __dump_stack lib/dump_stack.c:88 [inline]
      dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106
      print_deadlock_bug kernel/locking/lockdep.c:2988 [inline]
      check_deadlock kernel/locking/lockdep.c:3031 [inline]
      validate_chain kernel/locking/lockdep.c:3816 [inline]
      __lock_acquire.cold+0x152/0x3ca kernel/locking/lockdep.c:5053
      lock_acquire kernel/locking/lockdep.c:5665 [inline]
      lock_acquire+0x1ab/0x520 kernel/locking/lockdep.c:5630
      __mutex_lock_common kernel/locking/mutex.c:603 [inline]
      __mutex_lock+0x14f/0x1610 kernel/locking/mutex.c:747
      usb_stor_pre_reset+0x35/0x40 drivers/usb/storage/usb.c:230
      usb_reset_device+0x37d/0x9a0 drivers/usb/core/hub.c:6109
      r871xu_dev_remove+0x21a/0x270 drivers/staging/rtl8712/usb_intf.c:622
      usb_unbind_interface+0x1bd/0x890 drivers/usb/core/driver.c:458
      device_remove drivers/base/dd.c:545 [inline]
      device_remove+0x11f/0x170 drivers/base/dd.c:537
      __device_release_driver drivers/base/dd.c:1222 [inline]
      device_release_driver_internal+0x1a7/0x2f0 drivers/base/dd.c:1248
      usb_driver_release_interface+0x102/0x180 drivers/usb/core/driver.c:627
      usb_forced_unbind_intf+0x4d/0xa0 drivers/usb/core/driver.c:1118
      usb_reset_device+0x39b/0x9a0 drivers/usb/core/hub.c:6114
      
      This turned out not to be an error in usb-storage but rather a nested
      device reset attempt.  That is, as the rtl8712 driver was being
      unbound from a composite device in preparation for an unrelated USB
      reset (that driver does not have pre_reset or post_reset callbacks),
      its ->remove routine called usb_reset_device() -- thus nesting one
      reset call within another.
      
      Performing a reset as part of disconnect processing is a questionable
      practice at best.  However, the bug report points out that the USB
      core does not have any protection against nested resets.  Adding a
      reset_in_progress flag and testing it will prevent such errors in the
      future.
      
      Link: https://lore.kernel.org/all/CAB7eexKUpvX-JNiLzhXBDWgfg2T9e9_0Tw4HQ6keN==voRbP0g@mail.gmail.com/
      Cc: stable@vger.kernel.org
      Reported-and-tested-by: default avatarRondreis <linhaoguo86@gmail.com>
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Link: https://lore.kernel.org/r/YwkflDxvg0KWqyZK@rowland.harvard.edu
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      df187508
    • Josh Poimboeuf's avatar
      s390: fix nospec table alignments · 87b47c7f
      Josh Poimboeuf authored
      commit c9305b6c upstream.
      
      Add proper alignment for .nospec_call_table and .nospec_return_table in
      vmlinux.
      
      [hca@linux.ibm.com]: The problem with the missing alignment of the nospec
      tables exist since a long time, however only since commit e6ed91fd
      ("s390/alternatives: remove padding generation code") and with
      CONFIG_RELOCATABLE=n the kernel may also crash at boot time.
      
      The above named commit reduced the size of struct alt_instr by one byte,
      so its new size is 11 bytes. Therefore depending on the number of cpu
      alternatives the size of the __alt_instructions array maybe odd, which
      again also causes that the addresses of the nospec tables will be odd.
      
      If the address of __nospec_call_start is odd and the kernel is compiled
      With CONFIG_RELOCATABLE=n the compiler may generate code that loads the
      address of __nospec_call_start with a 'larl' instruction.
      
      This will generate incorrect code since the 'larl' instruction only works
      with even addresses. In result the members of the nospec tables will be
      accessed with an off-by-one offset, which subsequently may lead to
      addressing exceptions within __nospec_revert().
      
      Fixes: f19fbd5e
      
       ("s390: introduce execute-trampolines for branches")
      Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@kernel.org>
      Link: https://lore.kernel.org/r/8719bf1ce4a72ebdeb575200290094e9ce047bcc.1661557333.git.jpoimboe@kernel.org
      Cc: <stable@vger.kernel.org> # 4.16
      Reviewed-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      Signed-off-by: default avatarHeiko Carstens <hca@linux.ibm.com>
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      87b47c7f
    • Gerald Schaefer's avatar
      s390/hugetlb: fix prepare_hugepage_range() check for 2 GB hugepages · b604e79f
      Gerald Schaefer authored
      commit 7c8d42fd upstream.
      
      The alignment check in prepare_hugepage_range() is wrong for 2 GB
      hugepages, it only checks for 1 MB hugepage alignment.
      
      This can result in kernel crash in __unmap_hugepage_range() at the
      BUG_ON(start & ~huge_page_mask(h)) alignment check, for mappings
      created with MAP_FIXED at unaligned address.
      
      Fix this by correctly handling multiple hugepage sizes, similar to the
      generic version of prepare_hugepage_range().
      
      Fixes: d08de8e2
      
       ("s390/mm: add support for 2GB hugepages")
      Cc: <stable@vger.kernel.org> # 4.8+
      Acked-by: default avatarAlexander Gordeev <agordeev@linux.ibm.com>
      Signed-off-by: default avatarGerald Schaefer <gerald.schaefer@linux.ibm.com>
      Signed-off-by: default avatarVasily Gorbik <gor@linux.ibm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b604e79f
    • Witold Lipieta's avatar
      usb-storage: Add ignore-residue quirk for NXP PN7462AU · 33f8f830
      Witold Lipieta authored
      commit 2aa48857
      
       upstream.
      
      This is USB mass storage primary boot loader for code download on
      NXP PN7462AU.
      
      Without the quirk it is impossible to write whole memory at once as
      device restarts during the write due to bogus residue values reported.
      
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Cc: stable <stable@kernel.org>
      Signed-off-by: default avatarWitold Lipieta <witold.lipieta@thaumatec.com>
      Link: https://lore.kernel.org/r/20220809112911.462776-1-witold.lipieta@thaumatec.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      33f8f830