Skip to content
  1. Jul 28, 2021
    • Paolo Abeni's avatar
      ipv6: fix another slab-out-of-bounds in fib6_nh_flush_exceptions · ce8fafb6
      Paolo Abeni authored
      [ Upstream commit 8fb4792f ]
      
      While running the self-tests on a KASAN enabled kernel, I observed a
      slab-out-of-bounds splat very similar to the one reported in
      commit 821bbf79 ("ipv6: Fix KASAN: slab-out-of-bounds Read in
       fib6_nh_flush_exceptions").
      
      We additionally need to take care of fib6_metrics initialization
      failure when the caller provides an nh.
      
      The fix is similar, explicitly free the route instead of calling
      fib6_info_release on a half-initialized object.
      
      Fixes: f88d8ea6
      
       ("ipv6: Plumb support for nexthop object in a fib6_info")
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ce8fafb6
    • Peilin Ye's avatar
      net/sched: act_skbmod: Skip non-Ethernet packets · 07172915
      Peilin Ye authored
      [ Upstream commit 727d6a8b ]
      
      Currently tcf_skbmod_act() assumes that packets use Ethernet as their L2
      protocol, which is not always the case.  As an example, for CAN devices:
      
      	$ ip link add dev vcan0 type vcan
      	$ ip link set up vcan0
      	$ tc qdisc add dev vcan0 root handle 1: htb
      	$ tc filter add dev vcan0 parent 1: protocol ip prio 10 \
      		matchall action skbmod swap mac
      
      Doing the above silently corrupts all the packets.  Do not perform skbmod
      actions for non-Ethernet packets.
      
      Fixes: 86da71b5
      
       ("net_sched: Introduce skbmod action")
      Reviewed-by: default avatarCong Wang <cong.wang@bytedance.com>
      Signed-off-by: default avatarPeilin Ye <peilin.ye@bytedance.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      07172915
    • Alexandru Tachici's avatar
      spi: spi-bcm2835: Fix deadlock · ee36bb47
      Alexandru Tachici authored
      [ Upstream commit c45c1e82
      
       ]
      
      The bcm2835_spi_transfer_one function can create a deadlock
      if it is called while another thread already has the
      CCF lock.
      
      Signed-off-by: default avatarAlexandru Tachici <alexandru.tachici@analog.com>
      Fixes: f8043872
      
       ("spi: add driver for BCM2835")
      Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
      Link: https://lore.kernel.org/r/20210716210245.13240-2-alexandru.tachici@analog.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ee36bb47
    • Jian Shen's avatar
      net: hns3: fix rx VLAN offload state inconsistent issue · 432738c9
      Jian Shen authored
      [ Upstream commit bbfd4506 ]
      
      Currently, VF doesn't enable rx VLAN offload when initializating,
      and PF does it for VFs. If user disable the rx VLAN offload for
      VF with ethtool -K, and reload the VF driver, it may cause the
      rx VLAN offload state being inconsistent between hardware and
      software.
      
      Fixes it by enabling rx VLAN offload when VF initializing.
      
      Fixes: e2cb1dec
      
       ("net: hns3: Add HNS3 VF HCL(Hardware Compatibility Layer) Support")
      Signed-off-by: default avatarJian Shen <shenjian15@huawei.com>
      Signed-off-by: default avatarGuangbin Huang <huangguangbin2@huawei.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      432738c9
    • Chengwen Feng's avatar
      net: hns3: fix possible mismatches resp of mailbox · 3e903e0b
      Chengwen Feng authored
      [ Upstream commit 1b713d14 ]
      
      Currently, the mailbox synchronous communication between VF and PF use
      the following fields to maintain communication:
      1. Origin_mbx_msg which was combined by message code and subcode, used
      to match request and response.
      2. Received_resp which means whether received response.
      
      There may possible mismatches of the following situation:
      1. VF sends message A with code=1 subcode=1.
      2. PF was blocked about 500ms when processing the message A.
      3. VF will detect message A timeout because it can't get the response
      within 500ms.
      4. VF sends message B with code=1 subcode=1 which equal message A.
      5. PF processes the first message A and send the response message to
      VF.
      6. VF will identify the response matched the message B because the
      code/subcode is the same. This will lead to mismatch of request and
      response.
      
      To fix the above bug, we use the following scheme:
      1. The message sent from VF was labelled with match_id which was a
      unique 16-bit non-zero value.
      2. The response sent from PF will label with match_id which got from
      the request.
      3. The VF uses the match_id to match request and response message.
      
      As for PF driver, it only needs to copy the match_id from request to
      response.
      
      Fixes: dde1a86e
      
       ("net: hns3: Add mailbox support to PF driver")
      Signed-off-by: default avatarChengwen Feng <fengchengwen@huawei.com>
      Signed-off-by: default avatarGuangbin Huang <huangguangbin2@huawei.com>
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3e903e0b
    • Pierre-Louis Bossart's avatar
      ALSA: hda: intel-dsp-cfg: add missing ElkhartLake PCI ID · f4305375
      Pierre-Louis Bossart authored
      [ Upstream commit 114613f6 ]
      
      We missed the fact that ElkhartLake platforms have two different PCI
      IDs. We only added one so the SOF driver is never selected by the
      autodetection logic for the missing configuration.
      
      BugLink: https://github.com/thesofproject/linux/issues/2990
      Fixes: cc8f81c7
      
       ('ALSA: hda: fix intel DSP config')
      Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
      Link: https://lore.kernel.org/r/20210719231746.557325-1-pierre-louis.bossart@linux.intel.com
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      f4305375
    • Eric Dumazet's avatar
      net/tcp_fastopen: fix data races around tfo_active_disable_stamp · 41a83943
      Eric Dumazet authored
      [ Upstream commit 6f20c8ad ]
      
      tfo_active_disable_stamp is read and written locklessly.
      We need to annotate these accesses appropriately.
      
      Then, we need to perform the atomic_inc(tfo_active_disable_times)
      after the timestamp has been updated, and thus add barriers
      to make sure tcp_fastopen_active_should_disable() wont read
      a stale timestamp.
      
      Fixes: cf1ef3f0
      
       ("net/tcp_fastopen: Disable active side TFO in certain scenarios")
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: Wei Wang <weiwan@google.com>
      Cc: Yuchung Cheng <ycheng@google.com>
      Cc: Neal Cardwell <ncardwell@google.com>
      Acked-by: default avatarWei Wang <weiwan@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      41a83943
    • Randy Dunlap's avatar
      net: hisilicon: rename CACHE_LINE_MASK to avoid redefinition · ba333639
      Randy Dunlap authored
      [ Upstream commit b16f3299 ]
      
      Building on ARCH=arc causes a "redefined" warning, so rename this
      driver's CACHE_LINE_MASK to avoid the warning.
      
      ../drivers/net/ethernet/hisilicon/hip04_eth.c:134: warning: "CACHE_LINE_MASK" redefined
        134 | #define CACHE_LINE_MASK   0x3F
      In file included from ../include/linux/cache.h:6,
                       from ../include/linux/printk.h:9,
                       from ../include/linux/kernel.h:19,
                       from ../include/linux/list.h:9,
                       from ../include/linux/module.h:12,
                       from ../drivers/net/ethernet/hisilicon/hip04_eth.c:7:
      ../arch/arc/include/asm/cache.h:17: note: this is the location of the previous definition
         17 | #define CACHE_LINE_MASK  (~(L1_CACHE_BYTES - 1))
      
      Fixes: d413779c
      
       ("net: hisilicon: Add an tx_desc to adapt HI13X1_GMAC")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Cc: Vineet Gupta <vgupta@synopsys.com>
      Cc: Jiangfeng Xiao <xiaojiangfeng@huawei.com>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Jakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ba333639
    • Somnath Kotur's avatar
      bnxt_en: Check abort error state in bnxt_half_open_nic() · 320dcbde
      Somnath Kotur authored
      [ Upstream commit 11a39259 ]
      
      bnxt_half_open_nic() is called during during ethtool self test and is
      protected by rtnl_lock.  Firmware reset can be happening at the same
      time.  Only critical portions of the entire firmware reset sequence
      are protected by the rtnl_lock.  It is possible that bnxt_half_open_nic()
      can be called when the firmware reset sequence is aborting.  In that
      case, bnxt_half_open_nic() needs to check if the ABORT_ERR flag is set
      and abort if it is.  The ethtool self test will fail but the NIC will be
      brought to a consistent IF_DOWN state.
      
      Without this patch, if bnxt_half_open_nic() were to continue in this
      error state, it may crash like this:
      
        bnxt_en 0000:82:00.1 enp130s0f1np1: FW reset in progress during close, FW reset will be aborted
        Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
        ...
        Process ethtool (pid: 333327, stack limit = 0x0000000046476577)
        Call trace:
        bnxt_alloc_mem+0x444/0xef0 [bnxt_en]
        bnxt_half_open_nic+0x24/0xb8 [bnxt_en]
        bnxt_self_test+0x2dc/0x390 [bnxt_en]
        ethtool_self_test+0xe0/0x1f8
        dev_ethtool+0x1744/0x22d0
        dev_ioctl+0x190/0x3e0
        sock_ioctl+0x238/0x480
        do_vfs_ioctl+0xc4/0x758
        ksys_ioctl+0x84/0xb8
        __arm64_sys_ioctl+0x28/0x38
        el0_svc_handler+0xb0/0x180
        el0_svc+0x8/0xc
      
      Fixes: a1301f08
      
       ("bnxt_en: Check abort error state in bnxt_open_nic().")
      Signed-off-by: default avatarSomnath Kotur <somnath.kotur@broadcom.com>
      Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      320dcbde
    • Michael Chan's avatar
      bnxt_en: Validate vlan protocol ID on RX packets · 134a0536
      Michael Chan authored
      [ Upstream commit 96bdd4b9 ]
      
      Only pass supported VLAN protocol IDs for stripped VLAN tags to the
      stack.  The stack will hit WARN() if the protocol ID is unsupported.
      
      Existing firmware sets up the chip to strip 0x8100, 0x88a8, 0x9100.
      Only the 1st two protocols are supported by the kernel.
      
      Fixes: a196e96b
      
       ("bnxt_en: clean up VLAN feature bit handling")
      Reviewed-by: default avatarSomnath Kotur <somnath.kotur@broadcom.com>
      Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      134a0536
    • Michael Chan's avatar
      bnxt_en: Add missing check for BNXT_STATE_ABORT_ERR in bnxt_fw_rset_task() · 4f7da0f9
      Michael Chan authored
      [ Upstream commit 6cd657cb ]
      
      In the BNXT_FW_RESET_STATE_POLL_VF state in bnxt_fw_reset_task() after all
      VFs have unregistered, we need to check for BNXT_STATE_ABORT_ERR after
      we acquire the rtnl_lock.  If the flag is set, we need to abort.
      
      Fixes: 230d1f0d
      
       ("bnxt_en: Handle firmware reset.")
      Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      4f7da0f9
    • Michael Chan's avatar
      bnxt_en: Refresh RoCE capabilities in bnxt_ulp_probe() · 92737048
      Michael Chan authored
      [ Upstream commit 2c9f046b ]
      
      The capabilities can change after firmware upgrade/downgrade, so we
      should get the up-to-date RoCE capabilities everytime bnxt_ulp_probe()
      is called.
      
      Fixes: 2151fe08
      
       ("bnxt_en: Handle RESET_NOTIFY async event from firmware.")
      Reviewed-by: default avatarSomnath Kotur <somnath.kotur@broadcom.com>
      Reviewed-by: default avatarEdwin Peer <edwin.peer@broadcom.com>
      Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      92737048
    • Kalesh AP's avatar
      bnxt_en: don't disable an already disabled PCI device · ab830c3b
      Kalesh AP authored
      [ Upstream commit c81cfb62 ]
      
      If device is already disabled in reset path and PCI io error is
      detected before the device could be enabled, driver could
      call pci_disable_device() for already disabled device. Fix this
      problem by calling pci_disable_device() only if the device is already
      enabled.
      
      Fixes: 6316ea6d
      
       ("bnxt_en: Enable AER support.")
      Signed-off-by: default avatarKalesh AP <kalesh-anakkur.purayil@broadcom.com>
      Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ab830c3b
    • Robert Richter's avatar
      ACPI: Kconfig: Fix table override from built-in initrd · 26463689
      Robert Richter authored
      [ Upstream commit d2cbbf1f ]
      
      During a rework of initramfs code the INITRAMFS_COMPRESSION config
      option was removed in commit 65e00e04. A leftover as a dependency
      broke the config option ACPI_TABLE_OVERRIDE_VIA_ BUILTIN_INITRD that
      is used to enable the overriding of ACPI tables from built-in initrd.
      Fixing the dependency.
      
      Fixes: 65e00e04
      
       ("initramfs: refactor the initramfs build rules")
      Signed-off-by: default avatarRobert Richter <rrichter@amd.com>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      26463689
    • Marek Vasut's avatar
      spi: cadence: Correct initialisation of runtime PM again · 113ce8c5
      Marek Vasut authored
      [ Upstream commit 56912da7 ]
      
      The original implementation of RPM handling in probe() was mostly
      correct, except it failed to call pm_runtime_get_*() to activate the
      hardware. The subsequent fix, 734882a8 ("spi: cadence: Correct
      initialisation of runtime PM"), breaks the implementation further,
      to the point where the system using this hard IP on ZynqMP hangs on
      boot, because it accesses hardware which is gated off.
      
      Undo 734882a8 ("spi: cadence: Correct initialisation of runtime
      PM") and instead add missing pm_runtime_get_noresume() and move the
      RPM disabling all the way to the end of probe(). That makes ZynqMP
      not hang on boot yet again.
      
      Fixes: 734882a8
      
       ("spi: cadence: Correct initialisation of runtime PM")
      Signed-off-by: default avatarMarek Vasut <marex@denx.de>
      Cc: Charles Keepax <ckeepax@opensource.cirrus.com>
      Cc: Mark Brown <broonie@kernel.org>
      Link: https://lore.kernel.org/r/20210716182133.218640-1-marex@denx.de
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      113ce8c5
    • Dmitry Bogdanov's avatar
      scsi: target: Fix protect handling in WRITE SAME(32) · 3ea448b6
      Dmitry Bogdanov authored
      [ Upstream commit 6d8e7e7c ]
      
      WRITE SAME(32) command handling reads WRPROTECT at the wrong offset in 1st
      byte instead of 10th byte.
      
      Link: https://lore.kernel.org/r/20210702091655.22818-1-d.bogdanov@yadro.com
      Fixes: afd73f1b
      
       ("target: Perform PROTECT sanity checks for WRITE_SAME")
      Signed-off-by: default avatarDmitry Bogdanov <d.bogdanov@yadro.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3ea448b6
    • Mike Christie's avatar
      scsi: iscsi: Fix iface sysfs attr detection · b82a1a26
      Mike Christie authored
      [ Upstream commit e746f345 ]
      
      A ISCSI_IFACE_PARAM can have the same value as a ISCSI_NET_PARAM so when
      iscsi_iface_attr_is_visible tries to figure out the type by just checking
      the value, we can collide and return the wrong type. When we call into the
      driver we might not match and return that we don't want attr visible in
      sysfs. The patch fixes this by setting the type when we figure out what the
      param is.
      
      Link: https://lore.kernel.org/r/20210701002559.89533-1-michael.christie@oracle.com
      Fixes: 3e0f65b3
      
       ("[SCSI] iscsi_transport: Additional parameters for network settings")
      Signed-off-by: default avatarMike Christie <michael.christie@oracle.com>
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      b82a1a26
    • Nguyen Dinh Phi's avatar
      netrom: Decrease sock refcount when sock timers expire · 6811744b
      Nguyen Dinh Phi authored
      [ Upstream commit 517a16b1 ]
      
      Commit 63346650
      
       ("netrom: switch to sock timer API") switched to use
      sock timer API. It replaces mod_timer() by sk_reset_timer(), and
      del_timer() by sk_stop_timer().
      
      Function sk_reset_timer() will increase the refcount of sock if it is
      called on an inactive timer, hence, in case the timer expires, we need to
      decrease the refcount ourselves in the handler, otherwise, the sock
      refcount will be unbalanced and the sock will never be freed.
      
      Signed-off-by: default avatarNguyen Dinh Phi <phind.uet@gmail.com>
      Reported-by: default avatar <syzbot+10f1194569953b72f1ae@syzkaller.appspotmail.com>
      Fixes: 63346650
      
       ("netrom: switch to sock timer API")
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6811744b
    • Xin Long's avatar
      sctp: trim optlen when it's a huge value in sctp_setsockopt · 096a8dca
      Xin Long authored
      [ Upstream commit 2f3fdd8d ]
      
      After commit ca84bd05 ("sctp: copy the optval from user space in
      sctp_setsockopt"), it does memory allocation in sctp_setsockopt with
      the optlen, and it would fail the allocation and return error if the
      optlen from user space is a huge value.
      
      This breaks some sockopts, like SCTP_HMAC_IDENT, SCTP_RESET_STREAMS and
      SCTP_AUTH_KEY, as when processing these sockopts before, optlen would
      be trimmed to a biggest value it needs when optlen is a huge value,
      instead of failing the allocation and returning error.
      
      This patch is to fix the allocation failure when it's a huge optlen from
      user space by trimming it to the biggest size sctp sockopt may need when
      necessary, and this biggest size is from sctp_setsockopt_reset_streams()
      for SCTP_RESET_STREAMS, which is bigger than those for SCTP_HMAC_IDENT
      and SCTP_AUTH_KEY.
      
      Fixes: ca84bd05
      
       ("sctp: copy the optval from user space in sctp_setsockopt")
      Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      096a8dca
    • Pavel Skripkin's avatar
      net: sched: fix memory leak in tcindex_partial_destroy_work · 8e9662fd
      Pavel Skripkin authored
      [ Upstream commit f5051bce
      
       ]
      
      Syzbot reported memory leak in tcindex_set_parms(). The problem was in
      non-freed perfect hash in tcindex_partial_destroy_work().
      
      In tcindex_set_parms() new tcindex_data is allocated and some fields from
      old one are copied to new one, but not the perfect hash. Since
      tcindex_partial_destroy_work() is the destroy function for old
      tcindex_data, we need to free perfect hash to avoid memory leak.
      
      Reported-and-tested-by: default avatar <syzbot+f0bbb2287b8993d4fa74@syzkaller.appspotmail.com>
      Fixes: 331b7292
      
       ("net: sched: RCU cls_tcindex")
      Signed-off-by: default avatarPavel Skripkin <paskripkin@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      8e9662fd
    • Nicholas Piggin's avatar
      KVM: PPC: Fix kvm_arch_vcpu_ioctl vcpu_load leak · e14ef109
      Nicholas Piggin authored
      [ Upstream commit bc4188a2 ]
      
      vcpu_put is not called if the user copy fails. This can result in preempt
      notifier corruption and crashes, among other issues.
      
      Fixes: b3cebfe8
      
       ("KVM: PPC: Move vcpu_load/vcpu_put down to each ioctl case in kvm_arch_vcpu_ioctl")
      Reported-by: default avatarAlexey Kardashevskiy <aik@ozlabs.ru>
      Signed-off-by: default avatarNicholas Piggin <npiggin@gmail.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20210716024310.164448-2-npiggin@gmail.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e14ef109
    • Nicholas Piggin's avatar
      KVM: PPC: Book3S: Fix CONFIG_TRANSACTIONAL_MEM=n crash · fcbad8e1
      Nicholas Piggin authored
      [ Upstream commit bd31ecf4 ]
      
      When running CPU_FTR_P9_TM_HV_ASSIST, HFSCR[TM] is set for the guest
      even if the host has CONFIG_TRANSACTIONAL_MEM=n, which causes it to be
      unprepared to handle guest exits while transactional.
      
      Normal guests don't have a problem because the HTM capability will not
      be advertised, but a rogue or buggy one could crash the host.
      
      Fixes: 4bb3c7a0
      
       ("KVM: PPC: Book3S HV: Work around transactional memory bugs in POWER9")
      Reported-by: default avatarAlexey Kardashevskiy <aik@ozlabs.ru>
      Signed-off-by: default avatarNicholas Piggin <npiggin@gmail.com>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/20210716024310.164448-1-npiggin@gmail.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      fcbad8e1
    • Yajun Deng's avatar
      net: decnet: Fix sleeping inside in af_decnet · 30b83021
      Yajun Deng authored
      [ Upstream commit 5f119ba1 ]
      
      The release_sock() is blocking function, it would change the state
      after sleeping. use wait_woken() instead.
      
      Fixes: 1da177e4
      
       ("Linux-2.6.12-rc2")
      Signed-off-by: default avatarYajun Deng <yajun.deng@linux.dev>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      30b83021
    • Michal Suchanek's avatar
      efi/tpm: Differentiate missing and invalid final event log table. · d402c60d
      Michal Suchanek authored
      [ Upstream commit 674a9f1f ]
      
      Missing TPM final event log table is not a firmware bug.
      
      Clearly if providing event log in the old format makes the final event
      log invalid it should not be provided at least in that case.
      
      Fixes: b4f1874c
      
       ("tpm: check event log version before reading final events")
      Signed-off-by: default avatarMichal Suchanek <msuchanek@suse.de>
      Reviewed-by: default avatarJarkko Sakkinen <jarkko@kernel.org>
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d402c60d
    • Roman Skakun's avatar
      dma-mapping: handle vmalloc addresses in dma_common_{mmap,get_sgtable} · 89837669
      Roman Skakun authored
      [ Upstream commit 40ac971e ]
      
      xen-swiotlb can use vmalloc backed addresses for dma coherent allocations
      and uses the common helpers.  Properly handle them to unbreak Xen on
      ARM platforms.
      
      Fixes: 1b65c4e5
      
       ("swiotlb-xen: use xen_alloc/free_coherent_pages")
      Signed-off-by: default avatarRoman Skakun <roman_skakun@epam.com>
      Reviewed-by: default avatarAndrii Anisov <andrii_anisov@epam.com>
      [hch: split the patch, renamed the helpers]
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      89837669
    • Dongliang Mu's avatar
      usb: hso: fix error handling code of hso_create_net_device · 115e4f5b
      Dongliang Mu authored
      [ Upstream commit a6ecfb39
      
       ]
      
      The current error handling code of hso_create_net_device is
      hso_free_net_device, no matter which errors lead to. For example,
      WARNING in hso_free_net_device [1].
      
      Fix this by refactoring the error handling code of
      hso_create_net_device by handling different errors by different code.
      
      [1] https://syzkaller.appspot.com/bug?id=66eff8d49af1b28370ad342787413e35bbe76efe
      
      Reported-by: default avatar <syzbot+44d53c7255bb1aea22d2@syzkaller.appspotmail.com>
      Fixes: 5fcfb6d0
      
       ("hso: fix bailout in error case of probe")
      Signed-off-by: default avatarDongliang Mu <mudongliangabcd@gmail.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      115e4f5b
    • Ziyang Xuan's avatar
      net: fix uninit-value in caif_seqpkt_sendmsg · 1582a02f
      Ziyang Xuan authored
      [ Upstream commit 991e6343
      
       ]
      
      When nr_segs equal to zero in iovec_from_user, the object
      msg->msg_iter.iov is uninit stack memory in caif_seqpkt_sendmsg
      which is defined in ___sys_sendmsg. So we cann't just judge
      msg->msg_iter.iov->base directlly. We can use nr_segs to judge
      msg in caif_seqpkt_sendmsg whether has data buffers.
      
      =====================================================
      BUG: KMSAN: uninit-value in caif_seqpkt_sendmsg+0x693/0xf60 net/caif/caif_socket.c:542
      Call Trace:
       __dump_stack lib/dump_stack.c:77 [inline]
       dump_stack+0x1c9/0x220 lib/dump_stack.c:118
       kmsan_report+0xf7/0x1e0 mm/kmsan/kmsan_report.c:118
       __msan_warning+0x58/0xa0 mm/kmsan/kmsan_instr.c:215
       caif_seqpkt_sendmsg+0x693/0xf60 net/caif/caif_socket.c:542
       sock_sendmsg_nosec net/socket.c:652 [inline]
       sock_sendmsg net/socket.c:672 [inline]
       ____sys_sendmsg+0x12b6/0x1350 net/socket.c:2343
       ___sys_sendmsg net/socket.c:2397 [inline]
       __sys_sendmmsg+0x808/0xc90 net/socket.c:2480
       __compat_sys_sendmmsg net/compat.c:656 [inline]
      
      Reported-by: default avatar <syzbot+09a5d591c1f98cf5efcb@syzkaller.appspotmail.com>
      Link: https://syzkaller.appspot.com/bug?id=1ace85e8fc9b0d5a45c08c2656c3e91762daa9b8
      Fixes: bece7b23
      
       ("caif: Rewritten socket implementation")
      Signed-off-by: default avatarZiyang Xuan <william.xuanziyang@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      1582a02f
    • Tobias Klauser's avatar
      bpftool: Check malloc return value in mount_bpffs_for_pin · 2fc80482
      Tobias Klauser authored
      [ Upstream commit d444b06e ]
      
      Fix and add a missing NULL check for the prior malloc() call.
      
      Fixes: 49a086c2
      
       ("bpftool: implement prog load command")
      Signed-off-by: default avatarTobias Klauser <tklauser@distanz.ch>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Reviewed-by: default avatarQuentin Monnet <quentin@isovalent.com>
      Acked-by: default avatarRoman Gushchin <guro@fb.com>
      Link: https://lore.kernel.org/bpf/20210715110609.29364-1-tklauser@distanz.ch
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2fc80482
    • Jakub Sitnicki's avatar
      bpf, sockmap, udp: sk_prot needs inuse_idx set for proc stats · 3b5b0afd
      Jakub Sitnicki authored
      [ Upstream commit 54ea2f49 ]
      
      The proc socket stats use sk_prot->inuse_idx value to record inuse sock
      stats. We currently do not set this correctly from sockmap side. The
      result is reading sock stats '/proc/net/sockstat' gives incorrect values.
      The socket counter is incremented correctly, but because we don't set the
      counter correctly when we replace sk_prot we may omit the decrement.
      
      To get the correct inuse_idx value move the core_initcall that initializes
      the UDP proto handlers to late_initcall. This way it is initialized after
      UDP has the chance to assign the inuse_idx value from the register protocol
      handler.
      
      Fixes: edc6741c
      
       ("bpf: Add sockmap hooks for UDP sockets")
      Signed-off-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Reviewed-by: default avatarCong Wang <cong.wang@bytedance.com>
      Acked-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Link: https://lore.kernel.org/bpf/20210714154750.528206-1-jakub@cloudflare.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3b5b0afd
    • John Fastabend's avatar
      bpf, sockmap, tcp: sk_prot needs inuse_idx set for proc stats · c2604424
      John Fastabend authored
      [ Upstream commit 228a4a7b ]
      
      The proc socket stats use sk_prot->inuse_idx value to record inuse sock
      stats. We currently do not set this correctly from sockmap side. The
      result is reading sock stats '/proc/net/sockstat' gives incorrect values.
      The socket counter is incremented correctly, but because we don't set the
      counter correctly when we replace sk_prot we may omit the decrement.
      
      To get the correct inuse_idx value move the core_initcall that initializes
      the TCP proto handlers to late_initcall. This way it is initialized after
      TCP has the chance to assign the inuse_idx value from the register protocol
      handler.
      
      Fixes: 604326b4
      
       ("bpf, sockmap: convert to generic sk_msg interface")
      Suggested-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
      Signed-off-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Reviewed-by: default avatarCong Wang <cong.wang@bytedance.com>
      Link: https://lore.kernel.org/bpf/20210712195546.423990-3-john.fastabend@gmail.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      c2604424
    • John Fastabend's avatar
      bpf, sockmap: Fix potential memory leak on unlikely error case · 715f378f
      John Fastabend authored
      [ Upstream commit 7e6b27a6 ]
      
      If skb_linearize is needed and fails we could leak a msg on the error
      handling. To fix ensure we kfree the msg block before returning error.
      Found during code review.
      
      Fixes: 4363023d
      
       ("bpf, sockmap: Avoid failures from skb_to_sgvec when skb has frag_list")
      Signed-off-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Reviewed-by: default avatarCong Wang <cong.wang@bytedance.com>
      Link: https://lore.kernel.org/bpf/20210712195546.423990-2-john.fastabend@gmail.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      715f378f
    • Colin Ian King's avatar
      s390/bpf: Perform r1 range checking before accessing jit->seen_reg[r1] · e3a9548a
      Colin Ian King authored
      [ Upstream commit 91091656 ]
      
      Currently array jit->seen_reg[r1] is being accessed before the range
      checking of index r1. The range changing on r1 should be performed
      first since it will avoid any potential out-of-range accesses on the
      array seen_reg[] and also it is more optimal to perform checks on r1
      before fetching data from the array. Fix this by swapping the order
      of the checks before the array access.
      
      Fixes: 05462310
      
       ("s390/bpf: Add s390x eBPF JIT compiler backend")
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Tested-by: default avatarIlya Leoshkevich <iii@linux.ibm.com>
      Acked-by: default avatarIlya Leoshkevich <iii@linux.ibm.com>
      Link: https://lore.kernel.org/bpf/20210715125712.24690-1-colin.king@canonical.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      e3a9548a
    • Colin Ian King's avatar
      liquidio: Fix unintentional sign extension issue on left shift of u16 · 9264bebe
      Colin Ian King authored
      [ Upstream commit e7efc2ce ]
      
      Shifting the u16 integer oct->pcie_port by CN23XX_PKT_INPUT_CTL_MAC_NUM_POS
      (29) bits will be promoted to a 32 bit signed int and then sign-extended
      to a u64. In the cases where oct->pcie_port where bit 2 is set (e.g. 3..7)
      the shifted value will be sign extended and the top 32 bits of the result
      will be set.
      
      Fix this by casting the u16 values to a u64 before the 29 bit left shift.
      
      Addresses-Coverity: ("Unintended sign extension")
      
      Fixes: 3451b97c
      
       ("liquidio: CN23XX register setup")
      Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      9264bebe
    • Nicolas Saenz Julienne's avatar
      timers: Fix get_next_timer_interrupt() with no timers pending · 0ff2ea9d
      Nicolas Saenz Julienne authored
      [ Upstream commit aebacb7f ]
      
      31cd0e11 ("timers: Recalculate next timer interrupt only when
      necessary") subtly altered get_next_timer_interrupt()'s behaviour. The
      function no longer consistently returns KTIME_MAX with no timers
      pending.
      
      In order to decide if there are any timers pending we check whether the
      next expiry will happen NEXT_TIMER_MAX_DELTA jiffies from now.
      Unfortunately, the next expiry time and the timer base clock are no
      longer updated in unison. The former changes upon certain timer
      operations (enqueue, expire, detach), whereas the latter keeps track of
      jiffies as they move forward. Ultimately breaking the logic above.
      
      A simplified example:
      
      - Upon entering get_next_timer_interrupt() with:
      
      	jiffies = 1
      	base->clk = 0;
      	base->next_expiry = NEXT_TIMER_MAX_DELTA;
      
        'base->next_expiry == base->clk + NEXT_TIMER_MAX_DELTA', the function
        returns KTIME_MAX.
      
      - 'base->clk' is updated to the jiffies value.
      
      - The next time we enter get_next_timer_interrupt(), taking into account
        no timer operations happened:
      
      	base->clk = 1;
      	base->next_expiry = NEXT_TIMER_MAX_DELTA;
      
        'base->next_expiry != base->clk + NEXT_TIMER_MAX_DELTA', the function
        returns a valid expire time, which is incorrect.
      
      This ultimately might unnecessarily rearm sched's timer on nohz_full
      setups, and add latency to the system[1].
      
      So, introduce 'base->timers_pending'[2], update it every time
      'base->next_expiry' changes, and use it in get_next_timer_interrupt().
      
      [1] See tick_nohz_stop_tick().
      [2] A quick pahole check on x86_64 and arm64 shows it doesn't make
          'struct timer_base' any bigger.
      
      Fixes: 31cd0e11
      
       ("timers: Recalculate next timer interrupt only when necessary")
      Signed-off-by: default avatarNicolas Saenz Julienne <nsaenzju@redhat.com>
      Signed-off-by: default avatarFrederic Weisbecker <frederic@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      0ff2ea9d
    • Xuan Zhuo's avatar
      xdp, net: Fix use-after-free in bpf_xdp_link_release · ca9ba1de
      Xuan Zhuo authored
      [ Upstream commit 5acc7d3e ]
      
      The problem occurs between dev_get_by_index() and dev_xdp_attach_link().
      At this point, dev_xdp_uninstall() is called. Then xdp link will not be
      detached automatically when dev is released. But link->dev already
      points to dev, when xdp link is released, dev will still be accessed,
      but dev has been released.
      
      dev_get_by_index()        |
      link->dev = dev           |
                                |      rtnl_lock()
                                |      unregister_netdevice_many()
                                |          dev_xdp_uninstall()
                                |      rtnl_unlock()
      rtnl_lock();              |
      dev_xdp_attach_link()     |
      rtnl_unlock();            |
                                |      netdev_run_todo() // dev released
      bpf_xdp_link_release()    |
          /* access dev.        |
             use-after-free */  |
      
      [   45.966867] BUG: KASAN: use-after-free in bpf_xdp_link_release+0x3b8/0x3d0
      [   45.967619] Read of size 8 at addr ffff00000f9980c8 by task a.out/732
      [   45.968297]
      [   45.968502] CPU: 1 PID: 732 Comm: a.out Not tainted 5.13.0+ #22
      [   45.969222] Hardware name: linux,dummy-virt (DT)
      [   45.969795] Call trace:
      [   45.970106]  dump_backtrace+0x0/0x4c8
      [   45.970564]  show_stack+0x30/0x40
      [   45.970981]  dump_stack_lvl+0x120/0x18c
      [   45.971470]  print_address_description.constprop.0+0x74/0x30c
      [   45.972182]  kasan_report+0x1e8/0x200
      [   45.972659]  __asan_report_load8_noabort+0x2c/0x50
      [   45.973273]  bpf_xdp_link_release+0x3b8/0x3d0
      [   45.973834]  bpf_link_free+0xd0/0x188
      [   45.974315]  bpf_link_put+0x1d0/0x218
      [   45.974790]  bpf_link_release+0x3c/0x58
      [   45.975291]  __fput+0x20c/0x7e8
      [   45.975706]  ____fput+0x24/0x30
      [   45.976117]  task_work_run+0x104/0x258
      [   45.976609]  do_notify_resume+0x894/0xaf8
      [   45.977121]  work_pending+0xc/0x328
      [   45.977575]
      [   45.977775] The buggy address belongs to the page:
      [   45.978369] page:fffffc00003e6600 refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x4f998
      [   45.979522] flags: 0x7fffe0000000000(node=0|zone=0|lastcpupid=0x3ffff)
      [   45.980349] raw: 07fffe0000000000 fffffc00003e6708 ffff0000dac3c010 0000000000000000
      [   45.981309] raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
      [   45.982259] page dumped because: kasan: bad access detected
      [   45.982948]
      [   45.983153] Memory state around the buggy address:
      [   45.983753]  ffff00000f997f80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
      [   45.984645]  ffff00000f998000: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
      [   45.985533] >ffff00000f998080: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
      [   45.986419]                                               ^
      [   45.987112]  ffff00000f998100: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
      [   45.988006]  ffff00000f998180: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
      [   45.988895] ==================================================================
      [   45.989773] Disabling lock debugging due to kernel taint
      [   45.990552] Kernel panic - not syncing: panic_on_warn set ...
      [   45.991166] CPU: 1 PID: 732 Comm: a.out Tainted: G    B             5.13.0+ #22
      [   45.991929] Hardware name: linux,dummy-virt (DT)
      [   45.992448] Call trace:
      [   45.992753]  dump_backtrace+0x0/0x4c8
      [   45.993208]  show_stack+0x30/0x40
      [   45.993627]  dump_stack_lvl+0x120/0x18c
      [   45.994113]  dump_stack+0x1c/0x34
      [   45.994530]  panic+0x3a4/0x7d8
      [   45.994930]  end_report+0x194/0x198
      [   45.995380]  kasan_report+0x134/0x200
      [   45.995850]  __asan_report_load8_noabort+0x2c/0x50
      [   45.996453]  bpf_xdp_link_release+0x3b8/0x3d0
      [   45.997007]  bpf_link_free+0xd0/0x188
      [   45.997474]  bpf_link_put+0x1d0/0x218
      [   45.997942]  bpf_link_release+0x3c/0x58
      [   45.998429]  __fput+0x20c/0x7e8
      [   45.998833]  ____fput+0x24/0x30
      [   45.999247]  task_work_run+0x104/0x258
      [   45.999731]  do_notify_resume+0x894/0xaf8
      [   46.000236]  work_pending+0xc/0x328
      [   46.000697] SMP: stopping secondary CPUs
      [   46.001226] Dumping ftrace buffer:
      [   46.001663]    (ftrace buffer empty)
      [   46.002110] Kernel Offset: disabled
      [   46.002545] CPU features: 0x00000001,23202c00
      [   46.003080] Memory Limit: none
      
      Fixes: aa8d3a71
      
       ("bpf, xdp: Add bpf_link-based XDP attachment API")
      Reported-by: default avatarAbaci <abaci@linux.alibaba.com>
      Signed-off-by: default avatarXuan Zhuo <xuanzhuo@linux.alibaba.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Reviewed-by: default avatarDust Li <dust.li@linux.alibaba.com>
      Acked-by: default avatarAndrii Nakryiko <andrii@kernel.org>
      Link: https://lore.kernel.org/bpf/20210710031635.41649-1-xuanzhuo@linux.alibaba.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      ca9ba1de
    • Daniel Borkmann's avatar
      bpf: Fix tail_call_reachable rejection for interpreter when jit failed · 39f1735c
      Daniel Borkmann authored
      [ Upstream commit 5dd0a6b8 ]
      
      During testing of f263a814 ("bpf: Track subprog poke descriptors correctly
      and fix use-after-free") under various failure conditions, for example, when
      jit_subprogs() fails and tries to clean up the program to be run under the
      interpreter, we ran into the following freeze:
      
        [...]
        #127/8 tailcall_bpf2bpf_3:FAIL
        [...]
        [   92.041251] BUG: KASAN: slab-out-of-bounds in ___bpf_prog_run+0x1b9d/0x2e20
        [   92.042408] Read of size 8 at addr ffff88800da67f68 by task test_progs/682
        [   92.043707]
        [   92.044030] CPU: 1 PID: 682 Comm: test_progs Tainted: G   O   5.13.0-53301-ge6c08cb33a30-dirty #87
        [   92.045542] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1 04/01/2014
        [   92.046785] Call Trace:
        [   92.047171]  ? __bpf_prog_run_args64+0xc0/0xc0
        [   92.047773]  ? __bpf_prog_run_args32+0x8b/0xb0
        [   92.048389]  ? __bpf_prog_run_args64+0xc0/0xc0
        [   92.049019]  ? ktime_get+0x117/0x130
        [...] // few hundred [similar] lines more
        [   92.659025]  ? ktime_get+0x117/0x130
        [   92.659845]  ? __bpf_prog_run_args64+0xc0/0xc0
        [   92.660738]  ? __bpf_prog_run_args32+0x8b/0xb0
        [   92.661528]  ? __bpf_prog_run_args64+0xc0/0xc0
        [   92.662378]  ? print_usage_bug+0x50/0x50
        [   92.663221]  ? print_usage_bug+0x50/0x50
        [   92.664077]  ? bpf_ksym_find+0x9c/0xe0
        [   92.664887]  ? ktime_get+0x117/0x130
        [   92.665624]  ? kernel_text_address+0xf5/0x100
        [   92.666529]  ? __kernel_text_address+0xe/0x30
        [   92.667725]  ? unwind_get_return_address+0x2f/0x50
        [   92.668854]  ? ___bpf_prog_run+0x15d4/0x2e20
        [   92.670185]  ? ktime_get+0x117/0x130
        [   92.671130]  ? __bpf_prog_run_args64+0xc0/0xc0
        [   92.672020]  ? __bpf_prog_run_args32+0x8b/0xb0
        [   92.672860]  ? __bpf_prog_run_args64+0xc0/0xc0
        [   92.675159]  ? ktime_get+0x117/0x130
        [   92.677074]  ? lock_is_held_type+0xd5/0x130
        [   92.678662]  ? ___bpf_prog_run+0x15d4/0x2e20
        [   92.680046]  ? ktime_get+0x117/0x130
        [   92.681285]  ? __bpf_prog_run32+0x6b/0x90
        [   92.682601]  ? __bpf_prog_run64+0x90/0x90
        [   92.683636]  ? lock_downgrade+0x370/0x370
        [   92.684647]  ? mark_held_locks+0x44/0x90
        [   92.685652]  ? ktime_get+0x117/0x130
        [   92.686752]  ? lockdep_hardirqs_on+0x79/0x100
        [   92.688004]  ? ktime_get+0x117/0x130
        [   92.688573]  ? __cant_migrate+0x2b/0x80
        [   92.689192]  ? bpf_test_run+0x2f4/0x510
        [   92.689869]  ? bpf_test_timer_continue+0x1c0/0x1c0
        [   92.690856]  ? rcu_read_lock_bh_held+0x90/0x90
        [   92.691506]  ? __kasan_slab_alloc+0x61/0x80
        [   92.692128]  ? eth_type_trans+0x128/0x240
        [   92.692737]  ? __build_skb+0x46/0x50
        [   92.693252]  ? bpf_prog_test_run_skb+0x65e/0xc50
        [   92.693954]  ? bpf_prog_test_run_raw_tp+0x2d0/0x2d0
        [   92.694639]  ? __fget_light+0xa1/0x100
        [   92.695162]  ? bpf_prog_inc+0x23/0x30
        [   92.695685]  ? __sys_bpf+0xb40/0x2c80
        [   92.696324]  ? bpf_link_get_from_fd+0x90/0x90
        [   92.697150]  ? mark_held_locks+0x24/0x90
        [   92.698007]  ? lockdep_hardirqs_on_prepare+0x124/0x220
        [   92.699045]  ? finish_task_switch+0xe6/0x370
        [   92.700072]  ? lockdep_hardirqs_on+0x79/0x100
        [   92.701233]  ? finish_task_switch+0x11d/0x370
        [   92.702264]  ? __switch_to+0x2c0/0x740
        [   92.703148]  ? mark_held_locks+0x24/0x90
        [   92.704155]  ? __x64_sys_bpf+0x45/0x50
        [   92.705146]  ? do_syscall_64+0x35/0x80
        [   92.706953]  ? entry_SYSCALL_64_after_hwframe+0x44/0xae
        [...]
      
      Turns out that the program rejection from e411901c ("bpf: allow for tailcalls
      in BPF subprograms for x64 JIT") is buggy since env->prog->aux->tail_call_reachable
      is never true. Commit ebf7d1f5 ("bpf, x64: rework pro/epilogue and tailcall
      handling in JIT") added a tracker into check_max_stack_depth() which propagates
      the tail_call_reachable condition throughout the subprograms. This info is then
      assigned to the subprogram's func[i]->aux->tail_call_reachable. However, in the
      case of the rejection check upon JIT failure, env->prog->aux->tail_call_reachable
      is used. func[0]->aux->tail_call_reachable which represents the main program's
      information did not propagate this to the outer env->prog->aux, though. Add this
      propagation into check_max_stack_depth() where it needs to belong so that the
      check can be done reliably.
      
      Fixes: ebf7d1f5 ("bpf, x64: rework pro/epilogue and tailcall handling in JIT")
      Fixes: e411901c
      
       ("bpf: allow for tailcalls in BPF subprograms for x64 JIT")
      Co-developed-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Signed-off-by: default avatarJohn Fastabend <john.fastabend@gmail.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Acked-by: default avatarMaciej Fijalkowski <maciej.fijalkowski@intel.com>
      Link: https://lore.kernel.org/bpf/618c34e3163ad1a36b1e82377576a6081e182f25.1626123173.git.daniel@iogearbox.net
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      39f1735c
    • Xuan Zhuo's avatar
      bpf, test: fix NULL pointer dereference on invalid expected_attach_type · 2b4046e6
      Xuan Zhuo authored
      [ Upstream commit 5e21bb4e ]
      
      These two types of XDP progs (BPF_XDP_DEVMAP, BPF_XDP_CPUMAP) will not be
      executed directly in the driver, therefore we should also not directly
      run them from here. To run in these two situations, there must be further
      preparations done, otherwise these may cause a kernel panic.
      
      For more details, see also dev_xdp_attach().
      
        [   46.982479] BUG: kernel NULL pointer dereference, address: 0000000000000000
        [   46.984295] #PF: supervisor read access in kernel mode
        [   46.985777] #PF: error_code(0x0000) - not-present page
        [   46.987227] PGD 800000010dca4067 P4D 800000010dca4067 PUD 10dca6067 PMD 0
        [   46.989201] Oops: 0000 [#1] SMP PTI
        [   46.990304] CPU: 7 PID: 562 Comm: a.out Not tainted 5.13.0+ #44
        [   46.992001] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.14.0-0-g155821a1990b-prebuilt.qemu.org 04/01/24
        [   46.995113] RIP: 0010:___bpf_prog_run+0x17b/0x1710
        [   46.996586] Code: 49 03 14 cc e8 76 f6 fe ff e9 ad fe ff ff 0f b6 43 01 48 0f bf 4b 02 48 83 c3 08 89 c2 83 e0 0f c0 ea 04 02
        [   47.001562] RSP: 0018:ffffc900005afc58 EFLAGS: 00010246
        [   47.003115] RAX: 0000000000000000 RBX: ffffc9000023f068 RCX: 0000000000000000
        [   47.005163] RDX: 0000000000000000 RSI: 0000000000000079 RDI: ffffc900005afc98
        [   47.007135] RBP: 0000000000000000 R08: ffffc9000023f048 R09: c0000000ffffdfff
        [   47.009171] R10: 0000000000000001 R11: ffffc900005afb40 R12: ffffc900005afc98
        [   47.011172] R13: 0000000000000001 R14: 0000000000000001 R15: ffffffff825258a8
        [   47.013244] FS:  00007f04a5207580(0000) GS:ffff88842fdc0000(0000) knlGS:0000000000000000
        [   47.015705] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        [   47.017475] CR2: 0000000000000000 CR3: 0000000100182005 CR4: 0000000000770ee0
        [   47.019558] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
        [   47.021595] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
        [   47.023574] PKRU: 55555554
        [   47.024571] Call Trace:
        [   47.025424]  __bpf_prog_run32+0x32/0x50
        [   47.026296]  ? printk+0x53/0x6a
        [   47.027066]  ? ktime_get+0x39/0x90
        [   47.027895]  bpf_test_run.cold.28+0x23/0x123
        [   47.028866]  ? printk+0x53/0x6a
        [   47.029630]  bpf_prog_test_run_xdp+0x149/0x1d0
        [   47.030649]  __sys_bpf+0x1305/0x23d0
        [   47.031482]  __x64_sys_bpf+0x17/0x20
        [   47.032316]  do_syscall_64+0x3a/0x80
        [   47.033165]  entry_SYSCALL_64_after_hwframe+0x44/0xae
        [   47.034254] RIP: 0033:0x7f04a51364dd
        [   47.035133] Code: 00 c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 48
        [   47.038768] RSP: 002b:00007fff8f9fc518 EFLAGS: 00000213 ORIG_RAX: 0000000000000141
        [   47.040344] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f04a51364dd
        [   47.041749] RDX: 0000000000000048 RSI: 0000000020002a80 RDI: 000000000000000a
        [   47.043171] RBP: 00007fff8f9fc530 R08: 0000000002049300 R09: 0000000020000100
        [   47.044626] R10: 0000000000000004 R11: 0000000000000213 R12: 0000000000401070
        [   47.046088] R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
        [   47.047579] Modules linked in:
        [   47.048318] CR2: 0000000000000000
        [   47.049120] ---[ end trace 7ad34443d5be719a ]---
        [   47.050273] RIP: 0010:___bpf_prog_run+0x17b/0x1710
        [   47.051343] Code: 49 03 14 cc e8 76 f6 fe ff e9 ad fe ff ff 0f b6 43 01 48 0f bf 4b 02 48 83 c3 08 89 c2 83 e0 0f c0 ea 04 02
        [   47.054943] RSP: 0018:ffffc900005afc58 EFLAGS: 00010246
        [   47.056068] RAX: 0000000000000000 RBX: ffffc9000023f068 RCX: 0000000000000000
        [   47.057522] RDX: 0000000000000000 RSI: 0000000000000079 RDI: ffffc900005afc98
        [   47.058961] RBP: 0000000000000000 R08: ffffc9000023f048 R09: c0000000ffffdfff
        [   47.060390] R10: 0000000000000001 R11: ffffc900005afb40 R12: ffffc900005afc98
        [   47.061803] R13: 0000000000000001 R14: 0000000000000001 R15: ffffffff825258a8
        [   47.063249] FS:  00007f04a5207580(0000) GS:ffff88842fdc0000(0000) knlGS:0000000000000000
        [   47.065070] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        [   47.066307] CR2: 0000000000000000 CR3: 0000000100182005 CR4: 0000000000770ee0
        [   47.067747] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
        [   47.069217] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
        [   47.070652] PKRU: 55555554
        [   47.071318] Kernel panic - not syncing: Fatal exception
        [   47.072854] Kernel Offset: disabled
        [   47.073683] ---[ end Kernel panic - not syncing: Fatal exception ]---
      
      Fixes: 92164774 ("bpf: cpumap: Add the possibility to attach an eBPF program to cpumap")
      Fixes: fbee97fe
      
       ("bpf: Add support to attach bpf program to a devmap entry")
      Reported-by: default avatarAbaci <abaci@linux.alibaba.com>
      Signed-off-by: default avatarXuan Zhuo <xuanzhuo@linux.alibaba.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Reviewed-by: default avatarDust Li <dust.li@linux.alibaba.com>
      Acked-by: default avatarJesper Dangaard Brouer <brouer@redhat.com>
      Acked-by: default avatarDavid Ahern <dsahern@kernel.org>
      Acked-by: default avatarSong Liu <songliubraving@fb.com>
      Link: https://lore.kernel.org/bpf/20210708080409.73525-1-xuanzhuo@linux.alibaba.com
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2b4046e6
    • Maxim Schwalm's avatar
      ASoC: rt5631: Fix regcache sync errors on resume · 3dba72d1
      Maxim Schwalm authored
      [ Upstream commit c71f78a6 ]
      
      The ALC5631 does not like multi-write accesses, avoid them. This fixes:
      
      rt5631 4-001a: Unable to sync registers 0x3a-0x3c. -121
      
      errors on resume from suspend (and all registers after the registers in
      the error not being synced).
      
      Inspired by commit 2d30e949
      
       ("ASoC: rt5651: Fix regcache sync errors
      on resume") from Hans de Geode, which fixed the same errors on ALC5651.
      
      Signed-off-by: default avatarMaxim Schwalm <maxim.schwalm@gmail.com>
      Link: https://lore.kernel.org/r/20210712005011.28536-1-digetx@gmail.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      3dba72d1
    • Peter Hess's avatar
      spi: mediatek: fix fifo rx mode · 2435dcfd
      Peter Hess authored
      [ Upstream commit 3a70dd2d ]
      
      In FIFO mode were two problems:
      - RX mode was never handled and
      - in this case the tx_buf pointer was NULL and caused an exception
      
      fix this by handling RX mode in mtk_spi_fifo_transfer
      
      Fixes: a568231f
      
       ("spi: mediatek: Add spi bus for Mediatek MT8173")
      Signed-off-by: default avatarPeter Hess <peter.hess@ph-home.de>
      Signed-off-by: default avatarFrank Wunderlich <frank-w@public-files.de>
      Link: https://lore.kernel.org/r/20210706121609.680534-1-linux@fw-web.de
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      2435dcfd
    • Axel Lin's avatar
      regulator: hi6421: Fix getting wrong drvdata · a9a85bfe
      Axel Lin authored
      [ Upstream commit 1c73daee ]
      
      Since config.dev = pdev->dev.parent in current code, so
      dev_get_drvdata(rdev->dev.parent) call in hi6421_regulator_enable
      returns the drvdata of the mfd device rather than the regulator. Fix it.
      
      This was broken while converting to use simplified DT parsing because the
      config.dev changed from pdev->dev to pdev->dev.parent for parsing the
      parent's of_node.
      
      Fixes: 29dc269a
      
       ("regulator: hi6421: Convert to use simplified DT parsing")
      Signed-off-by: default avatarAxel Lin <axel.lin@ingics.com>
      Link: https://lore.kernel.org/r/20210630095959.2411543-1-axel.lin@ingics.com
      Signed-off-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a9a85bfe