Skip to content
  1. Mar 09, 2022
    • Sidong Yang's avatar
      btrfs: qgroup: fix deadlock between rescan worker and remove qgroup · f8d4a8ee
      Sidong Yang authored
      commit d4aef1e1 upstream.
      
      The commit e804861b ("btrfs: fix deadlock between quota disable and
      qgroup rescan worker") by Kawasaki resolves deadlock between quota
      disable and qgroup rescan worker. But also there is a deadlock case like
      it. It's about enabling or disabling quota and creating or removing
      qgroup. It can be reproduced in simple script below.
      
      for i in {1..100}
      do
          btrfs quota enable /mnt &
          btrfs qgroup create 1/0 /mnt &
          btrfs qgroup destroy 1/0 /mnt &
          btrfs quota disable /mnt &
      done
      
      Here's why the deadlock happens:
      
      1) The quota rescan task is running.
      
      2) Task A calls btrfs_quota_disable(), locks the qgroup_ioctl_lock
         mutex, and then calls btrfs_qgroup_wait_for_completion(), to wait for
         the quota rescan task to complete.
      
      3) Task B calls btrfs_remove_qgroup() and it blocks when trying to lock
         the qgroup_ioctl_lock mutex, because it's being held by task A. At that
         point task B is holding a transaction handle for the current transaction.
      
      4) The quota rescan task calls btrfs_commit_transaction(). This results
         in it waiting for all other tasks to release their handles on the
         transaction, but task B is blocked on the qgroup_ioctl_lock mutex
         while holding a handle on the transaction, and that mutex is being held
         by task A, which is waiting for the quota rescan task to complete,
         resulting in a deadlock between these 3 tasks.
      
      To resolve this issue, the thread disabling quota should unlock
      qgroup_ioctl_lock before waiting rescan completion. Move
      btrfs_qgroup_wait_for_completion() after unlock of qgroup_ioctl_lock.
      
      Fixes: e804861b
      
       ("btrfs: fix deadlock between quota disable and qgroup rescan worker")
      CC: stable@vger.kernel.org # 5.4+
      Reviewed-by: default avatarFilipe Manana <fdmanana@suse.com>
      Reviewed-by: default avatarShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
      Signed-off-by: default avatarSidong Yang <realwakka@gmail.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f8d4a8ee
    • Filipe Manana's avatar
      btrfs: fix lost prealloc extents beyond eof after full fsync · 39403d72
      Filipe Manana authored
      commit d9947887 upstream.
      
      When doing a full fsync, if we have prealloc extents beyond (or at) eof,
      and the leaves that contain them were not modified in the current
      transaction, we end up not logging them. This results in losing those
      extents when we replay the log after a power failure, since the inode is
      truncated to the current value of the logged i_size.
      
      Just like for the fast fsync path, we need to always log all prealloc
      extents starting at or beyond i_size. The fast fsync case was fixed in
      commit 471d557a ("Btrfs: fix loss of prealloc extents past i_size
      after fsync log replay") but it missed the full fsync path. The problem
      exists since the very early days, when the log tree was added by
      commit e02119d5
      
       ("Btrfs: Add a write ahead tree log to optimize
      synchronous operations").
      
      Example reproducer:
      
        $ mkfs.btrfs -f /dev/sdc
        $ mount /dev/sdc /mnt
      
        # Create our test file with many file extent items, so that they span
        # several leaves of metadata, even if the node/page size is 64K. Use
        # direct IO and not fsync/O_SYNC because it's both faster and it avoids
        # clearing the full sync flag from the inode - we want the fsync below
        # to trigger the slow full sync code path.
        $ xfs_io -f -d -c "pwrite -b 4K 0 16M" /mnt/foo
      
        # Now add two preallocated extents to our file without extending the
        # file's size. One right at i_size, and another further beyond, leaving
        # a gap between the two prealloc extents.
        $ xfs_io -c "falloc -k 16M 1M" /mnt/foo
        $ xfs_io -c "falloc -k 20M 1M" /mnt/foo
      
        # Make sure everything is durably persisted and the transaction is
        # committed. This makes all created extents to have a generation lower
        # than the generation of the transaction used by the next write and
        # fsync.
        sync
      
        # Now overwrite only the first extent, which will result in modifying
        # only the first leaf of metadata for our inode. Then fsync it. This
        # fsync will use the slow code path (inode full sync bit is set) because
        # it's the first fsync since the inode was created/loaded.
        $ xfs_io -c "pwrite 0 4K" -c "fsync" /mnt/foo
      
        # Extent list before power failure.
        $ xfs_io -c "fiemap -v" /mnt/foo
        /mnt/foo:
         EXT: FILE-OFFSET      BLOCK-RANGE      TOTAL FLAGS
           0: [0..7]:          2178048..2178055     8   0x0
           1: [8..16383]:      26632..43007     16376   0x0
           2: [16384..32767]:  2156544..2172927 16384   0x0
           3: [32768..34815]:  2172928..2174975  2048 0x800
           4: [34816..40959]:  hole              6144
           5: [40960..43007]:  2174976..2177023  2048 0x801
      
        <power fail>
      
        # Mount fs again, trigger log replay.
        $ mount /dev/sdc /mnt
      
        # Extent list after power failure and log replay.
        $ xfs_io -c "fiemap -v" /mnt/foo
        /mnt/foo:
         EXT: FILE-OFFSET      BLOCK-RANGE      TOTAL FLAGS
           0: [0..7]:          2178048..2178055     8   0x0
           1: [8..16383]:      26632..43007     16376   0x0
           2: [16384..32767]:  2156544..2172927 16384   0x1
      
        # The prealloc extents at file offsets 16M and 20M are missing.
      
      So fix this by calling btrfs_log_prealloc_extents() when we are doing a
      full fsync, so that we always log all prealloc extents beyond eof.
      
      A test case for fstests will follow soon.
      
      CC: stable@vger.kernel.org # 4.19+
      Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      39403d72
    • Randy Dunlap's avatar
      tracing: Fix return value of __setup handlers · 4dd5d331
      Randy Dunlap authored
      commit 1d02b444 upstream.
      
      __setup() handlers should generally return 1 to indicate that the
      boot options have been handled.
      
      Using invalid option values causes the entire kernel boot option
      string to be reported as Unknown and added to init's environment
      strings, polluting it.
      
        Unknown kernel command line parameters "BOOT_IMAGE=/boot/bzImage-517rc6
          kprobe_event=p,syscall_any,$arg1 trace_options=quiet
          trace_clock=jiffies", will be passed to user space.
      
       Run /sbin/init as init process
         with arguments:
           /sbin/init
         with environment:
           HOME=/
           TERM=linux
           BOOT_IMAGE=/boot/bzImage-517rc6
           kprobe_event=p,syscall_any,$arg1
           trace_options=quiet
           trace_clock=jiffies
      
      Return 1 from the __setup() handlers so that init's environment is not
      polluted with kernel boot options.
      
      Link: lore.kernel.org/r/64644a2f-4a20-bab3-1e15-3b2cdd0defe3@omprussia.ru
      Link: https://lkml.kernel.org/r/20220303031744.32356-1-rdunlap@infradead.org
      
      Cc: stable@vger.kernel.org
      Fixes: 7bcfaf54 ("tracing: Add trace_options kernel command line parameter")
      Fixes: e1e232ca ("tracing: Add trace_clock=<clock> kernel parameter")
      Fixes: 970988e1
      
       ("tracing/kprobe: Add kprobe_event= boot parameter")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Reported-by: default avatarIgor Zhbanov <i.zhbanov@omprussia.ru>
      Acked-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4dd5d331
    • Steven Rostedt (Google)'s avatar
      tracing/histogram: Fix sorting on old "cpu" value · c0f72533
      Steven Rostedt (Google) authored
      commit 1d1898f6 upstream.
      
      When trying to add a histogram against an event with the "cpu" field, it
      was impossible due to "cpu" being a keyword to key off of the running CPU.
      So to fix this, it was changed to "common_cpu" to match the other generic
      fields (like "common_pid"). But since some scripts used "cpu" for keying
      off of the CPU (for events that did not have "cpu" as a field, which is
      most of them), a backward compatibility trick was added such that if "cpu"
      was used as a key, and the event did not have "cpu" as a field name, then
      it would fallback and switch over to "common_cpu".
      
      This fix has a couple of subtle bugs. One was that when switching over to
      "common_cpu", it did not change the field name, it just set a flag. But
      the code still found a "cpu" field. The "cpu" field is used for filtering
      and is returned when the event does not have a "cpu" field.
      
      This was found by:
      
        # cd /sys/kernel/tracing
        # echo hist:key=cpu,pid:sort=cpu > events/sched/sched_wakeup/trigger
        # cat events/sched/sched_wakeup/hist
      
      Which showed the histogram unsorted:
      
      { cpu:         19, pid:       1175 } hitcount:          1
      { cpu:          6, pid:        239 } hitcount:          2
      { cpu:         23, pid:       1186 } hitcount:         14
      { cpu:         12, pid:        249 } hitcount:          2
      { cpu:          3, pid:        994 } hitcount:          5
      
      Instead of hard coding the "cpu" checks, take advantage of the fact that
      trace_event_field_field() returns a special field for "cpu" and "CPU" if
      the event does not have "cpu" as a field. This special field has the
      "filter_type" of "FILTER_CPU". Check that to test if the returned field is
      of the CPU type instead of doing the string compare.
      
      Also, fix the sorting bug by testing for the hist_field flag of
      HIST_FIELD_FL_CPU when setting up the sort routine. Otherwise it will use
      the special CPU field to know what compare routine to use, and since that
      special field does not have a size, it returns tracing_map_cmp_none.
      
      Cc: stable@vger.kernel.org
      Fixes: 1e3bac71
      
       ("tracing/histogram: Rename "cpu" to "common_cpu"")
      Reported-by: default avatarDaniel Bristot de Oliveira <bristot@kernel.org>
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c0f72533
    • William Mahon's avatar
      HID: add mapping for KEY_ALL_APPLICATIONS · 35fa6f2a
      William Mahon authored
      commit 327b89f0
      
       upstream.
      
      This patch adds a new key definition for KEY_ALL_APPLICATIONS
      and aliases KEY_DASHBOARD to it.
      
      It also maps the 0x0c/0x2a2 usage code to KEY_ALL_APPLICATIONS.
      
      Signed-off-by: default avatarWilliam Mahon <wmahon@chromium.org>
      Acked-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
      Link: https://lore.kernel.org/r/20220303035618.1.I3a7746ad05d270161a18334ae06e3b6db1a1d339@changeid
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      35fa6f2a
    • William Mahon's avatar
      HID: add mapping for KEY_DICTATE · ecefb8cc
      William Mahon authored
      commit bfa26ba3
      
       upstream.
      
      Numerous keyboards are adding dictate keys which allows for text
      messages to be dictated by a microphone.
      
      This patch adds a new key definition KEY_DICTATE and maps 0x0c/0x0d8
      usage code to this new keycode. Additionally hid-debug is adjusted to
      recognize this new usage code as well.
      
      Signed-off-by: default avatarWilliam Mahon <wmahon@chromium.org>
      Acked-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
      Link: https://lore.kernel.org/r/20220303021501.1.I5dbf50eb1a7a6734ee727bda4a8573358c6d3ec0@changeid
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ecefb8cc
    • Hans de Goede's avatar
      Input: elan_i2c - fix regulator enable count imbalance after suspend/resume · 52b984b1
      Hans de Goede authored
      commit 04b7762e
      
       upstream.
      
      Before these changes elan_suspend() would only disable the regulator
      when device_may_wakeup() returns false; whereas elan_resume() would
      unconditionally enable it, leading to an enable count imbalance when
      device_may_wakeup() returns true.
      
      This triggers the "WARN_ON(regulator->enable_count)" in regulator_put()
      when the elan_i2c driver gets unbound, this happens e.g. with the
      hot-plugable dock with Elan I2C touchpad for the Asus TF103C 2-in-1.
      
      Fix this by making the regulator_enable() call also be conditional
      on device_may_wakeup() returning false.
      
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Link: https://lore.kernel.org/r/20220131135436.29638-2-hdegoede@redhat.com
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      52b984b1
    • Hans de Goede's avatar
      Input: elan_i2c - move regulator_[en|dis]able() out of elan_[en|dis]able_power() · 16eb602e
      Hans de Goede authored
      commit 81a36d8c
      
       upstream.
      
      elan_disable_power() is called conditionally on suspend, where as
      elan_enable_power() is always called on resume. This leads to
      an imbalance in the regulator's enable count.
      
      Move the regulator_[en|dis]able() calls out of elan_[en|dis]able_power()
      in preparation of fixing this.
      
      No functional changes intended.
      
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Link: https://lore.kernel.org/r/20220131135436.29638-1-hdegoede@redhat.com
      [dtor: consolidate elan_[en|dis]able() into elan_set_power()]
      Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      16eb602e
    • 蒋家盛's avatar
      nl80211: Handle nla_memdup failures in handle_nan_filter · 3f123c30
      蒋家盛 authored
      [ Upstream commit 6ad27f52 ]
      
      As there's potential for failure of the nla_memdup(),
      check the return value.
      
      Fixes: a442b761
      
       ("cfg80211: add add_nan_func / del_nan_func")
      Signed-off-by: default avatarJiasheng Jiang <jiasheng@iscas.ac.cn>
      Link: https://lore.kernel.org/r/20220301100020.3801187-1-jiasheng@iscas.ac.cn
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3f123c30
    • Jia-Ju Bai's avatar
      net: chelsio: cxgb3: check the return value of pci_find_capability() · ec89b276
      Jia-Ju Bai authored
      [ Upstream commit 767b9825 ]
      
      The function pci_find_capability() in t3_prep_adapter() can fail, so its
      return value should be checked.
      
      Fixes: 4d22de3e
      
       ("Add support for the latest 1G/10G Chelsio adapter, T3")
      Reported-by: default avatarTOTE Robot <oslab@tsinghua.edu.cn>
      Signed-off-by: default avatarJia-Ju Bai <baijiaju1990@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ec89b276
    • 蒋家盛's avatar
      soc: fsl: qe: Check of ioremap return value · 6650fa5f
      蒋家盛 authored
      [ Upstream commit a222fd85 ]
      
      As the possible failure of the ioremap(), the par_io could be NULL.
      Therefore it should be better to check it and return error in order to
      guarantee the success of the initiation.
      But, I also notice that all the caller like mpc85xx_qe_par_io_init() in
      `arch/powerpc/platforms/85xx/common.c` don't check the return value of
      the par_io_init().
      Actually, par_io_init() needs to check to handle the potential error.
      I will submit another patch to fix that.
      Anyway, par_io_init() itsely should be fixed.
      
      Fixes: 7aa1aa6e
      
       ("QE: Move QE from arch/powerpc to drivers/soc")
      Signed-off-by: default avatarJiasheng Jiang <jiasheng@iscas.ac.cn>
      Signed-off-by: default avatarLi Yang <leoyang.li@nxp.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6650fa5f
    • Hugh Dickins's avatar
      memfd: fix F_SEAL_WRITE after shmem huge page allocated · e89c53fc
      Hugh Dickins authored
      commit f2b277c4
      
       upstream.
      
      Wangyong reports: after enabling tmpfs filesystem to support transparent
      hugepage with the following command:
      
        echo always > /sys/kernel/mm/transparent_hugepage/shmem_enabled
      
      the docker program tries to add F_SEAL_WRITE through the following
      command, but it fails unexpectedly with errno EBUSY:
      
        fcntl(5, F_ADD_SEALS, F_SEAL_WRITE) = -1.
      
      That is because memfd_tag_pins() and memfd_wait_for_pins() were never
      updated for shmem huge pages: checking page_mapcount() against
      page_count() is hopeless on THP subpages - they need to check
      total_mapcount() against page_count() on THP heads only.
      
      Make memfd_tag_pins() (compared > 1) as strict as memfd_wait_for_pins()
      (compared != 1): either can be justified, but given the non-atomic
      total_mapcount() calculation, it is better now to be strict.  Bear in
      mind that total_mapcount() itself scans all of the THP subpages, when
      choosing to take an XA_CHECK_SCHED latency break.
      
      Also fix the unlikely xa_is_value() case in memfd_wait_for_pins(): if a
      page has been swapped out since memfd_tag_pins(), then its refcount must
      have fallen, and so it can safely be untagged.
      
      Link: https://lkml.kernel.org/r/a4f79248-df75-2c8c-3df-ba3317ccb5da@google.com
      Signed-off-by: default avatarHugh Dickins <hughd@google.com>
      Reported-by: default avatarZeal Robot <zealci@zte.com.cn>
      Reported-by: default avatarwangyong <wang.yong12@zte.com.cn>
      Cc: Mike Kravetz <mike.kravetz@oracle.com>
      Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
      Cc: CGEL ZTE <cgel.zte@gmail.com>
      Cc: Kirill A. Shutemov <kirill@shutemov.name>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Yang Yang <yang.yang29@zte.com.cn>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e89c53fc
    • Sukadev Bhattiprolu's avatar
      ibmvnic: free reset-work-item when flushing · 58b07100
      Sukadev Bhattiprolu authored
      commit 8d0657f3 upstream.
      
      Fix a tiny memory leak when flushing the reset work queue.
      
      Fixes: 2770a798
      
       ("ibmvnic: Introduce hard reset recovery")
      Signed-off-by: default avatarSukadev Bhattiprolu <sukadev@linux.ibm.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      58b07100
    • Sasha Neftin's avatar
      igc: igc_write_phy_reg_gpy: drop premature return · 2e7abe2e
      Sasha Neftin authored
      commit c4208653 upstream.
      
      Similar to "igc_read_phy_reg_gpy: drop premature return" patch.
      igc_write_phy_reg_gpy checks the return value from igc_write_phy_reg_mdic
      and if it's not 0, returns immediately. By doing this, it leaves the HW
      semaphore in the acquired state.
      
      Drop this premature return statement, the function returns after
      releasing the semaphore immediately anyway.
      
      Fixes: 5586838f
      
       ("igc: Add code for PHY support")
      Suggested-by: default avatarDima Ruinskiy <dima.ruinskiy@intel.com>
      Reported-by: default avatarCorinna Vinschen <vinschen@redhat.com>
      Signed-off-by: default avatarSasha Neftin <sasha.neftin@intel.com>
      Tested-by: default avatarNaama Meir <naamax.meir@linux.intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2e7abe2e
    • Randy Dunlap's avatar
      ARM: 9182/1: mmu: fix returns from early_param() and __setup() functions · 5c215ea5
      Randy Dunlap authored
      commit 7b83299e upstream.
      
      early_param() handlers should return 0 on success.
      __setup() handlers should return 1 on success, i.e., the parameter
      has been handled. A return of 0 would cause the "option=value" string
      to be added to init's environment strings, polluting it.
      
      ../arch/arm/mm/mmu.c: In function 'test_early_cachepolicy':
      ../arch/arm/mm/mmu.c:215:1: error: no return statement in function returning non-void [-Werror=return-type]
      ../arch/arm/mm/mmu.c: In function 'test_noalign_setup':
      ../arch/arm/mm/mmu.c:221:1: error: no return statement in function returning non-void [-Werror=return-type]
      
      Fixes: b849a60e
      
       ("ARM: make cr_alignment read-only #ifndef CONFIG_CPU_CP15")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Reported-by: default avatarIgor Zhbanov <i.zhbanov@omprussia.ru>
      Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
      Cc: linux-arm-kernel@lists.infradead.org
      Cc: patches@armlinux.org.uk
      Signed-off-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5c215ea5
    • Russell King (Oracle)'s avatar
      ARM: Fix kgdb breakpoint for Thumb2 · 89b881f3
      Russell King (Oracle) authored
      commit d920eaa4
      
       upstream.
      
      The kgdb code needs to register an undef hook for the Thumb UDF
      instruction that will fault in order to be functional on Thumb2
      platforms.
      
      Reported-by: default avatarJohannes Stezenbach <js@sig21.net>
      Tested-by: default avatarJohannes Stezenbach <js@sig21.net>
      Fixes: 5cbad0eb
      
       ("kgdb: support for ARCH=arm")
      Signed-off-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      89b881f3
    • Corinna Vinschen's avatar
      igc: igc_read_phy_reg_gpy: drop premature return · 87765309
      Corinna Vinschen authored
      commit fda26354 upstream.
      
      igc_read_phy_reg_gpy checks the return value from igc_read_phy_reg_mdic
      and if it's not 0, returns immediately. By doing this, it leaves the HW
      semaphore in the acquired state.
      
      Drop this premature return statement, the function returns after
      releasing the semaphore immediately anyway.
      
      Fixes: 5586838f
      
       ("igc: Add code for PHY support")
      Signed-off-by: default avatarCorinna Vinschen <vinschen@redhat.com>
      Acked-by: default avatarSasha Neftin <sasha.neftin@intel.com>
      Tested-by: default avatarNaama Meir <naamax.meir@linux.intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      87765309
    • Brian Norris's avatar
      arm64: dts: rockchip: Switch RK3399-Gru DP to SPDIF output · 44ff6c29
      Brian Norris authored
      commit b5fbaf7d upstream.
      
      Commit b18c6c3c ("ASoC: rockchip: cdn-dp sound output use spdif")
      switched the platform to SPDIF, but we didn't fix up the device tree.
      
      Drop the pinctrl settings, because the 'spdif_bus' pins are either:
       * unused (on kevin, bob), so the settings is ~harmless
       * used by a different function (on scarlet), which causes probe
         failures (!!)
      
      Fixes: b18c6c3c
      
       ("ASoC: rockchip: cdn-dp sound output use spdif")
      Signed-off-by: default avatarBrian Norris <briannorris@chromium.org>
      Reviewed-by: default avatarChen-Yu Tsai <wenst@chromium.org>
      Link: https://lore.kernel.org/r/20220114150129.v2.1.I46f64b00508d9dff34abe1c3e8d2defdab4ea1e5@changeid
      Signed-off-by: default avatarHeiko Stuebner <heiko@sntech.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      44ff6c29
    • Vincent Mailhol's avatar
      can: gs_usb: change active_channels's type from atomic_t to u8 · d59120a4
      Vincent Mailhol authored
      commit 035b0fcf upstream.
      
      The driver uses an atomic_t variable: gs_usb:active_channels to keep
      track of the number of opened channels in order to only allocate
      memory for the URBs when this count changes from zero to one.
      
      However, the driver does not decrement the counter when an error
      occurs in gs_can_open(). This issue is fixed by changing the type from
      atomic_t to u8 and by simplifying the logic accordingly.
      
      It is safe to use an u8 here because the network stack big kernel lock
      (a.k.a. rtnl_mutex) is being hold. For details, please refer to [1].
      
      [1] https://lore.kernel.org/linux-can/CAMZ6Rq+sHpiw34ijPsmp7vbUpDtJwvVtdV7CvRZJsLixjAFfrg@mail.gmail.com/T/#t
      
      Fixes: d08e973a
      
       ("can: gs_usb: Added support for the GS_USB CAN devices")
      Link: https://lore.kernel.org/all/20220214234814.1321599-1-mailhol.vincent@wanadoo.fr
      Signed-off-by: default avatarVincent Mailhol <mailhol.vincent@wanadoo.fr>
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d59120a4
    • Fabio Estevam's avatar
      ASoC: cs4265: Fix the duplicated control name · bc653724
      Fabio Estevam authored
      commit c5487b9c upstream.
      
      Currently, the following error messages are seen during boot:
      
      asoc-simple-card sound: control 2:0:0:SPDIF Switch:0 is already present
      cs4265 1-004f: ASoC: failed to add widget SPDIF dapm kcontrol SPDIF Switch: -16
      
      Quoting Mark Brown:
      
      "The driver is just plain buggy, it defines both a regular SPIDF Switch
      control and a SND_SOC_DAPM_SWITCH() called SPDIF both of which will
      create an identically named control, it can never have loaded without
      error.  One or both of those has to be renamed or they need to be
      merged into one thing."
      
      Fix the duplicated control name by combining the two SPDIF controls here
      and move the register bits onto the DAPM widget and have DAPM control them.
      
      Fixes: f853d6b3
      
       ("ASoC: cs4265: Add a S/PDIF enable switch")
      Signed-off-by: default avatarFabio Estevam <festevam@denx.de>
      Acked-by: default avatarCharles Keepax <ckeepax@opensource.cirrus.com>
      Link: https://lore.kernel.org/r/20220215120514.1760628-1-festevam@gmail.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bc653724
    • Alyssa Ross's avatar
      firmware: arm_scmi: Remove space in MODULE_ALIAS name · cff3987e
      Alyssa Ross authored
      commit 1ba603f5 upstream.
      
      modprobe can't handle spaces in aliases. Get rid of it to fix the issue.
      
      Link: https://lore.kernel.org/r/20220211102704.128354-1-sudeep.holla@arm.com
      Fixes: aa4f886f
      
       ("firmware: arm_scmi: add basic driver infrastructure for SCMI")
      Reviewed-by: default avatarCristian Marussi <cristian.marussi@arm.com>
      Signed-off-by: default avatarAlyssa Ross <hi@alyssa.is>
      Signed-off-by: default avatarSudeep Holla <sudeep.holla@arm.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cff3987e
    • Jann Horn's avatar
      efivars: Respect "block" flag in efivar_entry_set_safe() · 461a26eb
      Jann Horn authored
      commit 258dd902 upstream.
      
      When the "block" flag is false, the old code would sometimes still call
      check_var_size(), which wrongly tells ->query_variable_store() that it can
      block.
      
      As far as I can tell, this can't really materialize as a bug at the moment,
      because ->query_variable_store only does something on X86 with generic EFI,
      and in that configuration we always take the efivar_entry_set_nonblocking()
      path.
      
      Fixes: ca0e30dc
      
       ("efi: Add nonblocking option to efi_query_variable_store()")
      Signed-off-by: default avatarJann Horn <jannh@google.com>
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Link: https://lore.kernel.org/r/20220218180559.1432559-1-jannh@google.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      461a26eb
    • Maciej Fijalkowski's avatar
      ixgbe: xsk: change !netif_carrier_ok() handling in ixgbe_xmit_zc() · b4f46598
      Maciej Fijalkowski authored
      commit 6c7273a2 upstream.
      
      Commit c685c69f ("ixgbe: don't do any AF_XDP zero-copy transmit if
      netif is not OK") addressed the ring transient state when
      MEM_TYPE_XSK_BUFF_POOL was being configured which in turn caused the
      interface to through down/up. Maurice reported that when carrier is not
      ok and xsk_pool is present on ring pair, ksoftirqd will consume 100% CPU
      cycles due to the constant NAPI rescheduling as ixgbe_poll() states that
      there is still some work to be done.
      
      To fix this, do not set work_done to false for a !netif_carrier_ok().
      
      Fixes: c685c69f
      
       ("ixgbe: don't do any AF_XDP zero-copy transmit if netif is not OK")
      Reported-by: default avatarMaurice Baijens <maurice.baijens@ellips.com>
      Tested-by: default avatarMaurice Baijens <maurice.baijens@ellips.com>
      Signed-off-by: default avatarMaciej Fijalkowski <maciej.fijalkowski@intel.com>
      Tested-by: default avatarSandeep Penigalapati <sandeep.penigalapati@intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b4f46598
    • Zheyu Ma's avatar
      net: arcnet: com20020: Fix null-ptr-deref in com20020pci_probe() · e50c5896
      Zheyu Ma authored
      commit bd6f1fd5 upstream.
      
      During driver initialization, the pointer of card info, i.e. the
      variable 'ci' is required. However, the definition of
      'com20020pci_id_table' reveals that this field is empty for some
      devices, which will cause null pointer dereference when initializing
      these devices.
      
      The following log reveals it:
      
      [    3.973806] KASAN: null-ptr-deref in range [0x0000000000000028-0x000000000000002f]
      [    3.973819] RIP: 0010:com20020pci_probe+0x18d/0x13e0 [com20020_pci]
      [    3.975181] Call Trace:
      [    3.976208]  local_pci_probe+0x13f/0x210
      [    3.977248]  pci_device_probe+0x34c/0x6d0
      [    3.977255]  ? pci_uevent+0x470/0x470
      [    3.978265]  really_probe+0x24c/0x8d0
      [    3.978273]  __driver_probe_device+0x1b3/0x280
      [    3.979288]  driver_probe_device+0x50/0x370
      
      Fix this by checking whether the 'ci' is a null pointer first.
      
      Fixes: 8c14f9c7
      
       ("ARCNET: add com20020 PCI IDs with metadata")
      Signed-off-by: default avatarZheyu Ma <zheyuma97@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e50c5896
    • Randy Dunlap's avatar
      net: sxgbe: fix return value of __setup handler · 044e209c
      Randy Dunlap authored
      commit 50e06ddc upstream.
      
      __setup() handlers should return 1 on success, i.e., the parameter
      has been handled. A return of 0 causes the "option=value" string to be
      added to init's environment strings, polluting it.
      
      Fixes: acc18c14 ("net: sxgbe: add EEE(Energy Efficient Ethernet) for Samsung sxgbe")
      Fixes: 1edb9ca6
      
       ("net: sxgbe: add basic framework for Samsung 10Gb ethernet driver")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Reported-by: default avatarIgor Zhbanov <i.zhbanov@omprussia.ru>
      Link: lore.kernel.org/r/64644a2f-4a20-bab3-1e15-3b2cdd0defe3@omprussia.ru
      Cc: Siva Reddy <siva.kallam@samsung.com>
      Cc: Girish K S <ks.giri@samsung.com>
      Cc: Byungho An <bh74.an@samsung.com>
      Link: https://lore.kernel.org/r/20220224033528.24640-1-rdunlap@infradead.org
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      044e209c
    • Slawomir Laba's avatar
      iavf: Fix missing check for running netdev · a54dedf6
      Slawomir Laba authored
      commit d2c0f45f upstream.
      
      The driver was queueing reset_task regardless of the netdev
      state.
      
      Do not queue the reset task in iavf_change_mtu if netdev
      is not running.
      
      Fixes: fdd4044f
      
       ("iavf: Remove timer for work triggering, use delaying work instead")
      Signed-off-by: default avatarSlawomir Laba <slawomirx.laba@intel.com>
      Signed-off-by: default avatarPhani Burra <phani.r.burra@intel.com>
      Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
      Signed-off-by: default avatarMateusz Palczewski <mateusz.palczewski@intel.com>
      Tested-by: default avatarKonrad Jankowski <konrad0.jankowski@intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a54dedf6
    • Randy Dunlap's avatar
      net: stmmac: fix return value of __setup handler · 150b8a05
      Randy Dunlap authored
      commit e01b042e upstream.
      
      __setup() handlers should return 1 on success, i.e., the parameter
      has been handled. A return of 0 causes the "option=value" string to be
      added to init's environment strings, polluting it.
      
      Fixes: 47dd7a54 ("net: add support for STMicroelectronics Ethernet controllers.")
      Fixes: f3240e28
      
       ("stmmac: remove warning when compile as built-in (V2)")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Reported-by: default avatarIgor Zhbanov <i.zhbanov@omprussia.ru>
      Link: lore.kernel.org/r/64644a2f-4a20-bab3-1e15-3b2cdd0defe3@omprussia.ru
      Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
      Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
      Cc: Jose Abreu <joabreu@synopsys.com>
      Link: https://lore.kernel.org/r/20220224033536.25056-1-rdunlap@infradead.org
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      150b8a05
    • Nicolas Escande's avatar
      mac80211: fix forwarded mesh frames AC & queue selection · e9fa4009
      Nicolas Escande authored
      commit 859ae701 upstream.
      
      There are two problems with the current code that have been highlighted
      with the AQL feature that is now enbaled by default.
      
      First problem is in ieee80211_rx_h_mesh_fwding(),
      ieee80211_select_queue_80211() is used on received packets to choose
      the sending AC queue of the forwarding packet although this function
      should only be called on TX packet (it uses ieee80211_tx_info).
      This ends with forwarded mesh packets been sent on unrelated random AC
      queue. To fix that, AC queue can directly be infered from skb->priority
      which has been extracted from QOS info (see ieee80211_parse_qos()).
      
      Second problem is the value of queue_mapping set on forwarded mesh
      frames via skb_set_queue_mapping() is not the AC of the packet but a
      hardware queue index. This may or may not work depending on AC to HW
      queue mapping which is driver specific.
      
      Both of these issues lead to improper AC selection while forwarding
      mesh packets but more importantly due to improper airtime accounting
      (which is done on a per STA, per AC basis) caused traffic stall with
      the introduction of AQL.
      
      Fixes: cf440128 ("mac80211: fix unnecessary frame drops in mesh fwding")
      Fixes: d3c1597b
      
       ("mac80211: fix forwarded mesh frame queue mapping")
      Co-developed-by: default avatarRemi Pommarel <repk@triplefau.lt>
      Signed-off-by: default avatarRemi Pommarel <repk@triplefau.lt>
      Signed-off-by: default avatarNicolas Escande <nico.escande@gmail.com>
      Link: https://lore.kernel.org/r/20220214173214.368862-1-nico.escande@gmail.com
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e9fa4009
    • Valentin Schneider's avatar
      ia64: ensure proper NUMA distance and possible map initialization · f17b27f3
      Valentin Schneider authored
      commit b22a8f7b upstream.
      
      John Paul reported a warning about bogus NUMA distance values spurred by
      commit:
      
        620a6dc4 ("sched/topology: Make sched_init_numa() use a set for the deduplicating sort")
      
      In this case, the afflicted machine comes up with a reported 256 possible
      nodes, all of which are 0 distance away from one another.  This was
      previously silently ignored, but is now caught by the aforementioned
      commit.
      
      The culprit is ia64's node_possible_map which remains unchanged from its
      initialization value of NODE_MASK_ALL.  In John's case, the machine
      doesn't have any SRAT nor SLIT table, but AIUI the possible map remains
      untouched regardless of what ACPI tables end up being parsed.  Thus,
      !online && possible nodes remain with a bogus distance of 0 (distances \in
      [0, 9] are "reserved and have no meaning" as per the ACPI spec).
      
      Follow x86 / drivers/base/arch_numa's example and set the possible map to
      the parsed map, which in this case seems to be the online map.
      
      Link: http://lore.kernel.org/r/255d6b5d-194e-eb0e-ecdd-97477a534441@physik.fu-berlin.de
      Link: https://lkml.kernel.org/r/20210318130617.896309-1-valentin.schneider@arm.com
      Fixes: 620a6dc4
      
       ("sched/topology: Make sched_init_numa() use a set for the deduplicating sort")
      Signed-off-by: default avatarValentin Schneider <valentin.schneider@arm.com>
      Reported-by: default avatarJohn Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Tested-by: default avatarJohn Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Tested-by: default avatarSergei Trofimovich <slyfox@gentoo.org>
      Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Vincent Guittot <vincent.guittot@linaro.org>
      Cc: Dietmar Eggemann <dietmar.eggemann@arm.com>
      Cc: Anatoly Pugachev <matorola@gmail.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatardann frazier <dann.frazier@canonical.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f17b27f3
    • Dietmar Eggemann's avatar
      sched/topology: Fix sched_domain_topology_level alloc in sched_init_numa() · 80998dbd
      Dietmar Eggemann authored
      commit 71e5f664
      
       upstream.
      
      Commit "sched/topology: Make sched_init_numa() use a set for the
      deduplicating sort" allocates 'i + nr_levels (level)' instead of
      'i + nr_levels + 1' sched_domain_topology_level.
      
      This led to an Oops (on Arm64 juno with CONFIG_SCHED_DEBUG):
      
      sched_init_domains
        build_sched_domains()
          __free_domain_allocs()
            __sdt_free() {
      	...
              for_each_sd_topology(tl)
      	  ...
                sd = *per_cpu_ptr(sdd->sd, j); <--
      	  ...
            }
      
      Signed-off-by: default avatarDietmar Eggemann <dietmar.eggemann@arm.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      Tested-by: default avatarVincent Guittot <vincent.guittot@linaro.org>
      Tested-by: default avatarBarry Song <song.bao.hua@hisilicon.com>
      Link: https://lkml.kernel.org/r/6000e39e-7d28-c360-9cd6-8798fd22a9bf@arm.com
      Signed-off-by: default avatardann frazier <dann.frazier@canonical.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      80998dbd
    • Valentin Schneider's avatar
      sched/topology: Make sched_init_numa() use a set for the deduplicating sort · 407ec382
      Valentin Schneider authored
      commit 620a6dc4
      
       upstream.
      
      The deduplicating sort in sched_init_numa() assumes that the first line in
      the distance table contains all unique values in the entire table. I've
      been trying to pen what this exactly means for the topology, but it's not
      straightforward. For instance, topology.c uses this example:
      
        node   0   1   2   3
          0:  10  20  20  30
          1:  20  10  20  20
          2:  20  20  10  20
          3:  30  20  20  10
      
        0 ----- 1
        |     / |
        |   /   |
        | /     |
        2 ----- 3
      
      Which works out just fine. However, if we swap nodes 0 and 1:
      
        1 ----- 0
        |     / |
        |   /   |
        | /     |
        2 ----- 3
      
      we get this distance table:
      
        node   0  1  2  3
          0:  10 20 20 20
          1:  20 10 20 30
          2:  20 20 10 20
          3:  20 30 20 10
      
      Which breaks the deduplicating sort (non-representative first line). In
      this case this would just be a renumbering exercise, but it so happens that
      we can have a deduplicating sort that goes through the whole table in O(n²)
      at the extra cost of a temporary memory allocation (i.e. any form of set).
      
      The ACPI spec (SLIT) mentions distances are encoded on 8 bits. Following
      this, implement the set as a 256-bits bitmap. Should this not be
      satisfactory (i.e. we want to support 32-bit values), then we'll have to go
      for some other sparse set implementation.
      
      This has the added benefit of letting us allocate just the right amount of
      memory for sched_domains_numa_distance[], rather than an arbitrary
      (nr_node_ids + 1).
      
      Note: DT binding equivalent (distance-map) decodes distances as 32-bit
      values.
      
      Signed-off-by: default avatarValentin Schneider <valentin.schneider@arm.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/20210122123943.1217-2-valentin.schneider@arm.com
      Signed-off-by: default avatardann frazier <dann.frazier@canonical.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      407ec382
    • Marek Marczykowski-Górecki's avatar
      xen/netfront: destroy queues before real_num_tx_queues is zeroed · b40c9126
      Marek Marczykowski-Górecki authored
      commit dcf4ff7a upstream.
      
      xennet_destroy_queues() relies on info->netdev->real_num_tx_queues to
      delete queues. Since d7dac083
      ("net-sysfs: update the queue counts in the unregistration path"),
      unregister_netdev() indirectly sets real_num_tx_queues to 0. Those two
      facts together means, that xennet_destroy_queues() called from
      xennet_remove() cannot do its job, because it's called after
      unregister_netdev(). This results in kfree-ing queues that are still
      linked in napi, which ultimately crashes:
      
          BUG: kernel NULL pointer dereference, address: 0000000000000000
          #PF: supervisor read access in kernel mode
          #PF: error_code(0x0000) - not-present page
          PGD 0 P4D 0
          Oops: 0000 [#1] PREEMPT SMP PTI
          CPU: 1 PID: 52 Comm: xenwatch Tainted: G        W         5.16.10-1.32.fc32.qubes.x86_64+ #226
          RIP: 0010:free_netdev+0xa3/0x1a0
          Code: ff 48 89 df e8 2e e9 00 00 48 8b 43 50 48 8b 08 48 8d b8 a0 fe ff ff 48 8d a9 a0 fe ff ff 49 39 c4 75 26 eb 47 e8 ed c1 66 ff <48> 8b 85 60 01 00 00 48 8d 95 60 01 00 00 48 89 ef 48 2d 60 01 00
          RSP: 0000:ffffc90000bcfd00 EFLAGS: 00010286
          RAX: 0000000000000000 RBX: ffff88800edad000 RCX: 0000000000000000
          RDX: 0000000000000001 RSI: ffffc90000bcfc30 RDI: 00000000ffffffff
          RBP: fffffffffffffea0 R08: 0000000000000000 R09: 0000000000000000
          R10: 0000000000000000 R11: 0000000000000001 R12: ffff88800edad050
          R13: ffff8880065f8f88 R14: 0000000000000000 R15: ffff8880066c6680
          FS:  0000000000000000(0000) GS:ffff8880f3300000(0000) knlGS:0000000000000000
          CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
          CR2: 0000000000000000 CR3: 00000000e998c006 CR4: 00000000003706e0
          Call Trace:
           <TASK>
           xennet_remove+0x13d/0x300 [xen_netfront]
           xenbus_dev_remove+0x6d/0xf0
           __device_release_driver+0x17a/0x240
           device_release_driver+0x24/0x30
           bus_remove_device+0xd8/0x140
           device_del+0x18b/0x410
           ? _raw_spin_unlock+0x16/0x30
           ? klist_iter_exit+0x14/0x20
           ? xenbus_dev_request_and_reply+0x80/0x80
           device_unregister+0x13/0x60
           xenbus_dev_changed+0x18e/0x1f0
           xenwatch_thread+0xc0/0x1a0
           ? do_wait_intr_irq+0xa0/0xa0
           kthread+0x16b/0x190
           ? set_kthread_struct+0x40/0x40
           ret_from_fork+0x22/0x30
           </TASK>
      
      Fix this by calling xennet_destroy_queues() from xennet_uninit(),
      when real_num_tx_queues is still available. This ensures that queues are
      destroyed when real_num_tx_queues is set to 0, regardless of how
      unregister_netdev() was called.
      
      Originally reported at
      https://github.com/QubesOS/qubes-issues/issues/7257
      
      Fixes: d7dac083
      
       ("net-sysfs: update the queue counts in the unregistration path")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMarek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b40c9126
    • Ye Bin's avatar
      block: Fix fsync always failed if once failed · fa84d44d
      Ye Bin authored
      commit 8a751893 upstream.
      
      We do test with inject error fault base on v4.19, after test some time we found
      sync /dev/sda always failed.
      [root@localhost] sync /dev/sda
      sync: error syncing '/dev/sda': Input/output error
      
      scsi log as follows:
      [19069.812296] sd 0:0:0:0: [sda] tag#64 Send: scmd 0x00000000d03a0b6b
      [19069.812302] sd 0:0:0:0: [sda] tag#64 CDB: Synchronize Cache(10) 35 00 00 00 00 00 00 00 00 00
      [19069.812533] sd 0:0:0:0: [sda] tag#64 Done: SUCCESS Result: hostbyte=DID_OK driverbyte=DRIVER_OK
      [19069.812536] sd 0:0:0:0: [sda] tag#64 CDB: Synchronize Cache(10) 35 00 00 00 00 00 00 00 00 00
      [19069.812539] sd 0:0:0:0: [sda] tag#64 scsi host busy 1 failed 0
      [19069.812542] sd 0:0:0:0: Notifying upper driver of completion (result 0)
      [19069.812546] sd 0:0:0:0: [sda] tag#64 sd_done: completed 0 of 0 bytes
      [19069.812549] sd 0:0:0:0: [sda] tag#64 0 sectors total, 0 bytes done.
      [19069.812564] print_req_error: I/O error, dev sda, sector 0
      
      ftrace log as follows:
       rep-306069 [007] .... 19654.923315: block_bio_queue: 8,0 FWS 0 + 0 [rep]
       rep-306069 [007] .... 19654.923333: block_getrq: 8,0 FWS 0 + 0 [rep]
       kworker/7:1H-250   [007] .... 19654.923352: block_rq_issue: 8,0 FF 0 () 0 + 0 [kworker/7:1H]
       <idle>-0     [007] ..s. 19654.923562: block_rq_complete: 8,0 FF () 18446744073709551615 + 0 [0]
       <idle>-0     [007] d.s. 19654.923576: block_rq_complete: 8,0 WS () 0 + 0 [-5]
      
      As 8d699663 introduce 'fq->rq_status', this data only update when 'flush_rq'
      reference count isn't zero. If flush request once failed and record error code
      in 'fq->rq_status'. If there is no chance to update 'fq->rq_status',then do fsync
      will always failed.
      To address this issue reset 'fq->rq_status' after return error code to upper layer.
      
      Fixes: 8d699663
      
      ("block: fix null pointer dereference in blk_mq_rq_timed_out()")
      Signed-off-by: default avatarYe Bin <yebin10@huawei.com>
      Reviewed-by: default avatarMing Lei <ming.lei@redhat.com>
      Link: https://lore.kernel.org/r/20211129012659.1553733-1-yebin10@huawei.com
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      [sudip: adjust context]
      Signed-off-by: default avatarSudip Mukherjee <sudipm.mukherjee@gmail.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fa84d44d
    • D. Wythe's avatar
      net/smc: fix unexpected SMC_CLC_DECL_ERR_REGRMB error cause by server · 849339fd
      D. Wythe authored
      commit 4940a1fd upstream.
      
      The problem of SMC_CLC_DECL_ERR_REGRMB on the server is very clear.
      Based on the fact that whether a new SMC connection can be accepted or
      not depends on not only the limit of conn nums, but also the available
      entries of rtoken. Since the rtoken release is trigger by peer, while
      the conn nums is decrease by local, tons of thing can happen in this
      time difference.
      
      This only thing that needs to be mentioned is that now all connection
      creations are completely protected by smc_server_lgr_pending lock, it's
      enough to check only the available entries in rtokens_used_mask.
      
      Fixes: cd6851f3
      
       ("smc: remote memory buffers (RMBs)")
      Signed-off-by: default avatarD. Wythe <alibuda@linux.alibaba.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      849339fd
    • D. Wythe's avatar
      net/smc: fix unexpected SMC_CLC_DECL_ERR_REGRMB error generated by client · 8e306a76
      D. Wythe authored
      commit 0537f0a2 upstream.
      
      The main reason for this unexpected SMC_CLC_DECL_ERR_REGRMB in client
      dues to following execution sequence:
      
      Server Conn A:           Server Conn B:			Client Conn B:
      
      smc_lgr_unregister_conn
                              smc_lgr_register_conn
                              smc_clc_send_accept     ->
                                                              smc_rtoken_add
      smcr_buf_unuse
      		->		Client Conn A:
      				smc_rtoken_delete
      
      smc_lgr_unregister_conn() makes current link available to assigned to new
      incoming connection, while smcr_buf_unuse() has not executed yet, which
      means that smc_rtoken_add may fail because of insufficient rtoken_entry,
      reversing their execution order will avoid this problem.
      
      Fixes: 3e034725
      
       ("net/smc: common functions for RMBs and send buffers")
      Signed-off-by: default avatarD. Wythe <alibuda@linux.alibaba.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8e306a76
    • Vladimir Oltean's avatar
      net: dcb: flush lingering app table entries for unregistered devices · 1f5abd67
      Vladimir Oltean authored
      commit 91b0383f upstream.
      
      If I'm not mistaken (and I don't think I am), the way in which the
      dcbnl_ops work is that drivers call dcb_ieee_setapp() and this populates
      the application table with dynamically allocated struct dcb_app_type
      entries that are kept in the module-global dcb_app_list.
      
      However, nobody keeps exact track of these entries, and although
      dcb_ieee_delapp() is supposed to remove them, nobody does so when the
      interface goes away (example: driver unbinds from device). So the
      dcb_app_list will contain lingering entries with an ifindex that no
      longer matches any device in dcb_app_lookup().
      
      Reclaim the lost memory by listening for the NETDEV_UNREGISTER event and
      flushing the app table entries of interfaces that are now gone.
      
      In fact something like this used to be done as part of the initial
      commit (blamed below), but it was done in dcbnl_exit() -> dcb_flushapp(),
      essentially at module_exit time. That became dead code after commit
      7a6b6f51 ("DCB: fix kconfig option") which essentially merged
      "tristate config DCB" and "bool config DCBNL" into a single "bool config
      DCB", so net/dcb/dcbnl.c could not be built as a module anymore.
      
      Commit 36b9ad80 ("net/dcb: make dcbnl.c explicitly non-modular")
      recognized this and deleted dcbnl_exit() and dcb_flushapp() altogether,
      leaving us with the version we have today.
      
      Since flushing application table entries can and should be done as soon
      as the netdevice disappears, fundamentally the commit that is to blame
      is the one that introduced the design of this API.
      
      Fixes: 9ab933ab
      
       ("dcbnl: add appliction tlv handlers")
      Signed-off-by: default avatarVladimir Oltean <vladimir.oltean@nxp.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1f5abd67
    • Sven Eckelmann's avatar
      batman-adv: Don't expect inter-netns unique iflink indices · ed053680
      Sven Eckelmann authored
      commit 6c1f41af upstream.
      
      The ifindex doesn't have to be unique for multiple network namespaces on
      the same machine.
      
        $ ip netns add test1
        $ ip -net test1 link add dummy1 type dummy
        $ ip netns add test2
        $ ip -net test2 link add dummy2 type dummy
      
        $ ip -net test1 link show dev dummy1
        6: dummy1: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
            link/ether 96:81:55:1e:dd:85 brd ff:ff:ff:ff:ff:ff
        $ ip -net test2 link show dev dummy2
        6: dummy2: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
            link/ether 5a:3c:af:35:07:c3 brd ff:ff:ff:ff:ff:ff
      
      But the batman-adv code to walk through the various layers of virtual
      interfaces uses this assumption because dev_get_iflink handles it
      internally and doesn't return the actual netns of the iflink. And
      dev_get_iflink only documents the situation where ifindex == iflink for
      physical devices.
      
      But only checking for dev->netdev_ops->ndo_get_iflink is also not an option
      because ipoib_get_iflink implements it even when it sometimes returns an
      iflink != ifindex and sometimes iflink == ifindex. The caller must
      therefore make sure itself to check both netns and iflink + ifindex for
      equality. Only when they are equal, a "physical" interface was detected
      which should stop the traversal. On the other hand, vxcan_get_iflink can
      also return 0 in case there was currently no valid peer. In this case, it
      is still necessary to stop.
      
      Fixes: b7eddd0b ("batman-adv: prevent using any virtual device created on batman-adv as hard-interface")
      Fixes: 5ed4a460
      
       ("batman-adv: additional checks for virtual interfaces on top of WiFi")
      Reported-by: default avatarSabrina Dubroca <sd@queasysnail.net>
      Signed-off-by: default avatarSven Eckelmann <sven@narfation.org>
      Signed-off-by: default avatarSimon Wunderlich <sw@simonwunderlich.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ed053680
    • Sven Eckelmann's avatar
      batman-adv: Request iflink once in batadv_get_real_netdevice · 86395322
      Sven Eckelmann authored
      commit 6116ba09 upstream.
      
      There is no need to call dev_get_iflink multiple times for the same
      net_device in batadv_get_real_netdevice. And since some of the
      ndo_get_iflink callbacks are dynamic (for example via RCUs like in
      vxcan_get_iflink), it could easily happen that the returned values are not
      stable. The pre-checks before __dev_get_by_index are then of course bogus.
      
      Fixes: 5ed4a460
      
       ("batman-adv: additional checks for virtual interfaces on top of WiFi")
      Signed-off-by: default avatarSven Eckelmann <sven@narfation.org>
      Signed-off-by: default avatarSimon Wunderlich <sw@simonwunderlich.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      86395322
    • Sven Eckelmann's avatar
      batman-adv: Request iflink once in batadv-on-batadv check · a1ccea61
      Sven Eckelmann authored
      commit 690bb6fb upstream.
      
      There is no need to call dev_get_iflink multiple times for the same
      net_device in batadv_is_on_batman_iface. And since some of the
      .ndo_get_iflink callbacks are dynamic (for example via RCUs like in
      vxcan_get_iflink), it could easily happen that the returned values are not
      stable. The pre-checks before __dev_get_by_index are then of course bogus.
      
      Fixes: b7eddd0b
      
       ("batman-adv: prevent using any virtual device created on batman-adv as hard-interface")
      Signed-off-by: default avatarSven Eckelmann <sven@narfation.org>
      Signed-off-by: default avatarSimon Wunderlich <sw@simonwunderlich.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a1ccea61
    • Florian Westphal's avatar
      netfilter: nf_queue: fix possible use-after-free · 43c25da4
      Florian Westphal authored
      commit c3873070 upstream.
      
      Eric Dumazet says:
        The sock_hold() side seems suspect, because there is no guarantee
        that sk_refcnt is not already 0.
      
      On failure, we cannot queue the packet and need to indicate an
      error.  The packet will be dropped by the caller.
      
      v2: split skb prefetch hunk into separate change
      
      Fixes: 271b72c7
      
       ("udp: RCU handling for Unicast packets.")
      Reported-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
      Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
      Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      43c25da4