stable.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, Yonglong Liu <liuyonglong@huawei.com>,
	Huazhong Tan <tanhuazhong@huawei.com>,
	"David S. Miller" <davem@davemloft.net>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH 4.14 25/71] net: hns: Fix use after free identified by SLUB debug
Date: Mon, 25 Feb 2019 22:11:27 +0100	[thread overview]
Message-ID: <20190225195036.403120502@linuxfoundation.org> (raw)
In-Reply-To: <20190225195034.555044862@linuxfoundation.org>

4.14-stable review patch.  If anyone has any objections, please let me know.

------------------

[ Upstream commit bb989501abcafa0de5f18b0ec0ec459b5b817908 ]

When enable SLUB debug, than remove hns_enet_drv module, SLUB debug will
identify a use after free bug:

[134.189505] Unable to handle kernel paging request at virtual address
		006b6b6b6b6b6b6b
[134.197553] Mem abort info:
[134.200381]   ESR = 0x96000004
[134.203487]   Exception class = DABT (current EL), IL = 32 bits
[134.209497]   SET = 0, FnV = 0
[134.212596]   EA = 0, S1PTW = 0
[134.215777] Data abort info:
[134.218701]   ISV = 0, ISS = 0x00000004
[134.222596]   CM = 0, WnR = 0
[134.225606] [006b6b6b6b6b6b6b] address between user and kernel address ranges
[134.232851] Internal error: Oops: 96000004 [#1] SMP
[134.237798] CPU: 21 PID: 27834 Comm: rmmod Kdump: loaded Tainted: G
		OE     4.19.5-1.2.34.aarch64 #1
[134.247856] Hardware name: Huawei TaiShan 2280 /BC11SPCD, BIOS 1.58 10/24/2018
[134.255181] pstate: 20000005 (nzCv daif -PAN -UAO)
[134.260044] pc : hns_ae_put_handle+0x38/0x60
[134.264372] lr : hns_ae_put_handle+0x24/0x60
[134.268700] sp : ffff00001be93c50
[134.272054] x29: ffff00001be93c50 x28: ffff802faaec8040
[134.277442] x27: 0000000000000000 x26: 0000000000000000
[134.282830] x25: 0000000056000000 x24: 0000000000000015
[134.288284] x23: ffff0000096fe098 x22: ffff000001050070
[134.293671] x21: ffff801fb3c044a0 x20: ffff80afb75ec098
[134.303287] x19: ffff80afb75ec098 x18: 0000000000000000
[134.312945] x17: 0000000000000000 x16: 0000000000000000
[134.322517] x15: 0000000000000002 x14: 0000000000000000
[134.332030] x13: dead000000000100 x12: ffff7e02bea3c988
[134.341487] x11: ffff80affbee9e68 x10: 0000000000000000
[134.351033] x9 : 6fffff8000008101 x8 : 0000000000000000
[134.360569] x7 : dead000000000100 x6 : ffff000009579748
[134.370059] x5 : 0000000000210d00 x4 : 0000000000000000
[134.379550] x3 : 0000000000000001 x2 : 0000000000000000
[134.388813] x1 : 6b6b6b6b6b6b6b6b x0 : 0000000000000000
[134.397993] Process rmmod (pid: 27834, stack limit = 0x00000000d474b7fd)
[134.408498] Call trace:
[134.414611]  hns_ae_put_handle+0x38/0x60
[134.422208]  hnae_put_handle+0xd4/0x108
[134.429563]  hns_nic_dev_remove+0x60/0xc0 [hns_enet_drv]
[134.438342]  platform_drv_remove+0x2c/0x70
[134.445958]  device_release_driver_internal+0x174/0x208
[134.454810]  driver_detach+0x70/0xd8
[134.461913]  bus_remove_driver+0x64/0xe8
[134.469396]  driver_unregister+0x34/0x60
[134.476822]  platform_driver_unregister+0x20/0x30
[134.485130]  hns_nic_dev_driver_exit+0x14/0x6e4 [hns_enet_drv]
[134.494634]  __arm64_sys_delete_module+0x238/0x290

struct hnae_handle is a member of struct hnae_vf_cb, so when vf_cb is
freed, than use hnae_handle will cause use after free panic.

This patch frees vf_cb after hnae_handle used.

Signed-off-by: Yonglong Liu <liuyonglong@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
index a185a8be79993..53904f257b19d 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
+++ b/drivers/net/ethernet/hisilicon/hns/hns_ae_adapt.c
@@ -147,12 +147,10 @@ static void hns_ae_put_handle(struct hnae_handle *handle)
 	struct hnae_vf_cb *vf_cb = hns_ae_get_vf_cb(handle);
 	int i;
 
-	vf_cb->mac_cb	 = NULL;
-
-	kfree(vf_cb);
-
 	for (i = 0; i < handle->q_num; i++)
 		hns_ae_get_ring_pair(handle->qs[i])->used_by_vf = 0;
+
+	kfree(vf_cb);
 }
 
 static int hns_ae_wait_flow_down(struct hnae_handle *handle)
