linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Zhou Qingyang <zhou1615@umn.edu>,
	Leon Romanovsky <leonro@nvidia.com>,
	Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH 4.14 093/106] net/mlx4_en: Fix an use-after-free bug in mlx4_en_try_alloc_resources()
Date: Mon,  6 Dec 2021 15:56:41 +0100	[thread overview]
Message-ID: <20211206145558.747178592@linuxfoundation.org> (raw)
In-Reply-To: <20211206145555.386095297@linuxfoundation.org>

From: Zhou Qingyang <zhou1615@umn.edu>

commit addad7643142f500080417dd7272f49b7a185570 upstream.

In mlx4_en_try_alloc_resources(), mlx4_en_copy_priv() is called and
tmp->tx_cq will be freed on the error path of mlx4_en_copy_priv().
After that mlx4_en_alloc_resources() is called and there is a dereference
of &tmp->tx_cq[t][i] in mlx4_en_alloc_resources(), which could lead to
a use after free problem on failure of mlx4_en_copy_priv().

Fix this bug by adding a check of mlx4_en_copy_priv()

This bug was found by a static analyzer. The analysis employs
differential checking to identify inconsistent security operations
(e.g., checks or kfrees) between two code paths and confirms that the
inconsistent operations are not recovered in the current function or
the callers, so they constitute bugs.

Note that, as a bug found by static analysis, it can be a false
positive or hard to trigger. Multiple researchers have cross-reviewed
the bug.

Builds with CONFIG_MLX4_EN=m show no new warnings,
and our static analyzer no longer warns about this code.

