Skip to content
  1. Jan 01, 2024
    • Mauricio Faria de Oliveira's avatar
      loop: deprecate autoloading callback loop_probe() · a413b88c
      Mauricio Faria de Oliveira authored
      commit 23881aec upstream.
      
      The 'probe' callback in __register_blkdev() is only used under the
      CONFIG_BLOCK_LEGACY_AUTOLOAD deprecation guard.
      
      The loop_probe() function is only used for that callback, so guard it
      too, accordingly.
      
      See commit fbdee71b
      
       ("block: deprecate autoloading based on dev_t").
      
      Signed-off-by: default avatarMauricio Faria de Oliveira <mfo@canonical.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Link: https://lore.kernel.org/r/20230720143033.841001-2-mfo@canonical.com
      
      
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Cc: Sven Joachim <svenjoac@gmx.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a413b88c
    • Léo Lam's avatar
      wifi: nl80211: fix deadlock in nl80211_set_cqm_rssi (6.6.x) · 75c27bdb
      Léo Lam authored
      Commit 008afb9f3d57 ("wifi: cfg80211: fix CQM for non-range use"
      backported to 6.6.x) causes nl80211_set_cqm_rssi not to release the
      wdev lock in some of the error paths.
      
      Of course, the ensuing deadlock causes userland network managers to
      break pretty badly, and on typical systems this also causes lockups on
      on suspend, poweroff and reboot. See [1], [2], [3] for example reports.
      
      The upstream commit 7e7efdda ("wifi: cfg80211: fix CQM for non-range
      use"), committed in November 2023, is completely fine because there was
      another commit in August 2023 that removed the wdev lock:
      see commit 076fc877 ("wifi: cfg80211: remove wdev mutex").
      
      The reason things broke in 6.6.5 is that commit 4338058f6009 was applied
      without also applying 076fc877.
      
      Commit 076fc877 ("wifi: cfg80211: remove wdev mutex") is a rather
      large commit; adjusting the error handling (which is what this commit does)
      yields a much simpler patch and was tested to work properly.
      
      Fix the deadlock by releasing the lock before returning.
      
      [1] https://bugzilla.kernel.org/show_bug.cgi?id=218247
      [2] https://bbs.archlinux.org/viewtopic.php?id=290976
      [3] https://lore.kernel.org/all/87sf4belmm.fsf@turtle.gmx.de/
      
      Link: https://lore.kernel.org/stable/e374bb16-5b13-44cc-b11a-2f4eefb1ecf5@manjaro.org/
      
      
      Fixes: 008afb9f3d57 ("wifi: cfg80211: fix CQM for non-range use")
      Tested-by: default avatar"Léo Lam" <leo@leolam.fr>
      Tested-by: default avatar"Philip Müller" <philm@manjaro.org>
      Cc: stable@vger.kernel.org
      Cc: Johannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatar"Léo Lam" <leo@leolam.fr>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      75c27bdb
    • Johannes Berg's avatar
      wifi: cfg80211: fix CQM for non-range use · 15577a98
      Johannes Berg authored
      commit 7e7efdda upstream.
      
      [note: this is commit 4a7e9255 reapplied;
      that commit had been reverted in 6.6.6 because it caused regressions, see
      https://lore.kernel.org/stable/2023121450-habitual-transpose-68a1@gregkh/
      for details]
      
      My prior race fix here broke CQM when ranges aren't used, as
      the reporting worker now requires the cqm_config to be set in
      the wdev, but isn't set when there's no range configured.
      
      Rather than continuing to special-case the range version, set
      the cqm_config always and configure accordingly, also tracking
      if range was used or not to be able to clear the configuration
      appropriately with the same API, which was actually not right
      if both were implemented by a driver for some reason, as is
      the case with mac80211 (though there the implementations are
      equivalent so it doesn't matter.)
      
      Also, the original multiple-RSSI commit lost checking for the
      callback, so might have potentially crashed if a driver had
      neither implementation, and userspace tried to use it despite
      not being advertised as supported.
      
      Cc: stable@vger.kernel.org
      Fixes: 4a4b8169 ("cfg80211: Accept multiple RSSI thresholds for CQM")
      Fixes: 37c20b2e
      
       ("wifi: cfg80211: fix cqm_config access race")
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarLéo Lam <leo@leolam.fr>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      15577a98
    • Krister Johansen's avatar
      fuse: share lookup state between submount and its parent · 706448f7
      Krister Johansen authored
      commit c4d361f6
      
       upstream.
      
      Fuse submounts do not perform a lookup for the nodeid that they inherit
      from their parent.  Instead, the code decrements the nlookup on the
      submount's fuse_inode when it is instantiated, and no forget is
      performed when a submount root is evicted.
      
      Trouble arises when the submount's parent is evicted despite the
      submount itself being in use.  In this author's case, the submount was
      in a container and deatched from the initial mount namespace via a
      MNT_DEATCH operation.  When memory pressure triggered the shrinker, the
      inode from the parent was evicted, which triggered enough forgets to
      render the submount's nodeid invalid.
      
      Since submounts should still function, even if their parent goes away,
      solve this problem by sharing refcounted state between the parent and
      its submount.  When all of the references on this shared state reach
      zero, it's safe to forget the final lookup of the fuse nodeid.
      
      Signed-off-by: default avatarKrister Johansen <kjlx@templeofstupid.com>
      Cc: stable@vger.kernel.org
      Fixes: 1866d779
      
       ("fuse: Allow fuse_fill_super_common() for submounts")
      Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
      Signed-off-by: default avatarKrister Johansen <kjlx@templeofstupid.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      706448f7
    • SeongJae Park's avatar
      mm/damon/core: make damon_start() waits until kdamond_fn() starts · ec7b81b0
      SeongJae Park authored
      commit 6376a824 upstream.
      
      The cleanup tasks of kdamond threads including reset of corresponding
      DAMON context's ->kdamond field and decrease of global nr_running_ctxs
      counter is supposed to be executed by kdamond_fn().  However, commit
      0f91d133 ("mm/damon: simplify stop mechanism") made neither
      damon_start() nor damon_stop() ensure the corresponding kdamond has
      started the execution of kdamond_fn().
      
      As a result, the cleanup can be skipped if damon_stop() is called fast
      enough after the previous damon_start().  Especially the skipped reset
      of ->kdamond could cause a use-after-free.
      
      Fix it by waiting for start of kdamond_fn() execution from
      damon_start().
      
      Link: https://lkml.kernel.org/r/20231208175018.63880-1-sj@kernel.org
      Fixes: 0f91d133
      
       ("mm/damon: simplify stop mechanism")
      Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
      Reported-by: default avatarJakub Acs <acsjakub@amazon.de>
      Cc: Changbin Du <changbin.du@intel.com>
      Cc: Jakub Acs <acsjakub@amazon.de>
      Cc: <stable@vger.kernel.org> # 5.15.x
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarSeongJae Park <sj@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ec7b81b0
    • Thomas Gleixner's avatar
      x86/alternatives: Sync core before enabling interrupts · 41f4ff9f
      Thomas Gleixner authored
      commit 3ea1704a upstream.
      
      text_poke_early() does:
      
         local_irq_save(flags);
         memcpy(addr, opcode, len);
         local_irq_restore(flags);
         sync_core();
      
      That's not really correct because the synchronization should happen before
      interrupts are re-enabled to ensure that a pending interrupt observes the
      complete update of the opcodes.
      
      It's not entirely clear whether the interrupt entry provides enough
      serialization already, but moving the sync_core() invocation into interrupt
      disabled region does no harm and is obviously correct.
      
      Fixes: 6fffacb3
      
       ("x86/alternatives, jumplabel: Use text_poke_early() before mm_init()")
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
      Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: <stable@kernel.org>
      Link: https://lore.kernel.org/r/ZT6narvE%2BLxX%2B7Be@windriver.com
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      41f4ff9f
    • Marc Zyngier's avatar
      KVM: arm64: vgic: Force vcpu vgic teardown on vcpu destroy · 42537915
      Marc Zyngier authored
      commit 02e3858f
      
       upstream.
      
      When failing to create a vcpu because (for example) it has a
      duplicate vcpu_id, we destroy the vcpu. Amusingly, this leaves
      the redistributor registered with the KVM_MMIO bus.
      
      This is no good, and we should properly clean the mess. Force
      a teardown of the vgic vcpu interface, including the RD device
      before returning to the caller.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/20231207151201.3028710-4-maz@kernel.org
      
      
      Signed-off-by: default avatarOliver Upton <oliver.upton@linux.dev>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      42537915
    • Marc Zyngier's avatar
      KVM: arm64: vgic: Add a non-locking primitive for kvm_vgic_vcpu_destroy() · 5dfacfd0
      Marc Zyngier authored
      commit d26b9cb3
      
       upstream.
      
      As we are going to need to call into kvm_vgic_vcpu_destroy() without
      prior holding of the slots_lock, introduce __kvm_vgic_vcpu_destroy()
      as a non-locking primitive of kvm_vgic_vcpu_destroy().
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/20231207151201.3028710-3-maz@kernel.org
      
      
      Signed-off-by: default avatarOliver Upton <oliver.upton@linux.dev>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5dfacfd0
    • Marc Zyngier's avatar
      KVM: arm64: vgic: Simplify kvm_vgic_destroy() · 3a0fd93c
      Marc Zyngier authored
      commit 01ad29d2
      
       upstream.
      
      When destroying a vgic, we have rather cumbersome rules about
      when slots_lock and config_lock are held, resulting in fun
      buglets.
      
      The first port of call is to simplify kvm_vgic_map_resources()
      so that there is only one call to kvm_vgic_destroy() instead of
      two, with the second only holding half of the locks.
      
      For that, we kill the non-locking primitive and move the call
      outside of the locking altogether. This doesn't change anything
      (we re-acquire the locks and teardown the whole vgic), and
      simplifies the code significantly.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/r/20231207151201.3028710-2-maz@kernel.org
      
      
      Signed-off-by: default avatarOliver Upton <oliver.upton@linux.dev>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3a0fd93c
    • Yaxiong Tian's avatar
      thunderbolt: Fix memory leak in margining_port_remove() · 3339028d
      Yaxiong Tian authored
      commit ac43c912 upstream.
      
      The dentry returned by debugfs_lookup() needs to be released by calling
      dput() which is missing in margining_port_remove(). Fix this by calling
      debugfs_lookup_and_remove() that combines both and avoids the memory leak.
      
      Fixes: d0f1e0c2
      
       ("thunderbolt: Add support for receiver lane margining")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarYaxiong Tian <tianyaxiong@kylinos.cn>
      Signed-off-by: default avatarMika Westerberg <mika.westerberg@linux.intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3339028d
    • Herve Codina's avatar
      lib/vsprintf: Fix %pfwf when current node refcount == 0 · 69b6596c
      Herve Codina authored
      commit 5c47251e upstream.
      
      A refcount issue can appeared in __fwnode_link_del() due to the
      pr_debug() call:
        WARNING: CPU: 0 PID: 901 at lib/refcount.c:25 refcount_warn_saturate+0xe5/0x110
        Call Trace:
        <TASK>
        ...
        of_node_get+0x1e/0x30
        of_fwnode_get+0x28/0x40
        fwnode_full_name_string+0x34/0x90
        fwnode_string+0xdb/0x140
        ...
        vsnprintf+0x17b/0x630
        ...
        __fwnode_link_del+0x25/0xa0
        fwnode_links_purge+0x39/0xb0
        of_node_release+0xd9/0x180
        ...
      
      Indeed, an fwnode (of_node) is being destroyed and so, of_node_release()
      is called because the of_node refcount reached 0.
      From of_node_release() several function calls are done and lead to
      a pr_debug() calls with %pfwf to print the fwnode full name.
      The issue is not present if we change %pfwf to %pfwP.
      
      To print the full name, %pfwf iterates over the current node and its
      parents and obtain/drop a reference to all nodes involved.
      
      In order to allow to print the full name (%pfwf) of a node while it is
      being destroyed, do not obtain/drop a reference to this current node.
      
      Fixes: a92eb762
      
       ("lib/vsprintf: Make use of fwnode API to obtain node names and separators")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarHerve Codina <herve.codina@bootlin.com>
      Reviewed-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
      Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: default avatarPetr Mladek <pmladek@suse.com>
      Link: https://lore.kernel.org/r/20231114152655.409331-1-herve.codina@bootlin.com
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      69b6596c
    • xiongxin's avatar
      gpio: dwapb: mask/unmask IRQ when disable/enale it · 2dd6f228
      xiongxin authored
      commit 1cc3542c upstream.
      
      In the hardware implementation of the I2C HID driver based on DesignWare
      GPIO IRQ chip, when the user continues to use the I2C HID device in the
      suspend process, the I2C HID interrupt will be masked after the resume
      process is finished.
      
      This is because the disable_irq()/enable_irq() of the DesignWare GPIO
      driver does not synchronize the IRQ mask register state. In normal use
      of the I2C HID procedure, the GPIO IRQ irq_mask()/irq_unmask() functions
      are called in pairs. In case of an exception, i2c_hid_core_suspend()
      calls disable_irq() to disable the GPIO IRQ. With low probability, this
      causes irq_unmask() to not be called, which causes the GPIO IRQ to be
      masked and not unmasked in enable_irq(), raising an exception.
      
      Add synchronization to the masked register state in the
      dwapb_irq_enable()/dwapb_irq_disable() function. mask the GPIO IRQ
      before disabling it. After enabling the GPIO IRQ, unmask the IRQ.
      
      Fixes: 7779b345
      
       ("gpio: add a driver for the Synopsys DesignWare APB GPIO block")
      Cc: stable@kernel.org
      Co-developed-by: default avatarRiwen Lu <luriwen@kylinos.cn>
      Signed-off-by: default avatarRiwen Lu <luriwen@kylinos.cn>
      Signed-off-by: default avatarxiongxin <xiongxin@kylinos.cn>
      Acked-by: default avatarSerge Semin <fancer.lancer@gmail.com>
      Reviewed-by: default avatarAndy Shevchenko <andy@kernel.org>
      Signed-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2dd6f228
    • Tony Lindgren's avatar
      bus: ti-sysc: Flush posted write only after srst_udelay · ab1c3f91
      Tony Lindgren authored
      commit f71f6ff8 upstream.
      
      Commit 34539b44 ("bus: ti-sysc: Flush posted write on enable before
      reset") caused a regression reproducable on omap4 duovero where the ISS
      target module can produce interconnect errors on boot. Turns out the
      registers are not accessible until after a delay for devices needing
      a ti,sysc-delay-us value.
      
      Let's fix this by flushing the posted write only after the reset delay.
      We do flushing also for ti,sysc-delay-us using devices as that should
      trigger an interconnect error if the delay is not properly configured.
      
      Let's also add some comments while at it.
      
      Fixes: 34539b44
      
       ("bus: ti-sysc: Flush posted write on enable before reset")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ab1c3f91
    • Nam Cao's avatar
      pinctrl: starfive: jh7100: ignore disabled device tree nodes · cd9f9ef5
      Nam Cao authored
      commit 5c584f17 upstream.
      
      The driver always registers pin configurations in device tree. This can
      cause some inconvenience to users, as pin configurations in the base
      device tree cannot be disabled in the device tree overlay, even when the
      relevant devices are not used.
      
      Ignore disabled pin configuration nodes in device tree.
      
      Fixes: ec648f6b
      
       ("pinctrl: starfive: Add pinctrl driver for StarFive SoCs")
      Cc:  <stable@vger.kernel.org>
      Signed-off-by: default avatarNam Cao <namcao@linutronix.de>
      Link: https://lore.kernel.org/r/fe4c15dcc3074412326b8dc296b0cbccf79c49bf.1701422582.git.namcao@linutronix.de
      
      
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cd9f9ef5
    • Mikulas Patocka's avatar
      dm-integrity: don't modify bio's immutable bio_vec in integrity_metadata() · 7f7efa30
      Mikulas Patocka authored
      commit b86f4b79 upstream.
      
      __bio_for_each_segment assumes that the first struct bio_vec argument
      doesn't change - it calls "bio_advance_iter_single((bio), &(iter),
      (bvl).bv_len)" to advance the iterator. Unfortunately, the dm-integrity
      code changes the bio_vec with "bv.bv_len -= pos". When this code path
      is taken, the iterator would be out of sync and dm-integrity would
      report errors. This happens if the machine is out of memory and
      "kmalloc" fails.
      
      Fix this bug by making a copy of "bv" and changing the copy instead.
      
      Fixes: 7eada909
      
       ("dm: add integrity target")
      Cc: stable@vger.kernel.org	# v4.12+
      Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
      Signed-off-by: default avatarMike Snitzer <snitzer@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7f7efa30
    • Steven Rostedt (Google)'s avatar
      tracing / synthetic: Disable events after testing in synth_event_gen_test_init() · 33b976a0
      Steven Rostedt (Google) authored
      commit 88b30c7f upstream.
      
      The synth_event_gen_test module can be built in, if someone wants to run
      the tests at boot up and not have to load them.
      
      The synth_event_gen_test_init() function creates and enables the synthetic
      events and runs its tests.
      
      The synth_event_gen_test_exit() disables the events it created and
      destroys the events.
      
      If the module is builtin, the events are never disabled. The issue is, the
      events should be disable after the tests are run. This could be an issue
      if the rest of the boot up tests are enabled, as they expect the events to
      be in a known state before testing. That known state happens to be
      disabled.
      
      When CONFIG_SYNTH_EVENT_GEN_TEST=y and CONFIG_EVENT_TRACE_STARTUP_TEST=y
      a warning will trigger:
      
       Running tests on trace events:
       Testing event create_synth_test:
       Enabled event during self test!
       ------------[ cut here ]------------
       WARNING: CPU: 2 PID: 1 at kernel/trace/trace_events.c:4150 event_trace_self_tests+0x1c2/0x480
       Modules linked in:
       CPU: 2 PID: 1 Comm: swapper/0 Not tainted 6.7.0-rc2-test-00031-gb803d7c664d5-dirty #276
       Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.2-debian-1.16.2-1 04/01/2014
       RIP: 0010:event_trace_self_tests+0x1c2/0x480
       Code: bb e8 a2 ab 5d fc 48 8d 7b 48 e8 f9 3d 99 fc 48 8b 73 48 40 f6 c6 01 0f 84 d6 fe ff ff 48 c7 c7 20 b6 ad bb e8 7f ab 5d fc 90 <0f> 0b 90 48 89 df e8 d3 3d 99 fc 48 8b 1b 4c 39 f3 0f 85 2c ff ff
       RSP: 0000:ffffc9000001fdc0 EFLAGS: 00010246
       RAX: 0000000000000029 RBX: ffff88810399ca80 RCX: 0000000000000000
       RDX: 0000000000000000 RSI: ffffffffb9f19478 RDI: ffff88823c734e64
       RBP: ffff88810399f300 R08: 0000000000000000 R09: fffffbfff79eb32a
       R10: ffffffffbcf59957 R11: 0000000000000001 R12: ffff888104068090
       R13: ffffffffbc89f0a0 R14: ffffffffbc8a0f08 R15: 0000000000000078
       FS:  0000000000000000(0000) GS:ffff88823c700000(0000) knlGS:0000000000000000
       CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
       CR2: 0000000000000000 CR3: 00000001f6282001 CR4: 0000000000170ef0
       Call Trace:
        <TASK>
        ? __warn+0xa5/0x200
        ? event_trace_self_tests+0x1c2/0x480
        ? report_bug+0x1f6/0x220
        ? handle_bug+0x6f/0x90
        ? exc_invalid_op+0x17/0x50
        ? asm_exc_invalid_op+0x1a/0x20
        ? tracer_preempt_on+0x78/0x1c0
        ? event_trace_self_tests+0x1c2/0x480
        ? __pfx_event_trace_self_tests_init+0x10/0x10
        event_trace_self_tests_init+0x27/0xe0
        do_one_initcall+0xd6/0x3c0
        ? __pfx_do_one_initcall+0x10/0x10
        ? kasan_set_track+0x25/0x30
        ? rcu_is_watching+0x38/0x60
        kernel_init_freeable+0x324/0x450
        ? __pfx_kernel_init+0x10/0x10
        kernel_init+0x1f/0x1e0
        ? _raw_spin_unlock_irq+0x33/0x50
        ret_from_fork+0x34/0x60
        ? __pfx_kernel_init+0x10/0x10
        ret_from_fork_asm+0x1b/0x30
        </TASK>
      
      This is because the synth_event_gen_test_init() left the synthetic events
      that it created enabled. By having it disable them after testing, the
      other selftests will run fine.
      
      Link: https://lore.kernel.org/linux-trace-kernel/20231220111525.2f0f49b0@gandalf.local.home
      
      Cc: stable@vger.kernel.org
      Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
      Cc: Tom Zanussi <zanussi@kernel.org>
      Fixes: 9fe41efa
      
       ("tracing: Add synth event generation test module")
      Acked-by: default avatarMasami Hiramatsu (Google) <mhiramat@kernel.org>
      Reported-by: default avatarAlexander Graf <graf@amazon.com>
      Tested-by: default avatarAlexander Graf <graf@amazon.com>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      33b976a0
    • Alexander Atanasov's avatar
      scsi: core: Always send batch on reset or error handling command · d2b549d3
      Alexander Atanasov authored
      commit 066c5b46 upstream.
      
      In commit 8930a6c2 ("scsi: core: add support for request batching") the
      block layer bd->last flag was mapped to SCMD_LAST and used as an indicator
      to send the batch for the drivers that implement this feature. However, the
      error handling code was not updated accordingly.
      
      scsi_send_eh_cmnd() is used to send error handling commands and request
      sense. The problem is that request sense comes as a single command that
      gets into the batch queue and times out. As a result the device goes
      offline after several failed resets. This was observed on virtio_scsi
      during a device resize operation.
      
      [  496.316946] sd 0:0:4:0: [sdd] tag#117 scsi_eh_0: requesting sense
      [  506.786356] sd 0:0:4:0: [sdd] tag#117 scsi_send_eh_cmnd timeleft: 0
      [  506.787981] sd 0:0:4:0: [sdd] tag#117 abort
      
      To fix this always set SCMD_LAST flag in scsi_send_eh_cmnd() and
      scsi_reset_ioctl().
      
      Fixes: 8930a6c2
      
       ("scsi: core: add support for request batching")
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAlexander Atanasov <alexander.atanasov@virtuozzo.com>
      Link: https://lore.kernel.org/r/20231215121008.2881653-1-alexander.atanasov@virtuozzo.com
      
      
      Reviewed-by: default avatarMing Lei <ming.lei@redhat.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d2b549d3
    • Martin K. Petersen's avatar
      Revert "scsi: aacraid: Reply queue mapping to CPUs based on IRQ affinity" · 72e472a9
      Martin K. Petersen authored
      commit c5becf57 upstream.
      
      This reverts commit 9dc704dc.
      
      Several reports have been made indicating that this commit caused
      hangs. Numerous attempts at root causing and fixing the issue have
      been unsuccessful so let's revert for now.
      
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=217599
      
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      72e472a9
    • Geliang Tang's avatar
      selftests: mptcp: join: fix subflow_send_ack lookup · 4258274b
      Geliang Tang authored
      [ Upstream commit c8f021ee ]
      
      MPC backups tests will skip unexpected sometimes (For example, when
      compiling kernel with an older version of gcc, such as gcc-8), since
      static functions like mptcp_subflow_send_ack also be listed in
      /proc/kallsyms, with a 't' in front of it, not 'T' ('T' is for a global
      function):
      
       > grep "mptcp_subflow_send_ack" /proc/kallsyms
      
       0000000000000000 T __pfx___mptcp_subflow_send_ack
       0000000000000000 T __mptcp_subflow_send_ack
       0000000000000000 t __pfx_mptcp_subflow_send_ack
       0000000000000000 t mptcp_subflow_send_ack
      
      In this case, mptcp_lib_kallsyms_doesnt_have "mptcp_subflow_send_ack$"
      will be false, MPC backups tests will skip. This is not what we expected.
      
      The correct logic here should be: if mptcp_subflow_send_ack is not a
      global function in /proc/kallsyms, do these MPC backups tests. So a 'T'
      must be added in front of mptcp_subflow_send_ack.
      
      Fixes: 632978f0
      
       ("selftests: mptcp: join: skip MPC backups tests if not supported")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarGeliang Tang <geliang.tang@linux.dev>
      Reviewed-by: default avatarMat Martineau <martineau@kernel.org>
      Signed-off-by: default avatarMatthieu Baerts <matttbe@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4258274b
    • Ming Lei's avatar
      ublk: move ublk_cancel_dev() out of ub->mutex · a8555c86
      Ming Lei authored
      [ Upstream commit 85248d67 ]
      
      ublk_cancel_dev() just calls ublk_cancel_queue() to cancel all pending
      io commands after ublk request queue is idle. The only protection is just
      the read & write of ubq->nr_io_ready and avoid duplicated command cancel,
      so add one per-queue lock with cancel flag for providing this protection,
      meantime move ublk_cancel_dev() out of ub->mutex.
      
      Then we needn't to call io_uring_cmd_complete_in_task() to cancel
      pending command. And the same cancel logic will be re-used for
      cancelable uring command.
      
      This patch basically reverts commit ac5902f8
      
       ("ublk: fix AB-BA lockdep warning").
      
      Signed-off-by: default avatarMing Lei <ming.lei@redhat.com>
      Link: https://lore.kernel.org/r/20231009093324.957829-4-ming.lei@redhat.com
      
      
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a8555c86
    • Konstantin Meskhidze's avatar
      ubifs: fix possible dereference after free · 1c250f2c
      Konstantin Meskhidze authored
      [ Upstream commit d81efd66 ]
      
      'old_idx' could be dereferenced after free via 'rb_link_node' function
      call.
      
      Fixes: b5fda08e
      
       ("ubifs: Fix memleak when insert_old_idx() failed")
      Co-developed-by: default avatarIvanov Mikhail <ivanov.mikhail1@huawei-partners.com>
      Signed-off-by: default avatarKonstantin Meskhidze <konstantin.meskhidze@huawei.com>
      Reviewed-by: default avatarZhihao Cheng <chengzhihao1@huawei.com>
      Signed-off-by: default avatarRichard Weinberger <richard@nod.at>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1c250f2c
    • Naohiro Aota's avatar
      btrfs: zoned: no longer count fresh BG region as zone unusable · 3c42cc43
      Naohiro Aota authored
      [ Upstream commit 6a8ebc77 ]
      
      Now that we switched to write time activation, we no longer need to (and
      must not) count the fresh region as zone unusable. This commit is similar
      to revert of commit fa2068d7
      
       ("btrfs: zoned: count fresh BG
      region as zone unusable").
      
      Signed-off-by: default avatarNaohiro Aota <naohiro.aota@wdc.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3c42cc43
    • Aric Cyr's avatar
      Revert "drm/amd/display: Do not set DRR on pipe commit" · b09a6761
      Aric Cyr authored
      [ Upstream commit 36951fc9 ]
      
      This reverts commit 4f1b5e73
      
      .
      
      [Why & How]
      Original change causes a regression. Revert
      until fix is available.
      
      Reviewed-by: default avatarAric Cyr <aric.cyr@amd.com>
      Acked-by: default avatarQingqing Zhuo <qingqing.zhuo@amd.com>
      Signed-off-by: default avatarAric Cyr <aric.cyr@amd.com>
      Tested-by: default avatarDaniel Wheeler <daniel.wheeler@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b09a6761
    • Li Lingfeng's avatar
      dm thin metadata: Fix ABBA deadlock by resetting dm_bufio_client · 93da3d8a
      Li Lingfeng authored
      [ Upstream commit d4830012 ]
      
      As described in commit 8111964f ("dm thin: Fix ABBA deadlock between
      shrink_slab and dm_pool_abort_metadata"), ABBA deadlocks will be
      triggered because shrinker_rwsem currently needs to held by
      dm_pool_abort_metadata() as a side-effect of thin-pool metadata
      operation failure.
      
      The following three problem scenarios have been noticed:
      
      1) Described by commit 8111964f ("dm thin: Fix ABBA deadlock between
         shrink_slab and dm_pool_abort_metadata")
      
      2) shrinker_rwsem and throttle->lock
                P1(drop cache)                        P2(kworker)
      drop_caches_sysctl_handler
       drop_slab
        shrink_slab
         down_read(&shrinker_rwsem)  - LOCK A
         do_shrink_slab
          super_cache_scan
           prune_icache_sb
            dispose_list
             evict
              ext4_evict_inode
               ext4_clear_inode
                ext4_discard_preallocations
                 ext4_mb_load_buddy_gfp
                  ext4_mb_init_cache
                   ext4_wait_block_bitmap
                    __ext4_error
                     ext4_handle_error
                      ext4_commit_super
                       ...
                       dm_submit_bio
                                           do_worker
                                            throttle_work_update
                                             down_write(&t->lock) -- LOCK B
                                            process_deferred_bios
                                             commit
                                              metadata_operation_failed
                                               dm_pool_abort_metadata
                                                dm_block_manager_create
                                                 dm_bufio_client_create
                                                  register_shrinker
                                                   down_write(&shrinker_rwsem)
                                                   -- LOCK A
                       thin_map
                        thin_bio_map
                         thin_defer_bio_with_throttle
                          throttle_lock
                           down_read(&t->lock)  - LOCK B
      
      3) shrinker_rwsem and wait_on_buffer
                P1(drop cache)                            P2(kworker)
      drop_caches_sysctl_handler
       drop_slab
        shrink_slab
         down_read(&shrinker_rwsem)  - LOCK A
         do_shrink_slab
         ...
          ext4_wait_block_bitmap
           __ext4_error
            ext4_handle_error
             jbd2_journal_abort
              jbd2_journal_update_sb_errno
               jbd2_write_superblock
                submit_bh
                 // LOCK B
                 // RELEASE B
                                   do_worker
                                    throttle_work_update
                                     down_write(&t->lock) - LOCK B
                                    process_deferred_bios
                                     process_bio
                                     commit
                                      metadata_operation_failed
                                       dm_pool_abort_metadata
                                        dm_block_manager_create
                                         dm_bufio_client_create
                                          register_shrinker
                                           register_shrinker_prepared
                                            down_write(&shrinker_rwsem)  - LOCK A
                                     bio_endio
            wait_on_buffer
             __wait_on_buffer
      
      Fix these by resetting dm_bufio_client without holding shrinker_rwsem.
      
      Fixes: 8111964f
      
       ("dm thin: Fix ABBA deadlock between shrink_slab and dm_pool_abort_metadata")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarLi Lingfeng <lilingfeng3@huawei.com>
      Signed-off-by: default avatarMike Snitzer <snitzer@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      93da3d8a
    • Mauricio Faria de Oliveira's avatar
      loop: do not enforce max_loop hard limit by (new) default · e9779fac
      Mauricio Faria de Oliveira authored
      [ Upstream commit bb5faa99 ]
      
      Problem:
      
      The max_loop parameter is used for 2 different purposes:
      
      1) initial number of loop devices to pre-create on init
      2) maximum number of loop devices to add on access/open()
      
      Historically, its default value (zero) caused 1) to create non-zero
      number of devices (CONFIG_BLK_DEV_LOOP_MIN_COUNT), and no hard limit on
      2) to add devices with autoloading.
      
      However, the default value changed in commit 85c50197 ("loop: Fix
      the max_loop commandline argument treatment when it is set to 0") to
      CONFIG_BLK_DEV_LOOP_MIN_COUNT, for max_loop=0 not to pre-create devices.
      
      That does improve 1), but unfortunately it breaks 2), as the default
      behavior changed from no-limit to hard-limit.
      
      Example:
      
      For example, this userspace code broke for N >= CONFIG, if the user
      relied on the default value 0 for max_loop:
      
          mknod("/dev/loopN");
          open("/dev/loopN");  // now fails with ENXIO
      
      Though affected users may "fix" it with (loop.)max_loop=0, this means to
      require a kernel parameter change on stable kernel update (that commit
      Fixes: an old commit in stable).
      
      Solution:
      
      The original semantics for the default value in 2) can be applied if the
      parameter is not set (ie, default behavior).
      
      This still keeps the intended function in 1) and 2) if set, and that
      commit's intended improvement in 1) if max_loop=0.
      
      Before 85c50197:
        - default:     1) CONFIG devices   2) no limit
        - max_loop=0:  1) CONFIG devices   2) no limit
        - max_loop=X:  1) X devices        2) X limit
      
      After 85c50197:
        - default:     1) CONFIG devices   2) CONFIG limit (*)
        - max_loop=0:  1) 0 devices (*)    2) no limit
        - max_loop=X:  1) X devices        2) X limit
      
      This commit:
        - default:     1) CONFIG devices   2) no limit (*)
        - max_loop=0:  1) 0 devices        2) no limit
        - max_loop=X:  1) X devices        2) X limit
      
      Future:
      
      The issue/regression from that commit only affects code under the
      CONFIG_BLOCK_LEGACY_AUTOLOAD deprecation guard, thus the fix too is
      contained under it.
      
      Once that deprecated functionality/code is removed, the purpose 2) of
      max_loop (hard limit) is no longer in use, so the module parameter
      description can be changed then.
      
      Tests:
      
      Linux 6.4-rc7
      CONFIG_BLK_DEV_LOOP_MIN_COUNT=8
      CONFIG_BLOCK_LEGACY_AUTOLOAD=y
      
      - default (original)
      
      	# ls -1 /dev/loop*
      	/dev/loop-control
      	/dev/loop0
      	...
      	/dev/loop7
      
      	# ./test-loop
      	open: /dev/loop8: No such device or address
      
      - default (patched)
      
      	# ls -1 /dev/loop*
      	/dev/loop-control
      	/dev/loop0
      	...
      	/dev/loop7
      
      	# ./test-loop
      	#
      
      - max_loop=0 (original & patched):
      
      	# ls -1 /dev/loop*
      	/dev/loop-control
      
      	# ./test-loop
      	#
      
      - max_loop=8 (original & patched):
      
      	# ls -1 /dev/loop*
      	/dev/loop-control
      	/dev/loop0
      	...
      	/dev/loop7
      
      	# ./test-loop
      	open: /dev/loop8: No such device or address
      
      - max_loop=0 (patched; CONFIG_BLOCK_LEGACY_AUTOLOAD is not set)
      
      	# ls -1 /dev/loop*
      	/dev/loop-control
      
      	# ./test-loop
      	open: /dev/loop8: No such device or address
      
      Fixes: 85c50197
      
       ("loop: Fix the max_loop commandline argument treatment when it is set to 0")
      Signed-off-by: default avatarMauricio Faria de Oliveira <mfo@canonical.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Link: https://lore.kernel.org/r/20230720143033.841001-3-mfo@canonical.com
      
      
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e9779fac
    • Heiko Stuebner's avatar
      RISC-V: Fix do_notify_resume / do_work_pending prototype · 600043e1
      Heiko Stuebner authored
      [ Upstream commit 285b6a18 ]
      
      Commit b0f4c74e ("RISC-V: Fix unannoted hardirqs-on in return to
      userspace slow-path") renamed the do_notify_resume function to
      do_work_pending but did not change the prototype in signal.h
      Do that now, as the original function does not exist anymore.
      
      Fixes: b0f4c74e
      
       ("RISC-V: Fix unannoted hardirqs-on in return to userspace slow-path")
      Signed-off-by: default avatarHeiko Stuebner <heiko.stuebner@vrull.eu>
      Reviewed-by: default avatarAndrew Jones <ajones@ventanamicro.com>
      Reviewed-by: default avatarConor Dooley <conor.dooley@microchip.com>
      Link: https://lore.kernel.org/r/20230118142252.337103-1-heiko@sntech.de
      
      
      Signed-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      600043e1
    • JP Kobryn's avatar
      9p: prevent read overrun in protocol dump tracepoint · 764c6790
      JP Kobryn authored
      commit a931c681
      
       upstream.
      
      An out of bounds read can occur within the tracepoint 9p_protocol_dump. In
      the fast assign, there is a memcpy that uses a constant size of 32 (macro
      named P9_PROTO_DUMP_SZ). When the copy is invoked, the source buffer is not
      guaranteed match this size.  It was found that in some cases the source
      buffer size is less than 32, resulting in a read that overruns.
      
      The size of the source buffer seems to be known at the time of the
      tracepoint being invoked. The allocations happen within p9_fcall_init(),
      where the capacity field is set to the allocated size of the payload
      buffer. This patch tries to fix the overrun by changing the fixed array to
      a dynamically sized array and using the minimum of the capacity value or
      P9_PROTO_DUMP_SZ as its length. The trace log statement is adjusted to
      account for this. Note that the trace log no longer splits the payload on
      the first 16 bytes. The full payload is now logged to a single line.
      
      To repro the orignal problem, operations to a plan 9 managed resource can
      be used. The simplest approach might just be mounting a shared filesystem
      (between host and guest vm) using the plan 9 protocol while the tracepoint
      is enabled.
      
      mount -t 9p -o trans=virtio <mount_tag> <mount_path>
      
      The bpftrace program below can be used to show the out of bounds read.
      Note that a recent version of bpftrace is needed for the raw tracepoint
      support. The script was tested using v0.19.0.
      
      /* from include/net/9p/9p.h */
      struct p9_fcall {
          u32 size;
          u8 id;
          u16 tag;
          size_t offset;
          size_t capacity;
          struct kmem_cache *cache;
          u8 *sdata;
          bool zc;
      };
      
      tracepoint:9p:9p_protocol_dump
      {
          /* out of bounds read can happen when this tracepoint is enabled */
      }
      
      rawtracepoint:9p_protocol_dump
      {
          $pdu = (struct p9_fcall *)arg1;
          $dump_sz = (uint64)32;
      
          if ($dump_sz > $pdu->capacity) {
              printf("reading %zu bytes from src buffer of %zu bytes\n",
                  $dump_sz, $pdu->capacity);
          }
      }
      
      Signed-off-by: default avatarJP Kobryn <inwardvessel@gmail.com>
      Message-ID: <20231204202321.22730-1-inwardvessel@gmail.com>
      Fixes: 60ece083
      
       ("net/9p: allocate appropriate reduced message buffers")
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarChristian Schoenebeck <linux_oss@crudebyte.com>
      Signed-off-by: default avatarDominique Martinet <asmadeus@codewreck.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      764c6790
    • Ville Syrjälä's avatar
      drm/i915: Reject async flips with bigjoiner · 7d09c84d
      Ville Syrjälä authored
      commit 88a173e5 upstream.
      
      Currently async flips are busted when bigjoiner is in use.
      As a short term fix simply reject async flips in that case.
      
      Cc: stable@vger.kernel.org
      Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/9769
      
      
      Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20231211081134.2698-1-ville.syrjala@linux.intel.com
      
      
      Reviewed-by: default avatarStanislav Lisovskiy <stanislav.lisovskiy@intel.com>
      (cherry picked from commit e93bffc2
      
      )
      Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7d09c84d
    • Paulo Alcantara's avatar
      smb: client: fix OOB in smbCalcSize() · c60e10d1
      Paulo Alcantara authored
      commit b35858b3
      
       upstream.
      
      Validate @smb->WordCount to avoid reading off the end of @smb and thus
      causing the following KASAN splat:
      
        BUG: KASAN: slab-out-of-bounds in smbCalcSize+0x32/0x40 [cifs]
        Read of size 2 at addr ffff88801c024ec5 by task cifsd/1328
      
        CPU: 1 PID: 1328 Comm: cifsd Not tainted 6.7.0-rc5 #9
        Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS
        rel-1.16.2-3-gd478f380-rebuilt.opensuse.org 04/01/2014
        Call Trace:
         <TASK>
         dump_stack_lvl+0x4a/0x80
         print_report+0xcf/0x650
         ? srso_alias_return_thunk+0x5/0xfbef5
         ? srso_alias_return_thunk+0x5/0xfbef5
         ? __phys_addr+0x46/0x90
         kasan_report+0xd8/0x110
         ? smbCalcSize+0x32/0x40 [cifs]
         ? smbCalcSize+0x32/0x40 [cifs]
         kasan_check_range+0x105/0x1b0
         smbCalcSize+0x32/0x40 [cifs]
         checkSMB+0x162/0x370 [cifs]
         ? __pfx_checkSMB+0x10/0x10 [cifs]
         cifs_handle_standard+0xbc/0x2f0 [cifs]
         ? srso_alias_return_thunk+0x5/0xfbef5
         cifs_demultiplex_thread+0xed1/0x1360 [cifs]
         ? __pfx_cifs_demultiplex_thread+0x10/0x10 [cifs]
         ? srso_alias_return_thunk+0x5/0xfbef5
         ? lockdep_hardirqs_on_prepare+0x136/0x210
         ? __pfx_lock_release+0x10/0x10
         ? srso_alias_return_thunk+0x5/0xfbef5
         ? mark_held_locks+0x1a/0x90
         ? lockdep_hardirqs_on_prepare+0x136/0x210
         ? srso_alias_return_thunk+0x5/0xfbef5
         ? srso_alias_return_thunk+0x5/0xfbef5
         ? __kthread_parkme+0xce/0xf0
         ? __pfx_cifs_demultiplex_thread+0x10/0x10 [cifs]
         kthread+0x18d/0x1d0
         ? kthread+0xdb/0x1d0
         ? __pfx_kthread+0x10/0x10
         ret_from_fork+0x34/0x60
         ? __pfx_kthread+0x10/0x10
         ret_from_fork_asm+0x1b/0x30
         </TASK>
      
      This fixes CVE-2023-6606.
      
      Reported-by: default avatar <j51569436@gmail.com>
      Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218218
      
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarPaulo Alcantara (SUSE) <pc@manguebit.com>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c60e10d1
    • Paulo Alcantara's avatar
      smb: client: fix OOB in SMB2_query_info_init() · bef4315f
      Paulo Alcantara authored
      commit 33eae65c upstream.
      
      A small CIFS buffer (448 bytes) isn't big enough to hold
      SMB2_QUERY_INFO request along with user's input data from
      CIFS_QUERY_INFO ioctl.  That is, if the user passed an input buffer >
      344 bytes, the client will memcpy() off the end of @req->Buffer in
      SMB2_query_info_init() thus causing the following KASAN splat:
      
        BUG: KASAN: slab-out-of-bounds in SMB2_query_info_init+0x242/0x250 [cifs]
        Write of size 1023 at addr ffff88801308c5a8 by task a.out/1240
      
        CPU: 1 PID: 1240 Comm: a.out Not tainted 6.7.0-rc4 #5
        Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS
        rel-1.16.2-3-gd478f380-rebuilt.opensuse.org 04/01/2014
        Call Trace:
         <TASK>
         dump_stack_lvl+0x4a/0x80
         print_report+0xcf/0x650
         ? srso_alias_return_thunk+0x5/0xfbef5
         ? srso_alias_return_thunk+0x5/0xfbef5
         ? srso_alias_return_thunk+0x5/0xfbef5
         ? __phys_addr+0x46/0x90
         kasan_report+0xd8/0x110
         ? SMB2_query_info_init+0x242/0x250 [cifs]
         ? SMB2_query_info_init+0x242/0x250 [cifs]
         kasan_check_range+0x105/0x1b0
         __asan_memcpy+0x3c/0x60
         SMB2_query_info_init+0x242/0x250 [cifs]
         ? __pfx_SMB2_query_info_init+0x10/0x10 [cifs]
         ? srso_alias_return_thunk+0x5/0xfbef5
         ? smb_rqst_len+0xa6/0xc0 [cifs]
         smb2_ioctl_query_info+0x4f4/0x9a0 [cifs]
         ? __pfx_smb2_ioctl_query_info+0x10/0x10 [cifs]
         ? __pfx_cifsConvertToUTF16+0x10/0x10 [cifs]
         ? kasan_set_track+0x25/0x30
         ? srso_alias_return_thunk+0x5/0xfbef5
         ? __kasan_kmalloc+0x8f/0xa0
         ? srso_alias_return_thunk+0x5/0xfbef5
         ? cifs_strndup_to_utf16+0x12d/0x1a0 [cifs]
         ? __build_path_from_dentry_optional_prefix+0x19d/0x2d0 [cifs]
         ? __pfx_smb2_ioctl_query_info+0x10/0x10 [cifs]
         cifs_ioctl+0x11c7/0x1de0 [cifs]
         ? __pfx_cifs_ioctl+0x10/0x10 [cifs]
         ? srso_alias_return_thunk+0x5/0xfbef5
         ? rcu_is_watching+0x23/0x50
         ? srso_alias_return_thunk+0x5/0xfbef5
         ? __rseq_handle_notify_resume+0x6cd/0x850
         ? __pfx___schedule+0x10/0x10
         ? blkcg_iostat_update+0x250/0x290
         ? srso_alias_return_thunk+0x5/0xfbef5
         ? ksys_write+0xe9/0x170
         __x64_sys_ioctl+0xc9/0x100
         do_syscall_64+0x47/0xf0
         entry_SYSCALL_64_after_hwframe+0x6f/0x77
        RIP: 0033:0x7f893dde49cf
        Code: 00 48 89 44 24 18 31 c0 48 8d 44 24 60 c7 04 24 10 00 00 00 48
        89 44 24 08 48 8d 44 24 20 48 89 44 24 10 b8 10 00 00 00 0f 05 <89>
        c2 3d 00 f0 ff ff 77 18 48 8b 44 24 18 64 48 2b 04 25 28 00 00
        RSP: 002b:00007ffc03ff4160 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
        RAX: ffffffffffffffda RBX: 00007ffc03ff4378 RCX: 00007f893dde49cf
        RDX: 00007ffc03ff41d0 RSI: 00000000c018cf07 RDI: 0000000000000003
        RBP: 00007ffc03ff4260 R08: 0000000000000410 R09: 0000000000000001
        R10: 00007f893dce7300 R11: 0000000000000246 R12: 0000000000000000
        R13: 00007ffc03ff4388 R14: 00007f893df15000 R15: 0000000000406de0
         </TASK>
      
      Fix this by increasing size of SMB2_QUERY_INFO request buffers and
      validating input length to prevent other callers from overflowing @req
      in SMB2_query_info_init() as well.
      
      Fixes: f5b05d62
      
       ("cifs: add IOCTL for QUERY_INFO passthrough to userspace")
      Cc: stable@vger.kernel.org
      Reported-by: default avatarRobert Morris <rtm@csail.mit.edu>
      Signed-off-by: default avatarPaulo Alcantara <pc@manguebit.com>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bef4315f
    • Paulo Alcantara's avatar
      smb: client: fix potential OOB in cifs_dump_detail() · 71fe685b
      Paulo Alcantara authored
      commit b50492b0
      
       upstream.
      
      Validate SMB message with ->check_message() before calling
      ->calc_smb_size().
      
      Signed-off-by: default avatarPaulo Alcantara (SUSE) <pc@manguebit.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      71fe685b
    • Paulo Alcantara's avatar
      smb: client: fix OOB in cifsd when receiving compounded resps · 277832a3
      Paulo Alcantara authored
      commit a8f68b11 upstream.
      
      Validate next header's offset in ->next_header() so that it isn't
      smaller than MID_HEADER_SIZE(server) and then standard_receive3() or
      ->receive() ends up writing off the end of the buffer because
      'pdu_length - MID_HEADER_SIZE(server)' wraps up to a huge length:
      
        BUG: KASAN: slab-out-of-bounds in _copy_to_iter+0x4fc/0x840
        Write of size 701 at addr ffff88800caf407f by task cifsd/1090
      
        CPU: 0 PID: 1090 Comm: cifsd Not tainted 6.7.0-rc4 #5
        Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS
        rel-1.16.2-3-gd478f380-rebuilt.opensuse.org 04/01/2014
        Call Trace:
         <TASK>
         dump_stack_lvl+0x4a/0x80
         print_report+0xcf/0x650
         ? srso_alias_return_thunk+0x5/0xfbef5
         ? srso_alias_return_thunk+0x5/0xfbef5
         ? __phys_addr+0x46/0x90
         kasan_report+0xd8/0x110
         ? _copy_to_iter+0x4fc/0x840
         ? _copy_to_iter+0x4fc/0x840
         kasan_check_range+0x105/0x1b0
         __asan_memcpy+0x3c/0x60
         _copy_to_iter+0x4fc/0x840
         ? srso_alias_return_thunk+0x5/0xfbef5
         ? hlock_class+0x32/0xc0
         ? srso_alias_return_thunk+0x5/0xfbef5
         ? __pfx__copy_to_iter+0x10/0x10
         ? srso_alias_return_thunk+0x5/0xfbef5
         ? lock_is_held_type+0x90/0x100
         ? srso_alias_return_thunk+0x5/0xfbef5
         ? __might_resched+0x278/0x360
         ? __pfx___might_resched+0x10/0x10
         ? srso_alias_return_thunk+0x5/0xfbef5
         __skb_datagram_iter+0x2c2/0x460
         ? __pfx_simple_copy_to_iter+0x10/0x10
         skb_copy_datagram_iter+0x6c/0x110
         tcp_recvmsg_locked+0x9be/0xf40
         ? __pfx_tcp_recvmsg_locked+0x10/0x10
         ? mark_held_locks+0x5d/0x90
         ? srso_alias_return_thunk+0x5/0xfbef5
         tcp_recvmsg+0xe2/0x310
         ? __pfx_tcp_recvmsg+0x10/0x10
         ? srso_alias_return_thunk+0x5/0xfbef5
         ? srso_alias_return_thunk+0x5/0xfbef5
         ? lock_acquire+0x14a/0x3a0
         ? srso_alias_return_thunk+0x5/0xfbef5
         inet_recvmsg+0xd0/0x370
         ? __pfx_inet_recvmsg+0x10/0x10
         ? __pfx_lock_release+0x10/0x10
         ? do_raw_spin_trylock+0xd1/0x120
         sock_recvmsg+0x10d/0x150
         cifs_readv_from_socket+0x25a/0x490 [cifs]
         ? __pfx_cifs_readv_from_socket+0x10/0x10 [cifs]
         ? srso_alias_return_thunk+0x5/0xfbef5
         cifs_read_from_socket+0xb5/0x100 [cifs]
         ? __pfx_cifs_read_from_socket+0x10/0x10 [cifs]
         ? __pfx_lock_release+0x10/0x10
         ? do_raw_spin_trylock+0xd1/0x120
         ? _raw_spin_unlock+0x23/0x40
         ? srso_alias_return_thunk+0x5/0xfbef5
         ? __smb2_find_mid+0x126/0x230 [cifs]
         cifs_demultiplex_thread+0xd39/0x1270 [cifs]
         ? __pfx_cifs_demultiplex_thread+0x10/0x10 [cifs]
         ? __pfx_lock_release+0x10/0x10
         ? srso_alias_return_thunk+0x5/0xfbef5
         ? mark_held_locks+0x1a/0x90
         ? lockdep_hardirqs_on_prepare+0x136/0x210
         ? srso_alias_return_thunk+0x5/0xfbef5
         ? srso_alias_return_thunk+0x5/0xfbef5
         ? __kthread_parkme+0xce/0xf0
         ? __pfx_cifs_demultiplex_thread+0x10/0x10 [cifs]
         kthread+0x18d/0x1d0
         ? kthread+0xdb/0x1d0
         ? __pfx_kthread+0x10/0x10
         ret_from_fork+0x34/0x60
         ? __pfx_kthread+0x10/0x10
         ret_from_fork_asm+0x1b/0x30
         </TASK>
      
      Fixes: 8ce79ec3
      
       ("cifs: update multiplex loop to handle compounded responses")
      Cc: stable@vger.kernel.org
      Reported-by: default avatarRobert Morris <rtm@csail.mit.edu>
      Signed-off-by: default avatarPaulo Alcantara (SUSE) <pc@manguebit.com>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      277832a3
    • Fabio Estevam's avatar
      dt-bindings: nvmem: mxs-ocotp: Document fsl,ocotp · 3f6da210
      Fabio Estevam authored
      commit a2a8aefe upstream.
      
      Both imx23.dtsi and imx28.dtsi describe the OCOTP nodes in
      the format:
      
      compatible = "fsl,imx28-ocotp", "fsl,ocotp";
      
      Document the "fsl,ocotp" entry to fix the following schema
      warning:
      
      efuse@8002c000: compatible: ['fsl,imx23-ocotp', 'fsl,ocotp'] is too long
      from schema $id: http://devicetree.org/schemas/nvmem/mxs-ocotp.yaml#
      
      Fixes: 2c504460
      
       ("dt-bindings: nvmem: Convert MXS OCOTP to json-schema")
      Cc:  <Stable@vger.kernel.org>
      Signed-off-by: default avatarFabio Estevam <festevam@denx.de>
      Acked-by: default avatarConor Dooley <conor.dooley@microchip.com>
      Signed-off-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
      Link: https://lore.kernel.org/r/20231215111358.316727-2-srinivas.kandagatla@linaro.org
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3f6da210
    • Ronald Wahl's avatar
      net: ks8851: Fix TX stall caused by TX buffer overrun · 10925251
      Ronald Wahl authored
      commit 3dc5d445 upstream.
      
      There is a bug in the ks8851 Ethernet driver that more data is written
      to the hardware TX buffer than actually available. This is caused by
      wrong accounting of the free TX buffer space.
      
      The driver maintains a tx_space variable that represents the TX buffer
      space that is deemed to be free. The ks8851_start_xmit_spi() function
      adds an SKB to a queue if tx_space is large enough and reduces tx_space
      by the amount of buffer space it will later need in the TX buffer and
      then schedules a work item. If there is not enough space then the TX
      queue is stopped.
      
      The worker function ks8851_tx_work() dequeues all the SKBs and writes
      the data into the hardware TX buffer. The last packet will trigger an
      interrupt after it was send. Here it is assumed that all data fits into
      the TX buffer.
      
      In the interrupt routine (which runs asynchronously because it is a
      threaded interrupt) tx_space is updated with the current value from the
      hardware. Also the TX queue is woken up again.
      
      Now it could happen that after data was sent to the hardware and before
      handling the TX interrupt new data is queued in ks8851_start_xmit_spi()
      when the TX buffer space had still some space left. When the interrupt
      is actually handled tx_space is updated from the hardware but now we
      already have new SKBs queued that have not been written to the hardware
      TX buffer yet. Since tx_space has been overwritten by the value from the
      hardware the space is not accounted for.
      
      Now we have more data queued then buffer space available in the hardware
      and ks8851_tx_work() will potentially overrun the hardware TX buffer. In
      many cases it will still work because often the buffer is written out
      fast enough so that no overrun occurs but for example if the peer
      throttles us via flow control then an overrun may happen.
      
      This can be fixed in different ways. The most simple way would be to set
      tx_space to 0 before writing data to the hardware TX buffer preventing
      the queuing of more SKBs until the TX interrupt has been handled. I have
      chosen a slightly more efficient (and still rather simple) way and
      track the amount of data that is already queued and not yet written to
      the hardware. When new SKBs are to be queued the already queued amount
      of data is honoured when checking free TX buffer space.
      
      I tested this with a setup of two linked KS8851 running iperf3 between
      the two in bidirectional mode. Before the fix I got a stall after some
      minutes. With the fix I saw now issues anymore after hours.
      
      Fixes: 3ba81f3e
      
       ("net: Micrel KS8851 SPI network driver")
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Eric Dumazet <edumazet@google.com>
      Cc: Jakub Kicinski <kuba@kernel.org>
      Cc: Paolo Abeni <pabeni@redhat.com>
      Cc: Ben Dooks <ben.dooks@codethink.co.uk>
      Cc: Tristram Ha <Tristram.Ha@microchip.com>
      Cc: netdev@vger.kernel.org
      Cc: stable@vger.kernel.org # 5.10+
      Signed-off-by: default avatarRonald Wahl <ronald.wahl@raritan.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Link: https://lore.kernel.org/r/20231214181112.76052-1-rwahl@gmx.de
      
      
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      10925251
    • Rouven Czerwinski's avatar
      net: rfkill: gpio: set GPIO direction · e9df9f08
      Rouven Czerwinski authored
      commit 23484d81 upstream.
      
      Fix the undefined usage of the GPIO consumer API after retrieving the
      GPIO description with GPIO_ASIS. The API documentation mentions that
      GPIO_ASIS won't set a GPIO direction and requires the user to set a
      direction before using the GPIO.
      
      This can be confirmed on i.MX6 hardware, where rfkill-gpio is no longer
      able to enabled/disable a device, presumably because the GPIO controller
      was never configured for the output direction.
      
      Fixes: b2f750c3
      
       ("net: rfkill: gpio: prevent value glitch during probe")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarRouven Czerwinski <r.czerwinski@pengutronix.de>
      Link: https://msgid.link/20231207075835.3091694-1-r.czerwinski@pengutronix.de
      
      
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e9df9f08
    • Fedor Pchelkin's avatar
      net: 9p: avoid freeing uninit memory in p9pdu_vreadf · 80561115
      Fedor Pchelkin authored
      commit ff49bf18 upstream.
      
      If some of p9pdu_readf() calls inside case 'T' in p9pdu_vreadf() fails,
      the error path is not handled properly. *wnames or members of *wnames
      array may be left uninitialized and invalidly freed.
      
      Initialize *wnames to NULL in beginning of case 'T'. Initialize the first
      *wnames array element to NULL and nullify the failing *wnames element so
      that the error path freeing loop stops on the first NULL element and
      doesn't proceed further.
      
      Found by Linux Verification Center (linuxtesting.org).
      
      Fixes: ace51c4d
      
       ("9p: add new protocol support code")
      Signed-off-by: default avatarFedor Pchelkin <pchelkin@ispras.ru>
      Message-ID: <20231206200913.16135-1-pchelkin@ispras.ru>
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Reviewed-by: default avatarChristian Schoenebeck <linux_oss@crudebyte.com>
      Signed-off-by: default avatarDominique Martinet <asmadeus@codewreck.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      80561115
    • Christoffer Sandberg's avatar
      Input: soc_button_array - add mapping for airplane mode button · 4c775b4c
      Christoffer Sandberg authored
      commit ea371594
      
       upstream.
      
      This add a mapping for the airplane mode button on the TUXEDO Pulse Gen3.
      
      While it is physically a key it behaves more like a switch, sending a key
      down on first press and a key up on 2nd press. Therefor the switch event
      is used here. Besides this behaviour it uses the HID usage-id 0xc6
      (Wireless Radio Button) and not 0xc8 (Wireless Radio Slider Switch), but
      since neither 0xc6 nor 0xc8 are currently implemented at all in
      soc_button_array this not to standard behaviour is not put behind a quirk
      for the moment.
      
      Signed-off-by: default avatarChristoffer Sandberg <cs@tuxedo.de>
      Signed-off-by: default avatarWerner Sembach <wse@tuxedocomputers.com>
      Link: https://lore.kernel.org/r/20231215171718.80229-1-wse@tuxedocomputers.com
      
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4c775b4c
    • Jose Ignacio Tornos Martinez's avatar
      net: usb: ax88179_178a: avoid failed operations when device is disconnected · 5df2b49e
      Jose Ignacio Tornos Martinez authored
      commit aef05e34 upstream.
      
      When the device is disconnected we get the following messages showing
      failed operations:
      Nov 28 20:22:11 localhost kernel: usb 2-3: USB disconnect, device number 2
      Nov 28 20:22:11 localhost kernel: ax88179_178a 2-3:1.0 enp2s0u3: unregister 'ax88179_178a' usb-0000:02:00.0-3, ASIX AX88179 USB 3.0 Gigabit Ethernet
      Nov 28 20:22:11 localhost kernel: ax88179_178a 2-3:1.0 enp2s0u3: Failed to read reg index 0x0002: -19
      Nov 28 20:22:11 localhost kernel: ax88179_178a 2-3:1.0 enp2s0u3: Failed to write reg index 0x0002: -19
      Nov 28 20:22:11 localhost kernel: ax88179_178a 2-3:1.0 enp2s0u3 (unregistered): Failed to write reg index 0x0002: -19
      Nov 28 20:22:11 localhost kernel: ax88179_178a 2-3:1.0 enp2s0u3 (unregistered): Failed to write reg index 0x0001: -19
      Nov 28 20:22:11 localhost kernel: ax88179_178a 2-3:1.0 enp2s0u3 (unregistered): Failed to write reg index 0x0002: -19
      
      The reason is that although the device is detached, normal stop and
      unbind operations are commanded from the driver. These operations are
      not necessary in this situation, so avoid these logs when the device is
      detached if the result of the operation is -ENODEV and if the new flag
      informing about the disconnecting status is enabled.
      
      cc:  <stable@vger.kernel.org>
      Fixes: e2ca90c2
      
       ("ax88179_178a: ASIX AX88179_178A USB 3.0/2.0 to gigabit ethernet adapter driver")
      Signed-off-by: default avatarJose Ignacio Tornos Martinez <jtornosm@redhat.com>
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Link: https://lore.kernel.org/r/20231207175007.263907-1-jtornosm@redhat.com
      
      
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5df2b49e
    • Alex Lu's avatar
      Bluetooth: Add more enc key size check · 0f7bffd4
      Alex Lu authored
      commit 04a342cc
      
       upstream.
      
      When we are slave role and receives l2cap conn req when encryption has
      started, we should check the enc key size to avoid KNOB attack or BLUFFS
      attack.
      From SIG recommendation, implementations are advised to reject
      service-level connections on an encrypted baseband link with key
      strengths below 7 octets.
      A simple and clear way to achieve this is to place the enc key size
      check in hci_cc_read_enc_key_size()
      
      The btmon log below shows the case that lacks enc key size check.
      
      > HCI Event: Connect Request (0x04) plen 10
              Address: BB:22:33:44:55:99 (OUI BB-22-33)
              Class: 0x480104
                Major class: Computer (desktop, notebook, PDA, organizers)
                Minor class: Desktop workstation
                Capturing (Scanner, Microphone)
                Telephony (Cordless telephony, Modem, Headset)
              Link type: ACL (0x01)
      < HCI Command: Accept Connection Request (0x01|0x0009) plen 7
              Address: BB:22:33:44:55:99 (OUI BB-22-33)
              Role: Peripheral (0x01)
      > HCI Event: Command Status (0x0f) plen 4
            Accept Connection Request (0x01|0x0009) ncmd 2
              Status: Success (0x00)
      > HCI Event: Connect Complete (0x03) plen 11
              Status: Success (0x00)
              Handle: 1
              Address: BB:22:33:44:55:99 (OUI BB-22-33)
              Link type: ACL (0x01)
              Encryption: Disabled (0x00)
      ...
      
      > HCI Event: Encryption Change (0x08) plen 4
              Status: Success (0x00)
              Handle: 1 Address: BB:22:33:44:55:99 (OUI BB-22-33)
              Encryption: Enabled with E0 (0x01)
      < HCI Command: Read Encryption Key Size (0x05|0x0008) plen 2
              Handle: 1 Address: BB:22:33:44:55:99 (OUI BB-22-33)
      > HCI Event: Command Complete (0x0e) plen 7
            Read Encryption Key Size (0x05|0x0008) ncmd 2
              Status: Success (0x00)
              Handle: 1 Address: BB:22:33:44:55:99 (OUI BB-22-33)
              Key size: 6
      // We should check the enc key size
      ...
      
      > ACL Data RX: Handle 1 flags 0x02 dlen 12
            L2CAP: Connection Request (0x02) ident 3 len 4
              PSM: 25 (0x0019)
              Source CID: 64
      < ACL Data TX: Handle 1 flags 0x00 dlen 16
            L2CAP: Connection Response (0x03) ident 3 len 8
              Destination CID: 64
              Source CID: 64
              Result: Connection pending (0x0001)
              Status: Authorization pending (0x0002)
      > HCI Event: Number of Completed Packets (0x13) plen 5
              Num handles: 1
              Handle: 1 Address: BB:22:33:44:55:99 (OUI BB-22-33)
              Count: 1
              #35: len 16 (25 Kb/s)
              Latency: 5 msec (2-7 msec ~4 msec)
      < ACL Data TX: Handle 1 flags 0x00 dlen 16
            L2CAP: Connection Response (0x03) ident 3 len 8
              Destination CID: 64
              Source CID: 64
              Result: Connection successful (0x0000)
              Status: No further information available (0x0000)
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarAlex Lu <alex_lu@realsil.com.cn>
      Signed-off-by: default avatarMax Chou <max.chou@realtek.com>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0f7bffd4
    • Xiao Yao's avatar
      Bluetooth: MGMT/SMP: Fix address type when using SMP over BREDR/LE · 39347d64
      Xiao Yao authored
      commit 59b047bc
      
       upstream.
      
      If two Bluetooth devices both support BR/EDR and BLE, and also
      support Secure Connections, then they only need to pair once.
      The LTK generated during the LE pairing process may be converted
      into a BR/EDR link key for BR/EDR transport, and conversely, a
      link key generated during the BR/EDR SSP pairing process can be
      converted into an LTK for LE transport. Hence, the link type of
      the link key and LTK is not fixed, they can be either an LE LINK
      or an ACL LINK.
      
      Currently, in the mgmt_new_irk/ltk/crsk/link_key functions, the
      link type is fixed, which could lead to incorrect address types
      being reported to the application layer. Therefore, it is necessary
      to add link_type/addr_type to the smp_irk/ltk/crsk and link_key,
      to ensure the generation of the correct address type.
      
      SMP over BREDR:
      Before Fix:
      > ACL Data RX: Handle 11 flags 0x02 dlen 12
              BR/EDR SMP: Identity Address Information (0x09) len 7
              Address: F8:7D:76:F2:12:F3 (OUI F8-7D-76)
      @ MGMT Event: New Identity Resolving Key (0x0018) plen 30
              Random address: 00:00:00:00:00:00 (Non-Resolvable)
              LE Address: F8:7D:76:F2:12:F3 (OUI F8-7D-76)
      @ MGMT Event: New Long Term Key (0x000a) plen 37
              LE Address: F8:7D:76:F2:12:F3 (OUI F8-7D-76)
              Key type: Authenticated key from P-256 (0x03)
      
      After Fix:
      > ACL Data RX: Handle 11 flags 0x02 dlen 12
            BR/EDR SMP: Identity Address Information (0x09) len 7
              Address: F8:7D:76:F2:12:F3 (OUI F8-7D-76)
      @ MGMT Event: New Identity Resolving Key (0x0018) plen 30
              Random address: 00:00:00:00:00:00 (Non-Resolvable)
              BR/EDR Address: F8:7D:76:F2:12:F3 (OUI F8-7D-76)
      @ MGMT Event: New Long Term Key (0x000a) plen 37
              BR/EDR Address: F8:7D:76:F2:12:F3 (OUI F8-7D-76)
              Key type: Authenticated key from P-256 (0x03)
      
      SMP over LE:
      Before Fix:
      @ MGMT Event: New Identity Resolving Key (0x0018) plen 30
              Random address: 5F:5C:07:37:47:D5 (Resolvable)
              LE Address: F8:7D:76:F2:12:F3 (OUI F8-7D-76)
      @ MGMT Event: New Long Term Key (0x000a) plen 37
              LE Address: F8:7D:76:F2:12:F3 (OUI F8-7D-76)
              Key type: Authenticated key from P-256 (0x03)
      @ MGMT Event: New Link Key (0x0009) plen 26
              BR/EDR Address: F8:7D:76:F2:12:F3 (OUI F8-7D-76)
              Key type: Authenticated Combination key from P-256 (0x08)
      
      After Fix:
      @ MGMT Event: New Identity Resolving Key (0x0018) plen 30
              Random address: 5E:03:1C:00:38:21 (Resolvable)
              LE Address: F8:7D:76:F2:12:F3 (OUI F8-7D-76)
      @ MGMT Event: New Long Term Key (0x000a) plen 37
              LE Address: F8:7D:76:F2:12:F3 (OUI F8-7D-76)
              Key type: Authenticated key from P-256 (0x03)
      @ MGMT Event: New Link Key (0x0009) plen 26
              Store hint: Yes (0x01)
              LE Address: F8:7D:76:F2:12:F3 (OUI F8-7D-76)
              Key type: Authenticated Combination key from P-256 (0x08)
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarXiao Yao <xiaoyao@rock-chips.com>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      39347d64