-- 
2.19.1




  parent reply	other threads:[~2019-02-25 22:01 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-25 21:11 [PATCH 4.14 00/71] 4.14.104-stable review Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 01/71] ARM: 8834/1: Fix: kprobes: optimized kprobes illegal instruction Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 02/71] tracing: Fix number of entries in trace header Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 03/71] MIPS: eBPF: Always return sign extended 32b values Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 04/71] mac80211: Restore vif beacon interval if start ap fails Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 05/71] mac80211: Free mpath object when rhashtable insertion fails Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 06/71] libceph: handle an empty authorize reply Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 07/71] ceph: avoid repeatedly adding inode to mdsc->snap_flush_list Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 08/71] numa: change get_mempolicy() to use nr_node_ids instead of MAX_NUMNODES Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 09/71] proc, oom: do not report alien mms when setting oom_score_adj Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 10/71] KEYS: allow reaching the keys quotas exactly Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 11/71] mfd: ti_am335x_tscadc: Use PLATFORM_DEVID_AUTO while registering mfd cells Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 12/71] pvcalls-back: set -ENOTCONN in pvcalls_conn_back_read Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 13/71] mfd: twl-core: Fix section annotations on {,un}protect_pm_master Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 14/71] mfd: db8500-prcmu: Fix some section annotations Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 15/71] mfd: mt6397: Do not call irq_domain_remove if PMIC unsupported Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 16/71] mfd: ab8500-core: Return zero in get_register_interruptible() Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 17/71] mfd: bd9571mwv: Add volatile register to make DVFS work Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 18/71] mfd: qcom_rpm: write fw_version to CTRL_REG Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 19/71] mfd: wm5110: Add missing ASRC rate register Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 20/71] mfd: tps65218: Use devm_regmap_add_irq_chip and clean up error path in probe() Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 21/71] mfd: mc13xxx: Fix a missing check of a register-read failure Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 22/71] xen/pvcalls: remove set but not used variable intf Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 23/71] qed: Fix qed_chain_set_prod() for PBL chains with non power of 2 page count Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 24/71] qed: Fix qed_ll2_post_rx_buffer_notify_fw() by adding a write memory barrier Greg Kroah-Hartman