Fixes: ec25bc04ed8e ("net/mlx4_en: Add resilience in low memory systems")
Signed-off-by: Zhou Qingyang <zhou1615@umn.edu>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Link: https://lore.kernel.org/r/20211130164438.190591-1-zhou1615@umn.edu
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/net/ethernet/mellanox/mlx4/en_netdev.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -2283,9 +2283,14 @@ int mlx4_en_try_alloc_resources(struct m
 				bool carry_xdp_prog)
 {
 	struct bpf_prog *xdp_prog;
-	int i, t;
+	int i, t, ret;
 
-	mlx4_en_copy_priv(tmp, priv, prof);
+	ret = mlx4_en_copy_priv(tmp, priv, prof);
+	if (ret) {
+		en_warn(priv, "%s: mlx4_en_copy_priv() failed, return\n",
+			__func__);
+		return ret;
+	}
 
 	if (mlx4_en_alloc_resources(tmp)) {
 		en_warn(priv,



  parent reply	other threads:[~2021-12-06 15:14 UTC|newest]

Thread overview: 108+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-06 14:55 [PATCH 4.14 000/106] 4.14.257-rc1 review Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 001/106] USB: serial: option: add Telit LE910S1 0x9200 composition Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 002/106] USB: serial: option: add Fibocom FM101-GL variants Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 003/106] usb: hub: Fix usb enumeration issue due to address0 race Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 004/106] usb: hub: Fix locking issues with address0_mutex Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 005/106] binder: fix test regression due to sender_euid change Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 006/106] ALSA: ctxfi: Fix out-of-range access Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 007/106] media: cec: copy sequence field for the reply Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 008/106] HID: wacom: Use "Confidence" flag to prevent reporting invalid contacts Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 009/106] staging: rtl8192e: Fix use after free in _rtl92e_pci_disconnect() Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 010/106] fuse: fix page stealing Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 011/106] xen: dont continue xenstore initialization in case of errors Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 012/106] xen: detect uninitialized xenbus in xenbus_init Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 013/106] tracing: Fix pid filtering when triggers are attached Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 014/106] netfilter: ipvs: Fix reuse connection if RS weight is 0 Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 015/106] ARM: dts: BCM5301X: Fix I2C controller interrupt Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 016/106] ARM: dts: BCM5301X: Add interrupt properties to GPIO node Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 017/106] ASoC: topology: Add missing rwsem around snd_ctl_remove() calls Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 018/106] net: ieee802154: handle iftypes as u32 Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 019/106] NFSv42: Dont fail clone() unless the OP_CLONE operation failed Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 020/106] ARM: socfpga: Fix crash with CONFIG_FORTIRY_SOURCE Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 021/106] scsi: mpt3sas: Fix kernel panic during drive powercycle test Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 022/106] drm/vc4: fix error code in vc4_create_object() Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 023/106] ipv6: fix typos in __ip6_finish_output() Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 024/106] net/smc: Ensure the active closing peer first closes clcsock Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 025/106] PM: hibernate: use correct mode for swsusp_close() Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 026/106] tcp_cubic: fix spurious Hystart ACK train detections for not-cwnd-limited flows Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 027/106] MIPS: use 3-level pgtable for 64KB page size on MIPS_VA_BITS_48 Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 028/106] net/smc: Dont call clcsock shutdown twice when smc shutdown Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 029/106] vhost/vsock: fix incorrect used length reported to the guest Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 030/106] tracing: Check pid filtering when creating events Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 031/106] s390/mm: validate VMA in PGSTE manipulation functions Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 032/106] PCI: aardvark: Fix I/O space page leak Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 033/106] PCI: aardvark: Fix a leaked reference by adding missing of_node_put() Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 034/106] PCI: aardvark: Wait for endpoint to be ready before training link Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 035/106] PCI: aardvark: Train link immediately after enabling training Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 036/106] PCI: aardvark: Improve link training Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 037/106] PCI: aardvark: Issue PERST via GPIO Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 038/106] PCI: aardvark: Replace custom macros by standard linux/pci_regs.h macros Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 039/106] PCI: aardvark: Indicate error in val when config read fails Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 040/106] PCI: aardvark: Introduce an advk_pcie_valid_device() helper Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 041/106] PCI: aardvark: Dont touch PCIe registers if no card connected Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 042/106] PCI: aardvark: Fix compilation on s390 Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 043/106] PCI: aardvark: Move PCIe reset card code to advk_pcie_train_link() Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 044/106] PCI: aardvark: Update comment about disabling link training Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 045/106] PCI: aardvark: Remove PCIe outbound window configuration Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 046/106] PCI: aardvark: Configure PCIe resources from ranges DT property Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 047/106] PCI: aardvark: Fix PCIe Max Payload Size setting Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 048/106] PCI: Add PCI_EXP_LNKCTL2_TLS* macros Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 049/106] PCI: aardvark: Fix link training Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 050/106] PCI: aardvark: Fix checking for link up via LTSSM state Greg Kroah-Hartman
2021-12-06 14:55 ` [PATCH 4.14 051/106] pinctrl: armada-37xx: Correct mpp definitions Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 052/106] pinctrl: armada-37xx: add missing pin: PCIe1 Wakeup Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 053/106] pinctrl: armada-37xx: Correct PWM pins definitions Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 054/106] arm64: dts: marvell: armada-37xx: declare PCIe reset pin Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 055/106] arm64: dts: marvell: armada-37xx: Set pcie_reset_pin to gpio function Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 056/106] hugetlbfs: flush TLBs correctly after huge_pmd_unshare Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 057/106] proc/vmcore: fix clearing user buffer by properly using clear_user() Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 058/106] NFC: add NCI_UNREG flag to eliminate the race Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 059/106] fuse: release pipe buf after last use Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 060/106] xen: sync include/xen/interface/io/ring.h with Xens newest version Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 061/106] xen/blkfront: read response from backend only once Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 062/106] xen/blkfront: dont take local copy of a request from the ring page Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 063/106] xen/blkfront: dont trust the backend response data blindly Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 064/106] xen/netfront: read response from backend only once Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 065/106] xen/netfront: dont read data from request on the ring page Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 066/106] xen/netfront: disentangle tx_skb_freelist Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 067/106] xen/netfront: dont trust the backend response data blindly Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 068/106] tty: hvc: replace BUG_ON() with negative return value Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 069/106] shm: extend forced shm destroy to support objects from several IPC nses Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 070/106] ipc: WARN if trying to remove ipc object which is absent Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 071/106] NFSv42: Fix pagecache invalidation after COPY/CLONE Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 072/106] hugetlb: take PMD sharing into account when flushing tlb/caches Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 073/106] net: return correct error code Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 074/106] platform/x86: thinkpad_acpi: Fix WWAN device disabled issue after S3 deep Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 075/106] s390/setup: avoid using memblock_enforce_memory_limit Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 076/106] btrfs: check-integrity: fix a warning on write caching disabled disk Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 077/106] thermal: core: Reset previous low and high trip during thermal zone init Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 078/106] scsi: iscsi: Unblock session then wake up error handler Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 079/106] ethernet: hisilicon: hns: hns_dsaf_misc: fix a possible array overflow in hns_dsaf_ge_srst_by_port() Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 080/106] net: tulip: de4x5: fix the problem that the array lp->phy[8] may be out of bound Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 081/106] net: ethernet: dec: tulip: de4x5: fix possible array overflows in type3_infoblock() Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 082/106] perf hist: Fix memory leak of a perf_hpp_fmt Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 083/106] vrf: Reset IPCB/IP6CB when processing outbound pkts in vrf dev xmit Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 084/106] kprobes: Limit max data_size of the kretprobe instances Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 085/106] sata_fsl: fix UAF in sata_fsl_port_stop when rmmod sata_fsl Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 086/106] sata_fsl: fix warning in remove_proc_entry " Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 087/106] fs: add fget_many() and fput_many() Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 088/106] fget: check that the fd still exists after getting a ref to it Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 089/106] natsemi: xtensa: fix section mismatch warnings Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 090/106] net: qlogic: qlcnic: Fix a NULL pointer dereference in qlcnic_83xx_add_rings() Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 091/106] net: mpls: Fix notifications when deleting a device Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 092/106] siphash: use _unaligned version by default Greg Kroah-Hartman
2021-12-06 14:56 ` Greg Kroah-Hartman [this message]
2021-12-06 14:56 ` [PATCH 4.14 094/106] net: usb: lan78xx: lan78xx_phy_init(): use PHY_POLL instead of "0" if no IRQ is available Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 095/106] net/rds: correct socket tunable error in rds_tcp_tune() Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 096/106] net/smc: Keep smc_close_final rc during active close Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 097/106] parisc: Fix KBUILD_IMAGE for self-extracting kernel Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 098/106] parisc: Fix "make install" on newer debian releases Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 099/106] vgacon: Propagate console boot parameters before calling `vc_resize Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 100/106] xhci: Fix commad ring abort, write all 64 bits to CRCR register Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 101/106] usb: typec: tcpm: Wait in SNK_DEBOUNCED until disconnect Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 102/106] x86/64/mm: Map all kernel memory into trampoline_pgd Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 103/106] tty: serial: msm_serial: Deactivate RX DMA for polling support Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 104/106] serial: pl011: Add ACPI SBSA UART match id Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 105/106] serial: core: fix transmit-buffer reset and memleak Greg Kroah-Hartman
2021-12-06 14:56 ` [PATCH 4.14 106/106] parisc: Mark cr16 CPU clocksource unstable on all SMP machines Greg Kroah-Hartman
2021-12-07 20:40 ` [PATCH 4.14 000/106] 4.14.257-rc1 review Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211206145558.747178592@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=kuba@kernel.org \
    --cc=leonro@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=zhou1615@umn.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).