Skip to content
  1. Mar 30, 2021
    • Potnuri Bharat Teja's avatar
      RDMA/cxgb4: Fix adapter LE hash errors while destroying ipv6 listening server · b8775456
      Potnuri Bharat Teja authored
      [ Upstream commit 3408be14 ]
      
      Not setting the ipv6 bit while destroying ipv6 listening servers may
      result in potential fatal adapter errors due to lookup engine memory hash
      errors. Therefore always set ipv6 field while destroying ipv6 listening
      servers.
      
      Fixes: 830662f6
      
       ("RDMA/cxgb4: Add support for active and passive open connection with IPv6 address")
      Link: https://lore.kernel.org/r/20210324190453.8171-1-bharat@chelsio.com
      Signed-off-by: default avatarPotnuri Bharat Teja <bharat@chelsio.com>
      Reviewed-by: default avatarLeon Romanovsky <leonro@nvidia.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b8775456
    • Johan Hovold's avatar
      net: cdc-phonet: fix data-interface release on probe failure · 2000a40f
      Johan Hovold authored
      [ Upstream commit c79a7070 ]
      
      Set the disconnected flag before releasing the data interface in case
      netdev registration fails to avoid having the disconnect callback try to
      deregister the never registered netdev (and trigger a WARN_ON()).
      
      Fixes: 87cf6560
      
       ("USB host CDC Phonet network interface driver")
      Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2000a40f
    • Johannes Berg's avatar
      mac80211: fix rate mask reset · 3baa6365
      Johannes Berg authored
      [ Upstream commit 1944015f
      
       ]
      
      Coverity reported the strange "if (~...)" condition that's
      always true. It suggested that ! was intended instead of ~,
      but upon further analysis I'm convinced that what really was
      intended was a comparison to 0xff/0xffff (in HT/VHT cases
      respectively), since this indicates that all of the rates
      are enabled.
      
      Change the comparison accordingly.
      
      I'm guessing this never really mattered because a reset to
      not having a rate mask is basically equivalent to having a
      mask that enables all rates.
      
      Reported-by: default avatarColin Ian King <colin.king@canonical.com>
      Fixes: 2ffbe6d3 ("mac80211: fix and optimize MCS mask handling")
      Fixes: b119ad6e
      
       ("mac80211: add rate mask logic for vht rates")
      Reviewed-by: default avatarColin Ian King <colin.king@canonical.com>
      Link: https://lore.kernel.org/r/20210212112213.36b38078f569.I8546a20c80bc1669058eb453e213630b846e107b@changeid
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3baa6365
    • Torin Cooper-Bennun's avatar
      can: m_can: m_can_do_rx_poll(): fix extraneous msg loss warning · 735abed1
      Torin Cooper-Bennun authored
      [ Upstream commit c0e399f3 ]
      
      Message loss from RX FIFO 0 is already handled in
      m_can_handle_lost_msg(), with netdev output included.
      
      Removing this warning also improves driver performance under heavy
      load, where m_can_do_rx_poll() may be called many times before this
      interrupt is cleared, causing this message to be output many
      times (thanks Mariusz Madej for this report).
      
      Fixes: e0d1f481
      
       ("can: m_can: add Bosch M_CAN controller support")
      Link: https://lore.kernel.org/r/20210303103151.3760532-1-torin@maxiluxsystems.com
      Reported-by: default avatarMariusz Madej <mariusz.madej@xtrack.com>
      Signed-off-by: default avatarTorin Cooper-Bennun <torin@maxiluxsystems.com>
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      735abed1
    • Tong Zhang's avatar
      can: c_can: move runtime PM enable/disable to c_can_platform · eb05021a
      Tong Zhang authored
      [ Upstream commit 6e2fe01d ]
      
      Currently doing modprobe c_can_pci will make the kernel complain:
      
          Unbalanced pm_runtime_enable!
      
      this is caused by pm_runtime_enable() called before pm is initialized.
      
      This fix is similar to 227619c3, move those pm_enable/disable code
      to c_can_platform.
      
      Fixes: 4cdd34b2
      
       ("can: c_can: Add runtime PM support to Bosch C_CAN/D_CAN controller")
      Link: http://lore.kernel.org/r/20210302025542.987600-1-ztong0001@gmail.com
      Signed-off-by: default avatarTong Zhang <ztong0001@gmail.com>
      Tested-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      eb05021a
    • Tong Zhang's avatar
      can: c_can_pci: c_can_pci_remove(): fix use-after-free · a78e1578
      Tong Zhang authored
      [ Upstream commit 0429d6d8 ]
      
      There is a UAF in c_can_pci_remove(). dev is released by
      free_c_can_dev() and is used by pci_iounmap(pdev, priv->base) later.
      To fix this issue, save the mmio address before releasing dev.
      
      Fixes: 5b92da04
      
       ("c_can_pci: generic module for C_CAN/D_CAN on PCI")
      Link: https://lore.kernel.org/r/20210301024512.539039-1-ztong0001@gmail.com
      Signed-off-by: default avatarTong Zhang <ztong0001@gmail.com>
      Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a78e1578
    • Lv Yunlong's avatar
      net/qlcnic: Fix a use after free in qlcnic_83xx_get_minidump_template · 646b4ca2
      Lv Yunlong authored
      [ Upstream commit db74623a ]
      
      In qlcnic_83xx_get_minidump_template, fw_dump->tmpl_hdr was freed by
      vfree(). But unfortunately, it is used when extended is true.
      
      Fixes: 7061b2bd
      
       ("qlogic: Deletion of unnecessary checks before two function calls")
      Signed-off-by: default avatarLv Yunlong <lyl2019@mail.ustc.edu.cn>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      646b4ca2
    • Dinghao Liu's avatar
      e1000e: Fix error handling in e1000_set_d0_lplu_state_82571 · baf4fabc
      Dinghao Liu authored
      [ Upstream commit b52912b8 ]
      
      There is one e1e_wphy() call in e1000_set_d0_lplu_state_82571
      that we have caught its return value but lack further handling.
      Check and terminate the execution flow just like other e1e_wphy()
      in this function.
      
      Fixes: bc7f75fa
      
       ("[E1000E]: New pci-express e1000 driver (currently for ICH9 devices only)")
      Signed-off-by: default avatarDinghao Liu <dinghao.liu@zju.edu.cn>
      Acked-by: default avatarSasha Neftin <sasha.neftin@intel.com>
      Tested-by: default avatarDvora Fuxbrumer <dvorax.fuxbrumer@linux.intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      baf4fabc
    • Vitaly Lifshits's avatar
      e1000e: add rtnl_lock() to e1000_reset_task · e352ac6c
      Vitaly Lifshits authored
      [ Upstream commit 21f857f0 ]
      
      A possible race condition was found in e1000_reset_task,
      after discovering a similar issue in igb driver via
      commit 024a8168 ("igb: reinit_locked() should be called
      with rtnl_lock").
      
      Added rtnl_lock() and rtnl_unlock() to avoid this.
      
      Fixes: bc7f75fa
      
       ("[E1000E]: New pci-express e1000 driver (currently for ICH9 devices only)")
      Suggested-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarVitaly Lifshits <vitaly.lifshits@intel.com>
      Tested-by: default avatarDvora Fuxbrumer <dvorax.fuxbrumer@linux.intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e352ac6c
    • Florian Fainelli's avatar
      net: dsa: bcm_sf2: Qualify phydev->dev_flags based on port · 51838fb6
      Florian Fainelli authored
      [ Upstream commit 47142ed6 ]
      
      Similar to commit 92696286 ("net:
      bcmgenet: Set phydev->dev_flags only for internal PHYs") we need to
      qualify the phydev->dev_flags based on whether the port is connected to
      an internal or external PHY otherwise we risk having a flags collision
      with a completely different interpretation depending on the driver.
      
      Fixes: aa9aef77
      
       ("net: dsa: bcm_sf2: communicate integrated PHY revision to PHY driver")
      Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      51838fb6
    • Eric Dumazet's avatar
      macvlan: macvlan_count_rx() needs to be aware of preemption · 9bd8da26
      Eric Dumazet authored
      [ Upstream commit dd4fa1da ]
      
      macvlan_count_rx() can be called from process context, it is thus
      necessary to disable preemption before calling u64_stats_update_begin()
      
      syzbot was able to spot this on 32bit arch:
      
      WARNING: CPU: 1 PID: 4632 at include/linux/seqlock.h:271 __seqprop_assert include/linux/seqlock.h:271 [inline]
      WARNING: CPU: 1 PID: 4632 at include/linux/seqlock.h:271 __seqprop_assert.constprop.0+0xf0/0x11c include/linux/seqlock.h:269
      Modules linked in:
      Kernel panic - not syncing: panic_on_warn set ...
      CPU: 1 PID: 4632 Comm: kworker/1:3 Not tainted 5.12.0-rc2-syzkaller #0
      Hardware name: ARM-Versatile Express
      Workqueue: events macvlan_process_broadcast
      Backtrace:
      [<82740468>] (dump_backtrace) from [<827406dc>] (show_stack+0x18/0x1c arch/arm/kernel/traps.c:252)
       r7:00000080 r6:60000093 r5:00000000 r4:8422a3c4
      [<827406c4>] (show_stack) from [<82751b58>] (__dump_stack lib/dump_stack.c:79 [inline])
      [<827406c4>] (show_stack) from [<82751b58>] (dump_stack+0xb8/0xe8 lib/dump_stack.c:120)
      [<82751aa0>] (dump_stack) from [<82741270>] (panic+0x130/0x378 kernel/panic.c:231)
       r7:830209b4 r6:84069ea4 r5:00000000 r4:844350d0
      [<82741140>] (panic) from [<80244924>] (__warn+0xb0/0x164 kernel/panic.c:605)
       r3:8404ec8c r2:00000000 r1:00000000 r0:830209b4
       r7:0000010f
      [<80244874>] (__warn) from [<82741520>] (warn_slowpath_fmt+0x68/0xd4 kernel/panic.c:628)
       r7:81363f70 r6:0000010f r5:83018e50 r4:00000000
      [<827414bc>] (warn_slowpath_fmt) from [<81363f70>] (__seqprop_assert include/linux/seqlock.h:271 [inline])
      [<827414bc>] (warn_slowpath_fmt) from [<81363f70>] (__seqprop_assert.constprop.0+0xf0/0x11c include/linux/seqlock.h:269)
       r8:5a109000 r7:0000000f r6:a568dac0 r5:89802300 r4:00000001
      [<81363e80>] (__seqprop_assert.constprop.0) from [<81364af0>] (u64_stats_update_begin include/linux/u64_stats_sync.h:128 [inline])
      [<81363e80>] (__seqprop_assert.constprop.0) from [<81364af0>] (macvlan_count_rx include/linux/if_macvlan.h:47 [inline])
      [<81363e80>] (__seqprop_assert.constprop.0) from [<81364af0>] (macvlan_broadcast+0x154/0x26c drivers/net/macvlan.c:291)
       r5:89802300 r4:8a927740
      [<8136499c>] (macvlan_broadcast) from [<81365020>] (macvlan_process_broadcast+0x258/0x2d0 drivers/net/macvlan.c:317)
       r10:81364f78 r9:8a86d000 r8:8a9c7e7c r7:8413aa5c r6:00000000 r5:00000000
       r4:89802840
      [<81364dc8>] (macvlan_process_broadcast) from [<802696a4>] (process_one_work+0x2d4/0x998 kernel/workqueue.c:2275)
       r10:00000008 r9:8404ec98 r8:84367a02 r7:ddfe6400 r6:ddfe2d40 r5:898dac80
       r4:8a86d43c
      [<802693d0>] (process_one_work) from [<80269dcc>] (worker_thread+0x64/0x54c kernel/workqueue.c:2421)
       r10:00000008 r9:8a9c6000 r8:84006d00 r7:ddfe2d78 r6:898dac94 r5:ddfe2d40
       r4:898dac80
      [<80269d68>] (worker_thread) from [<80271f40>] (kthread+0x184/0x1a4 kernel/kthread.c:292)
       r10:85247e64 r9:898dac80 r8:80269d68 r7:00000000 r6:8a9c6000 r5:89a2ee40
       r4:8a97bd00
      [<80271dbc>] (kthread) from [<80200114>] (ret_from_fork+0x14/0x20 arch/arm/kernel/entry-common.S:158)
      Exception stack(0x8a9c7fb0 to 0x8a9c7ff8)
      
      Fixes: 412ca155
      
       ("macvlan: Move broadcasts into a work queue")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: Herbert Xu <herbert@gondor.apana.org.au>
      Reported-by: default avatarsyzbot <syzkaller@googlegroups.com>
      Acked-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9bd8da26
    • Grygorii Strashko's avatar
      bus: omap_l3_noc: mark l3 irqs as IRQF_NO_THREAD · a196c7df
      Grygorii Strashko authored
      [ Upstream commit 7d7275b3 ]
      
      The main purpose of l3 IRQs is to catch OCP bus access errors and identify
      corresponding code places by showing call stack, so it's important to
      handle L3 interconnect errors as fast as possible. On RT these IRQs will
      became threaded and will be scheduled much more late from the moment actual
      error occurred so showing completely useless information.
      
      Hence, mark l3 IRQs as IRQF_NO_THREAD so they will not be forced threaded
      on RT or if force_irqthreads = true.
      
      Fixes: 0ee7261c
      
       ("drivers: bus: Move the OMAP interconnect driver to drivers/bus/")
      Signed-off-by: default avatarGrygorii Strashko <grygorii.strashko@ti.com>
      Signed-off-by: default avatarTony Lindgren <tony@atomide.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a196c7df
    • Horia Geantă's avatar
      arm64: dts: ls1043a: mark crypto engine dma coherent · 7bfe5a14
      Horia Geantă authored
      commit 4fb3a074 upstream.
      
      Crypto engine (CAAM) on LS1043A platform is configured HW-coherent,
      mark accordingly the DT node.
      
      Lack of "dma-coherent" property for an IP that is configured HW-coherent
      can lead to problems, similar to what has been reported for LS1046A.
      
      Cc: <stable@vger.kernel.org> # v4.8+
      Fixes: 63dac35b
      
       ("arm64: dts: ls1043a: add crypto node")
      Link: https://lore.kernel.org/linux-crypto/fe6faa24-d8f7-d18f-adfa-44fa0caa1598@arm.com
      Signed-off-by: default avatarHoria Geantă <horia.geanta@nxp.com>
      Acked-by: default avatarLi Yang <leoyang.li@nxp.com>
      Signed-off-by: default avatarShawn Guo <shawnguo@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7bfe5a14
    • Phillip Lougher's avatar
      squashfs: fix xattr id and id lookup sanity checks · 693202c3
      Phillip Lougher authored
      commit 8b44ca2b upstream.
      
      The checks for maximum metadata block size is missing
      SQUASHFS_BLOCK_OFFSET (the two byte length count).
      
      Link: https://lkml.kernel.org/r/2069685113.2081245.1614583677427@webmail.123-reg.co.uk
      Fixes: f37aa4c7
      
       ("squashfs: add more sanity checks in id lookup")
      Signed-off-by: default avatarPhillip Lougher <phillip@squashfs.org.uk>
      Cc: Sean Nyekjaer <sean@geanix.com>
      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>
      693202c3
    • Sean Nyekjaer's avatar
      squashfs: fix inode lookup sanity checks · 31daf16c
      Sean Nyekjaer authored
      commit c1b20283 upstream.
      
      When mouting a squashfs image created without inode compression it fails
      with: "unable to read inode lookup table"
      
      It turns out that the BLOCK_OFFSET is missing when checking the
      SQUASHFS_METADATA_SIZE agaist the actual size.
      
      Link: https://lkml.kernel.org/r/20210226092903.1473545-1-sean@geanix.com
      Fixes: eabac19e
      
       ("squashfs: add more sanity checks in inode lookup")
      Signed-off-by: default avatarSean Nyekjaer <sean@geanix.com>
      Acked-by: default avatarPhillip Lougher <phillip@squashfs.org.uk>
      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>
      31daf16c
    • Borislav Petkov's avatar
      x86/tlb: Flush global mappings when KAISER is disabled · cdba20cd
      Borislav Petkov authored
      
      
      Jim Mattson reported that Debian 9 guests using a 4.9-stable kernel
      are exploding during alternatives patching:
      
        kernel BUG at /build/linux-dqnRSc/linux-4.9.228/arch/x86/kernel/alternative.c:709!
        invalid opcode: 0000 [#1] SMP
        Modules linked in:
        CPU: 1 PID: 1 Comm: swapper/0 Not tainted 4.9.0-13-amd64 #1 Debian 4.9.228-1
        Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
        Call Trace:
         swap_entry_free
         swap_entry_free
         text_poke_bp
         swap_entry_free
         arch_jump_label_transform
         set_debug_rodata
         __jump_label_update
         static_key_slow_inc
         frontswap_register_ops
         init_zswap
         init_frontswap
         do_one_initcall
         set_debug_rodata
         kernel_init_freeable
         rest_init
         kernel_init
         ret_from_fork
      
      triggering the BUG_ON in text_poke() which verifies whether patched
      instruction bytes have actually landed at the destination.
      
      Further debugging showed that the TLB flush before that check is
      insufficient because there could be global mappings left in the TLB,
      leading to a stale mapping getting used.
      
      I say "global mappings" because the hardware configuration is a new one:
      machine is an AMD, which means, KAISER/PTI doesn't need to be enabled
      there, which also means there's no user/kernel pagetables split and
      therefore the TLB can have global mappings.
      
      And the configuration is new one for a second reason: because that AMD
      machine supports PCID and INVPCID, which leads the CPU detection code to
      set the synthetic X86_FEATURE_INVPCID_SINGLE flag.
      
      Now, __native_flush_tlb_single() does invalidate global mappings when
      X86_FEATURE_INVPCID_SINGLE is *not* set and returns.
      
      When X86_FEATURE_INVPCID_SINGLE is set, however, it invalidates the
      requested address from both PCIDs in the KAISER-enabled case. But if
      KAISER is not enabled and the machine has global mappings in the TLB,
      then those global mappings do not get invalidated, which would lead to
      the above mismatch from using a stale TLB entry.
      
      So make sure to flush those global mappings in the KAISER disabled case.
      
      Co-debugged by Babu Moger <babu.moger@amd.com>.
      
      Reported-by: default avatarJim Mattson <jmattson@google.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Acked-by: default avatarHugh Dickins <hughd@google.com>
      Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Tested-by: default avatarBabu Moger <babu.moger@amd.com>
      Tested-by: default avatarJim Mattson <jmattson@google.com>
      Link: https://lkml.kernel.org/r/CALMp9eRDSW66%2BXvbHVF4ohL7XhThoPoT0BrB0TcS0cgk=dkcBg@mail.gmail.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      cdba20cd
    • Sergei Trofimovich's avatar
      ia64: fix ptrace(PTRACE_SYSCALL_INFO_EXIT) sign · a1dcff84
      Sergei Trofimovich authored
      [ Upstream commit 61bf318e
      
       ]
      
      In https://bugs.gentoo.org/769614 Dmitry noticed that
      `ptrace(PTRACE_GET_SYSCALL_INFO)` does not return error sign properly.
      
      The bug is in mismatch between get/set errors:
      
      static inline long syscall_get_error(struct task_struct *task,
                                           struct pt_regs *regs)
      {
              return regs->r10 == -1 ? regs->r8:0;
      }
      
      static inline long syscall_get_return_value(struct task_struct *task,
                                                  struct pt_regs *regs)
      {
              return regs->r8;
      }
      
      static inline void syscall_set_return_value(struct task_struct *task,
                                                  struct pt_regs *regs,
                                                  int error, long val)
      {
              if (error) {
                      /* error < 0, but ia64 uses > 0 return value */
                      regs->r8 = -error;
                      regs->r10 = -1;
              } else {
                      regs->r8 = val;
                      regs->r10 = 0;
              }
      }
      
      Tested on v5.10 on rx3600 machine (ia64 9040 CPU).
      
      Link: https://lkml.kernel.org/r/20210221002554.333076-2-slyfox@gentoo.org
      Link: https://bugs.gentoo.org/769614
      Signed-off-by: default avatarSergei Trofimovich <slyfox@gentoo.org>
      Reported-by: default avatarDmitry V. Levin <ldv@altlinux.org>
      Reviewed-by: default avatarDmitry V. Levin <ldv@altlinux.org>
      Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Cc: Oleg Nesterov <oleg@redhat.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 avatarSasha Levin <sashal@kernel.org>
      a1dcff84
    • Sergei Trofimovich's avatar
      ia64: fix ia64_syscall_get_set_arguments() for break-based syscalls · 3abc8cbd
      Sergei Trofimovich authored
      [ Upstream commit 0ceb1ace
      
       ]
      
      In https://bugs.gentoo.org/769614 Dmitry noticed that
      `ptrace(PTRACE_GET_SYSCALL_INFO)` does not work for syscalls called via
      glibc's syscall() wrapper.
      
      ia64 has two ways to call syscalls from userspace: via `break` and via
      `eps` instructions.
      
      The difference is in stack layout:
      
      1. `eps` creates simple stack frame: no locals, in{0..7} == out{0..8}
      2. `break` uses userspace stack frame: may be locals (glibc provides
         one), in{0..7} == out{0..8}.
      
      Both work fine in syscall handling cde itself.
      
      But `ptrace(PTRACE_GET_SYSCALL_INFO)` uses unwind mechanism to
      re-extract syscall arguments but it does not account for locals.
      
      The change always skips locals registers. It should not change `eps`
      path as kernel's handler already enforces locals=0 and fixes `break`.
      
      Tested on v5.10 on rx3600 machine (ia64 9040 CPU).
      
      Link: https://lkml.kernel.org/r/20210221002554.333076-1-slyfox@gentoo.org
      Link: https://bugs.gentoo.org/769614
      Signed-off-by: default avatarSergei Trofimovich <slyfox@gentoo.org>
      Reported-by: default avatarDmitry V. Levin <ldv@altlinux.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3abc8cbd
    • J. Bruce Fields's avatar
      nfs: we don't support removing system.nfs4_acl · a69c8d13
      J. Bruce Fields authored
      [ Upstream commit 4f8be1f5
      
       ]
      
      The NFSv4 protocol doesn't have any notion of reomoving an attribute, so
      removexattr(path,"system.nfs4_acl") doesn't make sense.
      
      There's no documented return value.  Arguably it could be EOPNOTSUPP but
      I'm a little worried an application might take that to mean that we
      don't support ACLs or xattrs.  How about EINVAL?
      
      Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
      Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a69c8d13
    • Peter Zijlstra's avatar
      u64_stats,lockdep: Fix u64_stats_init() vs lockdep · d54d0aaa
      Peter Zijlstra authored
      [ Upstream commit d5b0e067
      
       ]
      
      Jakub reported that:
      
          static struct net_device *rtl8139_init_board(struct pci_dev *pdev)
          {
      	    ...
      	    u64_stats_init(&tp->rx_stats.syncp);
      	    u64_stats_init(&tp->tx_stats.syncp);
      	    ...
          }
      
      results in lockdep getting confused between the RX and TX stats lock.
      This is because u64_stats_init() is an inline calling seqcount_init(),
      which is a macro using a static variable to generate a lockdep class.
      
      By wrapping that in an inline, we negate the effect of the macro and
      fold the static key variable, hence the confusion.
      
      Fix by also making u64_stats_init() a macro for the case where it
      matters, leaving the other case an inline for argument validation
      etc.
      
      Reported-by: default avatarJakub Kicinski <kuba@kernel.org>
      Debugged-by: default avatar"Ahmed S. Darwish" <a.darwish@linutronix.de>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Tested-by: default avatar"Erhard F." <erhard_f@mailbox.org>
      Link: https://lkml.kernel.org/r/YEXicy6+9MksdLZh@hirez.programming.kicks-ass.net
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d54d0aaa
    • Tong Zhang's avatar
      atm: idt77252: fix null-ptr-dereference · 1acd547e
      Tong Zhang authored
      [ Upstream commit 4416e985
      
       ]
      
      this one is similar to the phy_data allocation fix in uPD98402, the
      driver allocate the idt77105_priv and store to dev_data but later
      dereference using dev->dev_data, which will cause null-ptr-dereference.
      
      fix this issue by changing dev_data to phy_data so that PRIV(dev) can
      work correctly.
      
      Signed-off-by: default avatarTong Zhang <ztong0001@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1acd547e
    • Tong Zhang's avatar
      atm: uPD98402: fix incorrect allocation · b7c44536
      Tong Zhang authored
      [ Upstream commit 3153724f
      
       ]
      
      dev->dev_data is set in zatm.c, calling zatm_start() will overwrite this
      dev->dev_data in uPD98402_start() and a subsequent PRIV(dev)->lock
      (i.e dev->phy_data->lock) will result in a null-ptr-dereference.
      
      I believe this is a typo and what it actually want to do is to allocate
      phy_data instead of dev_data.
      
      Signed-off-by: default avatarTong Zhang <ztong0001@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b7c44536
    • Jia-Ju Bai's avatar
      net: wan: fix error return code of uhdlc_init() · ef822bd0
      Jia-Ju Bai authored
      [ Upstream commit 62765d39
      
       ]
      
      When priv->rx_skbuff or priv->tx_skbuff is NULL, no error return code of
      uhdlc_init() is assigned.
      To fix this bug, ret is assigned with -ENOMEM in these cases.
      
      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>
      ef822bd0
    • Frank Sorenson's avatar
      NFS: Correct size calculation for create reply length · 55ef4f2c
      Frank Sorenson authored
      [ Upstream commit ad3dbe35
      
       ]
      
      CREATE requests return a post_op_fh3, rather than nfs_fh3. The
      post_op_fh3 includes an extra word to indicate 'handle_follows'.
      
      Without that additional word, create fails when full 64-byte
      filehandles are in use.
      
      Add NFS3_post_op_fh_sz, and correct the size calculation for
      NFS3_createres_sz.
      
      Signed-off-by: default avatarFrank Sorenson <sorenson@redhat.com>
      Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      55ef4f2c
    • Timo Rothenpieler's avatar
      nfs: fix PNFS_FLEXFILE_LAYOUT Kconfig default · 7c34fb36
      Timo Rothenpieler authored
      [ Upstream commit a0590473 ]
      
      This follows what was done in 8c2fabc6
      
      .
      With the default being m, it's impossible to build the module into the
      kernel.
      
      Signed-off-by: default avatarTimo Rothenpieler <timo@rothenpieler.org>
      Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      7c34fb36
    • Denis Efremov's avatar
      sun/niu: fix wrong RXMAC_BC_FRM_CNT_COUNT count · 54567920
      Denis Efremov authored
      [ Upstream commit 155b23e6
      
       ]
      
      RXMAC_BC_FRM_CNT_COUNT added to mp->rx_bcasts twice in a row
      in niu_xmac_interrupt(). Remove the second addition.
      
      Signed-off-by: default avatarDenis Efremov <efremov@linux.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      54567920
    • Jia-Ju Bai's avatar
      net: tehuti: fix error return code in bdx_probe() · c8e18cb5
      Jia-Ju Bai authored
      [ Upstream commit 38c26ff3
      
       ]
      
      When bdx_read_mac() fails, no error return code of bdx_probe()
      is assigned.
      To fix this bug, err is assigned with -EFAULT as error return code.
      
      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>
      c8e18cb5
    • Dinghao Liu's avatar
      ixgbe: Fix memleak in ixgbe_configure_clsu32 · c3fab454
      Dinghao Liu authored
      [ Upstream commit 7a766381
      
       ]
      
      When ixgbe_fdir_write_perfect_filter_82599() fails,
      input allocated by kzalloc() has not been freed,
      which leads to memleak.
      
      Signed-off-by: default avatarDinghao Liu <dinghao.liu@zju.edu.cn>
      Reviewed-by: default avatarPaul Menzel <pmenzel@molgen.mpg.de>
      Tested-by: default avatarTony Brelinski <tonyx.brelinski@intel.com>
      Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c3fab454
    • Tong Zhang's avatar
      atm: lanai: dont run lanai_dev_close if not open · 20b2ca1f
      Tong Zhang authored
      [ Upstream commit a2bd4583
      
       ]
      
      lanai_dev_open() can fail. When it fail, lanai->base is unmapped and the
      pci device is disabled. The caller, lanai_init_one(), then tries to run
      atm_dev_deregister(). This will subsequently call lanai_dev_close() and
      use the already released MMIO area.
      
      To fix this issue, set the lanai->base to NULL if open fail,
      and test the flag in lanai_dev_close().
      
      [    8.324153] lanai: lanai_start() failed, err=19
      [    8.324819] lanai(itf 0): shutting down interface
      [    8.325211] BUG: unable to handle page fault for address: ffffc90000180024
      [    8.325781] #PF: supervisor write access in kernel mode
      [    8.326215] #PF: error_code(0x0002) - not-present page
      [    8.326641] PGD 100000067 P4D 100000067 PUD 100139067 PMD 10013a067 PTE 0
      [    8.327206] Oops: 0002 [#1] SMP KASAN NOPTI
      [    8.327557] CPU: 0 PID: 95 Comm: modprobe Not tainted 5.11.0-rc7-00090-gdcc0b49040c7 #12
      [    8.328229] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-48-gd9c812dda519-4
      [    8.329145] RIP: 0010:lanai_dev_close+0x4f/0xe5 [lanai]
      [    8.329587] Code: 00 48 c7 c7 00 d3 01 c0 e8 49 4e 0a c2 48 8d bd 08 02 00 00 e8 6e 52 14 c1 48 80
      [    8.330917] RSP: 0018:ffff8881029ef680 EFLAGS: 00010246
      [    8.331196] RAX: 000000000003fffe RBX: ffff888102fb4800 RCX: ffffffffc001a98a
      [    8.331572] RDX: ffffc90000180000 RSI: 0000000000000246 RDI: ffff888102fb4000
      [    8.331948] RBP: ffff888102fb4000 R08: ffffffff8115da8a R09: ffffed102053deaa
      [    8.332326] R10: 0000000000000003 R11: ffffed102053dea9 R12: ffff888102fb48a4
      [    8.332701] R13: ffffffffc00123c0 R14: ffff888102fb4b90 R15: ffff888102fb4b88
      [    8.333077] FS:  00007f08eb9056a0(0000) GS:ffff88815b400000(0000) knlGS:0000000000000000
      [    8.333502] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [    8.333806] CR2: ffffc90000180024 CR3: 0000000102a28000 CR4: 00000000000006f0
      [    8.334182] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [    8.334557] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [    8.334932] Call Trace:
      [    8.335066]  atm_dev_deregister+0x161/0x1a0 [atm]
      [    8.335324]  lanai_init_one.cold+0x20c/0x96d [lanai]
      [    8.335594]  ? lanai_send+0x2a0/0x2a0 [lanai]
      [    8.335831]  local_pci_probe+0x6f/0xb0
      [    8.336039]  pci_device_probe+0x171/0x240
      [    8.336255]  ? pci_device_remove+0xe0/0xe0
      [    8.336475]  ? kernfs_create_link+0xb6/0x110
      [    8.336704]  ? sysfs_do_create_link_sd.isra.0+0x76/0xe0
      [    8.336983]  really_probe+0x161/0x420
      [    8.337181]  driver_probe_device+0x6d/0xd0
      [    8.337401]  device_driver_attach+0x82/0x90
      [    8.337626]  ? device_driver_attach+0x90/0x90
      [    8.337859]  __driver_attach+0x60/0x100
      [    8.338065]  ? device_driver_attach+0x90/0x90
      [    8.338298]  bus_for_each_dev+0xe1/0x140
      [    8.338511]  ? subsys_dev_iter_exit+0x10/0x10
      [    8.338745]  ? klist_node_init+0x61/0x80
      [    8.338956]  bus_add_driver+0x254/0x2a0
      [    8.339164]  driver_register+0xd3/0x150
      [    8.339370]  ? 0xffffffffc0028000
      [    8.339550]  do_one_initcall+0x84/0x250
      [    8.339755]  ? trace_event_raw_event_initcall_finish+0x150/0x150
      [    8.340076]  ? free_vmap_area_noflush+0x1a5/0x5c0
      [    8.340329]  ? unpoison_range+0xf/0x30
      [    8.340532]  ? ____kasan_kmalloc.constprop.0+0x84/0xa0
      [    8.340806]  ? unpoison_range+0xf/0x30
      [    8.341014]  ? unpoison_range+0xf/0x30
      [    8.341217]  do_init_module+0xf8/0x350
      [    8.341419]  load_module+0x3fe6/0x4340
      [    8.341621]  ? vm_unmap_ram+0x1d0/0x1d0
      [    8.341826]  ? ____kasan_kmalloc.constprop.0+0x84/0xa0
      [    8.342101]  ? module_frob_arch_sections+0x20/0x20
      [    8.342358]  ? __do_sys_finit_module+0x108/0x170
      [    8.342604]  __do_sys_finit_module+0x108/0x170
      [    8.342841]  ? __ia32_sys_init_module+0x40/0x40
      [    8.343083]  ? file_open_root+0x200/0x200
      [    8.343298]  ? do_sys_open+0x85/0xe0
      [    8.343491]  ? filp_open+0x50/0x50
      [    8.343675]  ? exit_to_user_mode_prepare+0xfc/0x130
      [    8.343935]  do_syscall_64+0x33/0x40
      [    8.344132]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
      [    8.344401] RIP: 0033:0x7f08eb887cf7
      [    8.344594] Code: 48 89 57 30 48 8b 04 24 48 89 47 38 e9 1d a0 02 00 48 89 f8 48 89 f7 48 89 d6 41
      [    8.345565] RSP: 002b:00007ffcd5c98ad8 EFLAGS: 00000246 ORIG_RAX: 0000000000000139
      [    8.345962] RAX: ffffffffffffffda RBX: 00000000008fea70 RCX: 00007f08eb887cf7
      [    8.346336] RDX: 0000000000000000 RSI: 00000000008fd9e0 RDI: 0000000000000003
      [    8.346711] RBP: 0000000000000003 R08: 0000000000000000 R09: 0000000000000001
      [    8.347085] R10: 00007f08eb8eb300 R11: 0000000000000246 R12: 00000000008fd9e0
      [    8.347460] R13: 0000000000000000 R14: 00000000008fddd0 R15: 0000000000000001
      [    8.347836] Modules linked in: lanai(+) atm
      [    8.348065] CR2: ffffc90000180024
      [    8.348244] ---[ end trace 7fdc1c668f2003e5 ]---
      [    8.348490] RIP: 0010:lanai_dev_close+0x4f/0xe5 [lanai]
      [    8.348772] Code: 00 48 c7 c7 00 d3 01 c0 e8 49 4e 0a c2 48 8d bd 08 02 00 00 e8 6e 52 14 c1 48 80
      [    8.349745] RSP: 0018:ffff8881029ef680 EFLAGS: 00010246
      [    8.350022] RAX: 000000000003fffe RBX: ffff888102fb4800 RCX: ffffffffc001a98a
      [    8.350397] RDX: ffffc90000180000 RSI: 0000000000000246 RDI: ffff888102fb4000
      [    8.350772] RBP: ffff888102fb4000 R08: ffffffff8115da8a R09: ffffed102053deaa
      [    8.351151] R10: 0000000000000003 R11: ffffed102053dea9 R12: ffff888102fb48a4
      [    8.351525] R13: ffffffffc00123c0 R14: ffff888102fb4b90 R15: ffff888102fb4b88
      [    8.351918] FS:  00007f08eb9056a0(0000) GS:ffff88815b400000(0000) knlGS:0000000000000000
      [    8.352343] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [    8.352647] CR2: ffffc90000180024 CR3: 0000000102a28000 CR4: 00000000000006f0
      [    8.353022] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [    8.353397] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [    8.353958] modprobe (95) used greatest stack depth: 26216 bytes left
      
      Signed-off-by: default avatarTong Zhang <ztong0001@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      20b2ca1f
    • Tong Zhang's avatar
      atm: eni: dont release is never initialized · 164393ee
      Tong Zhang authored
      [ Upstream commit 4deb550b
      
       ]
      
      label err_eni_release is reachable when eni_start() fail.
      In eni_start() it calls dev->phy->start() in the last step, if start()
      fail we don't need to call phy->stop(), if start() is never called, we
      neither need to call phy->stop(), otherwise null-ptr-deref will happen.
      
      In order to fix this issue, don't call phy->stop() in label err_eni_release
      
      [    4.875714] ==================================================================
      [    4.876091] BUG: KASAN: null-ptr-deref in suni_stop+0x47/0x100 [suni]
      [    4.876433] Read of size 8 at addr 0000000000000030 by task modprobe/95
      [    4.876778]
      [    4.876862] CPU: 0 PID: 95 Comm: modprobe Not tainted 5.11.0-rc7-00090-gdcc0b49040c7 #2
      [    4.877290] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-48-gd94
      [    4.877876] Call Trace:
      [    4.878009]  dump_stack+0x7d/0xa3
      [    4.878191]  kasan_report.cold+0x10c/0x10e
      [    4.878410]  ? __slab_free+0x2f0/0x340
      [    4.878612]  ? suni_stop+0x47/0x100 [suni]
      [    4.878832]  suni_stop+0x47/0x100 [suni]
      [    4.879043]  eni_do_release+0x3b/0x70 [eni]
      [    4.879269]  eni_init_one.cold+0x1152/0x1747 [eni]
      [    4.879528]  ? _raw_spin_lock_irqsave+0x7b/0xd0
      [    4.879768]  ? eni_ioctl+0x270/0x270 [eni]
      [    4.879990]  ? __mutex_lock_slowpath+0x10/0x10
      [    4.880226]  ? eni_ioctl+0x270/0x270 [eni]
      [    4.880448]  local_pci_probe+0x6f/0xb0
      [    4.880650]  pci_device_probe+0x171/0x240
      [    4.880864]  ? pci_device_remove+0xe0/0xe0
      [    4.881086]  ? kernfs_create_link+0xb6/0x110
      [    4.881315]  ? sysfs_do_create_link_sd.isra.0+0x76/0xe0
      [    4.881594]  really_probe+0x161/0x420
      [    4.881791]  driver_probe_device+0x6d/0xd0
      [    4.882010]  device_driver_attach+0x82/0x90
      [    4.882233]  ? device_driver_attach+0x90/0x90
      [    4.882465]  __driver_attach+0x60/0x100
      [    4.882671]  ? device_driver_attach+0x90/0x90
      [    4.882903]  bus_for_each_dev+0xe1/0x140
      [    4.883114]  ? subsys_dev_iter_exit+0x10/0x10
      [    4.883346]  ? klist_node_init+0x61/0x80
      [    4.883557]  bus_add_driver+0x254/0x2a0
      [    4.883764]  driver_register+0xd3/0x150
      [    4.883971]  ? 0xffffffffc0038000
      [    4.884149]  do_one_initcall+0x84/0x250
      [    4.884355]  ? trace_event_raw_event_initcall_finish+0x150/0x150
      [    4.884674]  ? unpoison_range+0xf/0x30
      [    4.884875]  ? ____kasan_kmalloc.constprop.0+0x84/0xa0
      [    4.885150]  ? unpoison_range+0xf/0x30
      [    4.885352]  ? unpoison_range+0xf/0x30
      [    4.885557]  do_init_module+0xf8/0x350
      [    4.885760]  load_module+0x3fe6/0x4340
      [    4.885960]  ? vm_unmap_ram+0x1d0/0x1d0
      [    4.886166]  ? ____kasan_kmalloc.constprop.0+0x84/0xa0
      [    4.886441]  ? module_frob_arch_sections+0x20/0x20
      [    4.886697]  ? __do_sys_finit_module+0x108/0x170
      [    4.886941]  __do_sys_finit_module+0x108/0x170
      [    4.887178]  ? __ia32_sys_init_module+0x40/0x40
      [    4.887419]  ? file_open_root+0x200/0x200
      [    4.887634]  ? do_sys_open+0x85/0xe0
      [    4.887826]  ? filp_open+0x50/0x50
      [    4.888009]  ? fpregs_assert_state_consistent+0x4d/0x60
      [    4.888287]  ? exit_to_user_mode_prepare+0x2f/0x130
      [    4.888547]  do_syscall_64+0x33/0x40
      [    4.888739]  entry_SYSCALL_64_after_hwframe+0x44/0xa9
      [    4.889010] RIP: 0033:0x7ff62fcf1cf7
      [    4.889202] Code: 48 89 57 30 48 8b 04 24 48 89 47 38 e9 1d a0 02 00 48 89 f8 48 89 f71
      [    4.890172] RSP: 002b:00007ffe6644ade8 EFLAGS: 00000246 ORIG_RAX: 0000000000000139
      [    4.890570] RAX: ffffffffffffffda RBX: 0000000000f2ca70 RCX: 00007ff62fcf1cf7
      [    4.890944] RDX: 0000000000000000 RSI: 0000000000f2b9e0 RDI: 0000000000000003
      [    4.891318] RBP: 0000000000000003 R08: 0000000000000000 R09: 0000000000000001
      [    4.891691] R10: 00007ff62fd55300 R11: 0000000000000246 R12: 0000000000f2b9e0
      [    4.892064] R13: 0000000000000000 R14: 0000000000f2bdd0 R15: 0000000000000001
      [    4.892439] ==================================================================
      
      Signed-off-by: default avatarTong Zhang <ztong0001@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      164393ee
    • Michael Ellerman's avatar
      powerpc/4xx: Fix build errors from mfdcr() · 9113d250
      Michael Ellerman authored
      [ Upstream commit eead0893
      
       ]
      
      lkp reported a build error in fsp2.o:
      
        CC      arch/powerpc/platforms/44x/fsp2.o
        {standard input}:577: Error: unsupported relocation against base
      
      Which comes from:
      
        pr_err("GESR0: 0x%08x\n", mfdcr(base + PLB4OPB_GESR0));
      
      Where our mfdcr() macro is stringifying "base + PLB4OPB_GESR0", and
      passing that to the assembler, which obviously doesn't work.
      
      The mfdcr() macro already checks that the argument is constant using
      __builtin_constant_p(), and if not calls the out-of-line version of
      mfdcr(). But in this case GCC is smart enough to notice that "base +
      PLB4OPB_GESR0" will be constant, even though it's not something we can
      immediately stringify into a register number.
      
      Segher pointed out that passing the register number to the inline asm
      as a constant would be better, and in fact it fixes the build error,
      presumably because it gives GCC a chance to resolve the value.
      
      While we're at it, change mtdcr() similarly.
      
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Suggested-by: default avatarSegher Boessenkool <segher@kernel.crashing.org>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Acked-by: default avatarFeng Tang <feng.tang@intel.com>
      Link: https://lore.kernel.org/r/20210218123058.748882-1-mpe@ellerman.id.au
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9113d250
    • Heiko Thiery's avatar
      net: fec: ptp: avoid register access when ipg clock is disabled · 9b67dcf5
      Heiko Thiery authored
      [ Upstream commit 6a4d7234 ]
      
      When accessing the timecounter register on an i.MX8MQ the kernel hangs.
      This is only the case when the interface is down. This can be reproduced
      by reading with 'phc_ctrl eth0 get'.
      
      Like described in the change in 91c0d987
      
      
      the igp clock is disabled when the interface is down and leads to a
      system hang.
      
      So we check if the ptp clock status before reading the timecounter
      register.
      
      Signed-off-by: default avatarHeiko Thiery <heiko.thiery@gmail.com>
      Acked-by: default avatarRichard Cochran <richardcochran@gmail.com>
      Link: https://lore.kernel.org/r/20210225211514.9115-1-heiko.thiery@gmail.com
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9b67dcf5
  2. Mar 24, 2021
    • Greg Kroah-Hartman's avatar
      Linux 4.9.263 · 5023febc
      Greg Kroah-Hartman authored
      
      
      Tested-by: default avatarJon Hunter <jonathanh@nvidia.com>
      Tested-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Tested-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Tested-by: default avatarJason Self <jason@bluehome.net>
      Tested-by: default avatarLinux Kernel Functional Testing <lkft@linaro.org>
      Link: https://lore.kernel.org/r/20210322121920.399826335@linuxfoundation.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      v4.9.263
      5023febc
    • Thomas Gleixner's avatar
      genirq: Disable interrupts for force threaded handlers · 528d3b76
      Thomas Gleixner authored
      commit 81e2073c upstream.
      
      With interrupt force threading all device interrupt handlers are invoked
      from kernel threads. Contrary to hard interrupt context the invocation only
      disables bottom halfs, but not interrupts. This was an oversight back then
      because any code like this will have an issue:
      
      thread(irq_A)
        irq_handler(A)
          spin_lock(&foo->lock);
      
      interrupt(irq_B)
        irq_handler(B)
          spin_lock(&foo->lock);
      
      This has been triggered with networking (NAPI vs. hrtimers) and console
      drivers where printk() happens from an interrupt which interrupted the
      force threaded handler.
      
      Now people noticed and started to change the spin_lock() in the handler to
      spin_lock_irqsave() which affects performance or add IRQF_NOTHREAD to the
      interrupt request which in turn breaks RT.
      
      Fix the root cause and not the symptom and disable interrupts before
      invoking the force threaded handler which preserves the regular semantics
      and the usefulness of the interrupt force threading as a general debugging
      tool.
      
      For not RT this is not changing much, except that during the execution of
      the threaded handler interrupts are delayed until the handler
      returns. Vs. scheduling and softirq processing there is no difference.
      
      For RT kernels there is no issue.
      
      Fixes: 8d32a307
      
       ("genirq: Provide forced interrupt threading")
      Reported-by: default avatarJohan Hovold <johan@kernel.org>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarJohan Hovold <johan@kernel.org>
      Acked-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Link: https://lore.kernel.org/r/20210317143859.513307808@linutronix.de
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      528d3b76
    • Shijie Luo's avatar
      ext4: fix potential error in ext4_do_update_inode · 542e59b0
      Shijie Luo authored
      commit 7d8bd3c7
      
       upstream.
      
      If set_large_file = 1 and errors occur in ext4_handle_dirty_metadata(),
      the error code will be overridden, go to out_brelse to avoid this
      situation.
      
      Signed-off-by: default avatarShijie Luo <luoshijie1@huawei.com>
      Link: https://lore.kernel.org/r/20210312065051.36314-1-luoshijie1@huawei.com
      Cc: stable@kernel.org
      Reviewed-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      542e59b0
    • zhangyi (F)'s avatar
      ext4: find old entry again if failed to rename whiteout · 5acfb54a
      zhangyi (F) authored
      commit b7ff91fd upstream.
      
      If we failed to add new entry on rename whiteout, we cannot reset the
      old->de entry directly, because the old->de could have moved from under
      us during make indexed dir. So find the old entry again before reset is
      needed, otherwise it may corrupt the filesystem as below.
      
        /dev/sda: Entry '00000001' in ??? (12) has deleted/unused inode 15. CLEARED.
        /dev/sda: Unattached inode 75
        /dev/sda: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.
      
      Fixes: 6b4b8e6b
      
       ("ext4: fix bug for rename with RENAME_WHITEOUT")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarzhangyi (F) <yi.zhang@huawei.com>
      Link: https://lore.kernel.org/r/20210303131703.330415-1-yi.zhang@huawei.com
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5acfb54a
    • Oleg Nesterov's avatar
      x86: Introduce TS_COMPAT_RESTART to fix get_nr_restart_syscall() · 5b871095
      Oleg Nesterov authored
      commit 8c150ba2 upstream.
      
      The comment in get_nr_restart_syscall() says:
      
      	 * The problem is that we can get here when ptrace pokes
      	 * syscall-like values into regs even if we're not in a syscall
      	 * at all.
      
      Yes, but if not in a syscall then the
      
      	status & (TS_COMPAT|TS_I386_REGS_POKED)
      
      check below can't really help:
      
      	- TS_COMPAT can't be set
      
      	- TS_I386_REGS_POKED is only set if regs->orig_ax was changed by
      	  32bit debugger; and even in this case get_nr_restart_syscall()
      	  is only correct if the tracee is 32bit too.
      
      Suppose that a 64bit debugger plays with a 32bit tracee and
      
      	* Tracee calls sleep(2)	// TS_COMPAT is set
      	* User interrupts the tracee by CTRL-C after 1 sec and does
      	  "(gdb) call func()"
      	* gdb saves the regs by PTRACE_GETREGS
      	* does PTRACE_SETREGS to set %rip='func' and %orig_rax=-1
      	* PTRACE_CONT		// TS_COMPAT is cleared
      	* func() hits int3.
      	* Debugger catches SIGTRAP.
      	* Restore original regs by PTRACE_SETREGS.
      	* PTRACE_CONT
      
      get_nr_restart_syscall() wrongly returns __NR_restart_syscall==219, the
      tracee calls ia32_sys_call_table[219] == sys_madvise.
      
      Add the sticky TS_COMPAT_RESTART flag which survives after return to user
      mode. It's going to be removed in the next step again by storing the
      information in the restart block. As a further cleanup it might be possible
      to remove also TS_I386_REGS_POKED with that.
      
      Test-case:
      
        $ cvs -d :pserver:anoncvs:anoncvs@sourceware.org:/cvs/systemtap co ptrace-tests
        $ gcc -o erestartsys-trap-debuggee ptrace-tests/tests/erestartsys-trap-debuggee.c --m32
        $ gcc -o erestartsys-trap-debugger ptrace-tests/tests/erestartsys-trap-debugger.c -lutil
        $ ./erestartsys-trap-debugger
        Unexpected: retval 1, errno 22
        erestartsys-trap-debugger: ptrace-tests/tests/erestartsys-trap-debugger.c:421
      
      Fixes: 609c19a3
      
       ("x86/ptrace: Stop setting TS_COMPAT in ptrace code")
      Reported-by: default avatarJan Kratochvil <jan.kratochvil@redhat.com>
      Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20210201174709.GA17895@redhat.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5b871095
    • Oleg Nesterov's avatar
      x86: Move TS_COMPAT back to asm/thread_info.h · 4a3b8246
      Oleg Nesterov authored
      commit 66c1b6d7 upstream.
      
      Move TS_COMPAT back to asm/thread_info.h, close to TS_I386_REGS_POKED.
      
      It was moved to asm/processor.h by b9d989c7 ("x86/asm: Move the
      thread_info::status field to thread_struct"), then later 37a8f7c3
      ("x86/asm: Move 'status' from thread_struct to thread_info") moved the
      'status' field back but TS_COMPAT was forgotten.
      
      Preparatory patch to fix the COMPAT case for get_nr_restart_syscall()
      
      Fixes: 609c19a3
      
       ("x86/ptrace: Stop setting TS_COMPAT in ptrace code")
      Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20210201174649.GA17880@redhat.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4a3b8246
    • Oleg Nesterov's avatar
      kernel, fs: Introduce and use set_restart_fn() and arch_set_restart_data() · 376a76aa
      Oleg Nesterov authored
      commit 5abbe51a upstream.
      
      Preparation for fixing get_nr_restart_syscall() on X86 for COMPAT.
      
      Add a new helper which sets restart_block->fn and calls a dummy
      arch_set_restart_data() helper.
      
      Fixes: 609c19a3
      
       ("x86/ptrace: Stop setting TS_COMPAT in ptrace code")
      Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20210201174641.GA17871@redhat.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      376a76aa
    • Thomas Gleixner's avatar
      x86/ioapic: Ignore IRQ2 again · 3d9fcc25
      Thomas Gleixner authored
      commit a501b048 upstream.
      
      Vitaly ran into an issue with hotplugging CPU0 on an Amazon instance where
      the matrix allocator claimed to be out of vectors. He analyzed it down to
      the point that IRQ2, the PIC cascade interrupt, which is supposed to be not
      ever routed to the IO/APIC ended up having an interrupt vector assigned
      which got moved during unplug of CPU0.
      
      The underlying issue is that IRQ2 for various reasons (see commit
      af174783 ("x86: I/O APIC: Never configure IRQ2" for details) is treated
      as a reserved system vector by the vector core code and is not accounted as
      a regular vector. The Amazon BIOS has an routing entry of pin2 to IRQ2
      which causes the IO/APIC setup to claim that interrupt which is granted by
      the vector domain because there is no sanity check. As a consequence the
      allocation counter of CPU0 underflows which causes a subsequent unplug to
      fail with:
      
        [ ... ] CPU 0 has 4294967295 vectors, 589 available. Cannot disable CPU
      
      There is another sanity check missing in the matrix allocator, but the
      underlying root cause is that the IO/APIC code lost the IRQ2 ignore logic
      during the conversion to irqdomains.
      
      For almost 6 years nobody complained about this wreckage, which might
      indicate that this requirement could be lifted, but for any system which
      actually has a PIC IRQ2 is unusable by design so any routing entry has no
      effect and the interrupt cannot be connected to a device anyway.
      
      Due to that and due to history biased paranoia reasons restore the IRQ2
      ignore logic and treat it as non existent despite a routing entry claiming
      otherwise.
      
      Fixes: d32932d0
      
       ("x86/irq: Convert IOAPIC to use hierarchical irqdomain interfaces")
      Reported-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Tested-by: default avatarVitaly Kuznetsov <vkuznets@redhat.com>
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20210318192819.636943062@linutronix.de
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3d9fcc25