2019-02-25 21:11 ` Greg Kroah-Hartman [this message]
2019-02-25 21:11 ` [PATCH 4.14 26/71] MIPS: ath79: Enable OF serial ports in the default config Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 27/71] netfilter: nf_tables: fix leaking object reference count Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 28/71] scsi: qla4xxx: check return code of qla4xxx_copy_from_fwddb_param Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 29/71] scsi: isci: initialize shost fully before calling scsi_add_host() Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 30/71] MIPS: jazz: fix 64bit build Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 31/71] bpf: correctly set initial window on active Fast Open sender Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 32/71] net: stmmac: Fix PCI module removal leak Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 33/71] isdn: i4l: isdn_tty: Fix some concurrency double-free bugs Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 34/71] scsi: ufs: Fix system suspend status Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 35/71] scsi: qedi: Add ep_state for login completion on un-reachable targets Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 36/71] always clear the X2APIC_ENABLE bit for PV guest Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 37/71] drm/meson: add missing of_node_put Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 38/71] atm: he: fix sign-extension overflow on large shift Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 39/71] hwmon: (tmp421) Correct the misspelling of the tmp442 compatible attribute in OF device ID table Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 40/71] leds: lp5523: fix a missing check of return value of lp55xx_read Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 41/71] bpf: bpf_setsockopt: reset sock dst on SO_MARK changes Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 42/71] mlxsw: spectrum_switchdev: Do not treat static FDB entries as sticky Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 43/71] net/mlx5e: Fix wrong (zero) TX drop counter indication for representor Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 44/71] isdn: avm: Fix string plus integer warning from Clang Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 45/71] batman-adv: fix uninit-value in batadv_interface_tx() Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 46/71] ipv6: propagate genlmsg_reply return code Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 47/71] net/mlx5e: Dont overwrite pedit action when multiple pedit used Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 48/71] net/packet: fix 4gb buffer limit due to overflow check Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 49/71] net: sfp: do not probe SFP module before were attached Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 50/71] sctp: call gso_reset_checksum when computing checksum in sctp_gso_segment Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 51/71] team: avoid complex list operations in team_nl_cmd_options_set() Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 52/71] sit: check if IPv6 enabled before calling ip6_err_gen_icmpv6_unreach() Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 53/71] net/mlx4_en: Force CHECKSUM_NONE for short ethernet frames Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 54/71] inet_diag: fix reporting cgroup classid and fallback to priority Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 55/71] RDMA/srp: Rework SCSI device reset handling Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 56/71] KEYS: user: Align the payload buffer Greg Kroah-Hartman
2019-02-25 21:11 ` [PATCH 4.14 57/71] KEYS: always initialize keyring_index_key::desc_len Greg Kroah-Hartman
2019-02-25 21:12 ` [PATCH 4.14 58/71] parisc: Fix ptrace syscall number modification Greg Kroah-Hartman
2019-02-25 21:12 ` [PATCH 4.14 59/71] ARCv2: Enable unaligned access in early ASM code Greg Kroah-Hartman
2019-02-25 21:12 ` [PATCH 4.14 60/71] ARC: U-boot: check arguments paranoidly Greg Kroah-Hartman
2019-02-25 21:12 ` [PATCH 4.14 61/71] ARC: define ARCH_SLAB_MINALIGN = 8 Greg Kroah-Hartman
2019-02-25 21:12 ` [PATCH 4.14 62/71] drm/i915/fbdev: Actually configure untiled displays Greg Kroah-Hartman
2019-02-25 21:12 ` [PATCH 4.14 63/71] net: validate untrusted gso packets without csum offload Greg Kroah-Hartman
2019-02-25 21:12 ` [PATCH 4.14 64/71] net: avoid false positives in untrusted gso validation Greg Kroah-Hartman
2019-02-25 21:12 ` [PATCH 4.14 65/71] Revert "bridge: do not add port to router list when receives query with source 0.0.0.0" Greg Kroah-Hartman
2019-02-25 21:12 ` [PATCH 4.14 66/71] netfilter: nf_tables: fix flush after rule deletion in the same batch Greg Kroah-Hartman
2019-02-25 21:12 ` [PATCH 4.14 67/71] netfilter: nft_compat: use-after-free when deleting targets Greg Kroah-Hartman
2019-02-25 21:12 ` [PATCH 4.14 68/71] netfilter: ipv6: Dont preserve original oif for loopback address Greg Kroah-Hartman
2019-02-25 21:12 ` [PATCH 4.14 69/71] pinctrl: max77620: Use define directive for max77620_pinconf_param values Greg Kroah-Hartman
2019-02-25 21:12 ` [PATCH 4.14 70/71] phy: tegra: remove redundant self assignment of map Greg Kroah-Hartman
2019-02-25 21:12 ` [PATCH 4.14 71/71] sched/sysctl: Fix attributes of some extern declarations Greg Kroah-Hartman
2019-02-26  8:44 ` [PATCH 4.14 00/71] 4.14.104-stable review Naresh Kamboju
2019-02-26 12:24 ` Jon Hunter
2019-02-26 14:20 ` kernelci.org bot
2019-02-26 15:40 ` shuah
2019-02-26 17:46 ` 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=20190225195036.403120502@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liuyonglong@huawei.com \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tanhuazhong@huawei.com \
    /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).