netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: David Howells <dhowells@redhat.com>,
	syzbot+b9be979c55f2bea8ed30@syzkaller.appspotmail.com,
	Sasha Levin <sashal@kernel.org>,
	linux-afs@lists.infradead.org, netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 5.3 20/99] rxrpc: rxrpc_peer needs to hold a ref on the rxrpc_local record
Date: Sat, 26 Oct 2019 09:14:41 -0400	[thread overview]
Message-ID: <20191026131600.2507-20-sashal@kernel.org> (raw)
In-Reply-To: <20191026131600.2507-1-sashal@kernel.org>

From: David Howells <dhowells@redhat.com>

[ Upstream commit 9ebeddef58c41bd700419cdcece24cf64ce32276 ]

The rxrpc_peer record needs to hold a reference on the rxrpc_local record
it points as the peer is used as a base to access information in the
rxrpc_local record.

This can cause problems in __rxrpc_put_peer(), where we need the network
namespace pointer, and in rxrpc_send_keepalive(), where we need to access
the UDP socket, leading to symptoms like:

    BUG: KASAN: use-after-free in __rxrpc_put_peer net/rxrpc/peer_object.c:411
    [inline]
    BUG: KASAN: use-after-free in rxrpc_put_peer+0x685/0x6a0
    net/rxrpc/peer_object.c:435
    Read of size 8 at addr ffff888097ec0058 by task syz-executor823/24216

Fix this by taking a ref on the local record for the peer record.

Fixes: ace45bec6d77 ("rxrpc: Fix firewall route keepalive")
Fixes: 2baec2c3f854 ("rxrpc: Support network namespacing")
Reported-by: syzbot+b9be979c55f2bea8ed30@syzkaller.appspotmail.com
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/rxrpc/peer_object.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/rxrpc/peer_object.c b/net/rxrpc/peer_object.c
index b700b7ecaa3d8..64830d8c1fdb5 100644
--- a/net/rxrpc/peer_object.c
+++ b/net/rxrpc/peer_object.c
@@ -216,7 +216,7 @@ struct rxrpc_peer *rxrpc_alloc_peer(struct rxrpc_local *local, gfp_t gfp)
 	peer = kzalloc(sizeof(struct rxrpc_peer), gfp);
 	if (peer) {
 		atomic_set(&peer->usage, 1);
-		peer->local = local;
+		peer->local = rxrpc_get_local(local);
 		INIT_HLIST_HEAD(&peer->error_targets);
 		peer->service_conns = RB_ROOT;
 		seqlock_init(&peer->service_conn_lock);
@@ -307,7 +307,6 @@ void rxrpc_new_incoming_peer(struct rxrpc_sock *rx, struct rxrpc_local *local,
 	unsigned long hash_key;
 
 	hash_key = rxrpc_peer_hash_key(local, &peer->srx);
-	peer->local = local;
 	rxrpc_init_peer(rx, peer, hash_key);
 
 	spin_lock(&rxnet->peer_hash_lock);
@@ -417,6 +416,7 @@ static void __rxrpc_put_peer(struct rxrpc_peer *peer)
 	list_del_init(&peer->keepalive_link);
 	spin_unlock_bh(&rxnet->peer_hash_lock);
 
+	rxrpc_put_local(peer->local);
 	kfree_rcu(peer, rcu);
 }
 
@@ -453,6 +453,7 @@ void rxrpc_put_peer_locked(struct rxrpc_peer *peer)
 	if (n == 0) {
 		hash_del_rcu(&peer->hash_link);
 		list_del_init(&peer->keepalive_link);
+		rxrpc_put_local(peer->local);
 		kfree_rcu(peer, rcu);
 	}
 }
-- 
2.20.1


  parent reply	other threads:[~2019-10-26 13:16 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-26 13:14 [PATCH AUTOSEL 5.3 01/99] tools: bpf: Use !building_out_of_srctree to determine srctree Sasha Levin
2019-10-26 13:14 ` [PATCH AUTOSEL 5.3 05/99] rt2x00: initialize last_reset Sasha Levin
2019-10-26 13:14 ` [PATCH AUTOSEL 5.3 07/99] mac80211_hwsim: fix incorrect dev_alloc_name failure goto Sasha Levin
2019-10-26 13:14 ` [PATCH AUTOSEL 5.3 10/99] net: dsa: b53: Do not clear existing mirrored port mask Sasha Levin
2019-10-26 13:14 ` [PATCH AUTOSEL 5.3 11/99] net: stmmac: selftests: Check if filtering is available before running Sasha Levin
2019-10-26 13:14 ` [PATCH AUTOSEL 5.3 12/99] net: stmmac: gmac4+: Not all Unicast addresses may be available Sasha Levin
2019-10-26 13:14 ` [PATCH AUTOSEL 5.3 13/99] net: stmmac: selftests: Fix L2 Hash Filter test Sasha Levin
2019-10-26 13:14 ` [PATCH AUTOSEL 5.3 16/99] rxrpc: Fix call ref leak Sasha Levin
2019-10-26 13:14 ` [PATCH AUTOSEL 5.3 17/99] rxrpc: Fix trace-after-put looking at the put peer record Sasha Levin
2019-10-26 13:14 ` [PATCH AUTOSEL 5.3 18/99] rxrpc: Fix trace-after-put looking at the put connection record Sasha Levin
2019-10-26 13:14 ` [PATCH AUTOSEL 5.3 19/99] rxrpc: Fix trace-after-put looking at the put call record Sasha Levin
2019-10-26 13:14 ` Sasha Levin [this message]
2019-10-26 13:14 ` [PATCH AUTOSEL 5.3 21/99] nl80211: fix memory leak in nl80211_get_ftm_responder_stats Sasha Levin
2019-10-26 13:14 ` [PATCH AUTOSEL 5.3 22/99] cfg80211: fix a bunch of RCU issues in multi-bssid code Sasha Levin
2019-10-26 13:14 ` [PATCH AUTOSEL 5.3 23/99] mac80211: accept deauth frames in IBSS mode Sasha Levin
2019-10-26 13:14 ` [PATCH AUTOSEL 5.3 24/99] mac80211: fix scan when operating on DFS channels in ETSI domains Sasha Levin
2019-10-26 13:14 ` [PATCH AUTOSEL 5.3 25/99] llc: fix sk_buff leak in llc_sap_state_process() Sasha Levin
2019-10-26 13:14 ` [PATCH AUTOSEL 5.3 26/99] llc: fix sk_buff leak in llc_conn_service() Sasha Levin
2019-10-26 13:14 ` [PATCH AUTOSEL 5.3 27/99] llc: fix another potential sk_buff leak in llc_ui_sendmsg() Sasha Levin
2019-10-26 13:14 ` [PATCH AUTOSEL 5.3 28/99] llc: fix sk_buff refcounting in llc_conn_state_process() Sasha Levin
2019-10-26 13:14 ` [PATCH AUTOSEL 5.3 29/99] selftests/bpf: Set rp_filter in test_flow_dissector Sasha Levin
2019-10-26 13:14 ` [PATCH AUTOSEL 5.3 30/99] selftests/bpf: More compatible nc options in test_lwt_ip_encap Sasha Levin
2019-10-26 13:14 ` [PATCH AUTOSEL 5.3 31/99] net_sched: fix backward compatibility for TCA_KIND Sasha Levin
2019-10-26 13:14 ` [PATCH AUTOSEL 5.3 32/99] net_sched: fix backward compatibility for TCA_ACT_KIND Sasha Levin
2019-10-26 13:14 ` [PATCH AUTOSEL 5.3 33/99] NFC: pn533: fix use-after-free and memleaks Sasha Levin
2019-10-26 13:14 ` [PATCH AUTOSEL 5.3 34/99] ip6erspan: remove the incorrect mtu limit for ip6erspan Sasha Levin
2019-10-26 13:14 ` [PATCH AUTOSEL 5.3 35/99] iwlwifi: mvm: fix race in sync rx queue notification Sasha Levin
2019-10-26 13:14 ` [PATCH AUTOSEL 5.3 36/99] iwlwifi: dbg_ini: fix memory leak in alloc_sgtable Sasha Levin
2019-10-26 13:14 ` [PATCH AUTOSEL 5.3 37/99] iwlwifi: pcie: fix memory leaks in iwl_pcie_ctxt_info_gen3_init Sasha Levin
2019-10-26 13:14 ` [PATCH AUTOSEL 5.3 38/99] iwlwifi: exclude GEO SAR support for 3168 Sasha Levin
2019-10-26 13:15 ` [PATCH AUTOSEL 5.3 40/99] net: stmmac: fix length of PTP clock's name string Sasha Levin
2019-10-26 13:15 ` [PATCH AUTOSEL 5.3 41/99] net: stmmac: fix disabling flexible PPS output Sasha Levin
2019-10-26 13:15 ` [PATCH AUTOSEL 5.3 42/99] bonding: fix potential NULL deref in bond_update_slave_arr Sasha Levin
2019-10-26 13:15 ` [PATCH AUTOSEL 5.3 43/99] sctp: add chunks to sk_backlog when the newsk sk_socket is not set Sasha Levin
2019-10-26 13:15 ` [PATCH AUTOSEL 5.3 46/99] act_mirred: Fix mirred_init_module error handling Sasha Levin
2019-10-26 13:15 ` [PATCH AUTOSEL 5.3 47/99] net: usb: qmi_wwan: add Telit 0x1050 composition Sasha Levin
2019-10-26 13:15 ` [PATCH AUTOSEL 5.3 48/99] netns: fix NLM_F_ECHO mechanism for RTM_NEWNSID Sasha Levin
2019-10-26 13:15 ` [PATCH AUTOSEL 5.3 49/99] netfilter: conntrack: avoid possible false sharing Sasha Levin
2019-10-26 13:15 ` [PATCH AUTOSEL 5.3 50/99] tun: remove possible false sharing in tun_flow_update() Sasha Levin
2019-10-26 13:15 ` [PATCH AUTOSEL 5.3 51/99] net: avoid possible false sharing in sk_leave_memory_pressure() Sasha Levin
2019-10-26 13:15 ` [PATCH AUTOSEL 5.3 52/99] net: add {READ|WRITE}_ONCE() annotations on ->rskq_accept_head Sasha Levin
2019-10-26 13:15 ` [PATCH AUTOSEL 5.3 53/99] net/smc: fix SMCD link group creation with VLAN id Sasha Levin
2019-10-26 13:15 ` [PATCH AUTOSEL 5.3 54/99] net/smc: receive returns without data Sasha Levin
2019-10-26 13:15 ` [PATCH AUTOSEL 5.3 55/99] net/smc: receive pending data after RCV_SHUTDOWN Sasha Levin
2019-10-26 13:15 ` [PATCH AUTOSEL 5.3 57/99] vhost/test: stop device before reset Sasha Levin
2019-10-26 13:15 ` [PATCH AUTOSEL 5.3 58/99] net/ibmvnic: Fix EOI when running in XIVE mode Sasha Levin
2019-10-26 13:15 ` [PATCH AUTOSEL 5.3 59/99] netdevsim: Fix error handling in nsim_fib_init and nsim_fib_exit Sasha Levin
2019-10-26 13:15 ` [PATCH AUTOSEL 5.3 60/99] ath10k: fix latency issue for QCA988x Sasha Levin
2019-10-26 13:15 ` [PATCH AUTOSEL 5.3 69/99] net: aquantia: temperature retrieval fix Sasha Levin
2019-10-26 13:15 ` [PATCH AUTOSEL 5.3 70/99] net: aquantia: do not pass lro session with invalid tcp checksum Sasha Levin
2019-10-26 13:15 ` [PATCH AUTOSEL 5.3 71/99] net: aquantia: correctly handle macvlan and multicast coexistence Sasha Levin
2019-10-26 13:15 ` [PATCH AUTOSEL 5.3 78/99] net: i82596: fix dma_alloc_attr for sni_82596 Sasha Levin
2019-10-26 13:15 ` [PATCH AUTOSEL 5.3 79/99] net: bcmgenet: Fix RGMII_MODE_EN value for GENET v1/2/3 Sasha Levin
2019-10-26 13:15 ` [PATCH AUTOSEL 5.3 80/99] net: usb: sr9800: fix uninitialized local variable Sasha Levin
2019-10-26 13:15 ` [PATCH AUTOSEL 5.3 82/99] net: stmmac: disable/enable ptp_ref_clk in suspend/resume flow Sasha Levin
2019-10-26 13:15 ` [PATCH AUTOSEL 5.3 84/99] usb: hso: obey DMA rules in tiocmget Sasha Levin
2019-10-26 13:15 ` [PATCH AUTOSEL 5.3 85/99] dpaa2-eth: add irq for the dpmac connect/disconnect event Sasha Levin
2019-10-26 13:15 ` [PATCH AUTOSEL 5.3 86/99] net: stmmac: fix argument to stmmac_pcs_ctrl_ane() Sasha Levin
2019-10-26 13:15 ` [PATCH AUTOSEL 5.3 87/99] net: phy: micrel: Discern KSZ8051 and KSZ8795 PHYs Sasha Levin
2019-10-26 13:15 ` [PATCH AUTOSEL 5.3 88/99] net: phy: micrel: Update KSZ87xx PHY name Sasha Levin
2019-10-26 13:15 ` [PATCH AUTOSEL 5.3 90/99] net: bcmgenet: don't set phydev->link from MAC Sasha Levin
2019-10-26 13:15 ` [PATCH AUTOSEL 5.3 91/99] net: phy: bcm7xxx: define soft_reset for 40nm EPHY Sasha Levin
2019-10-26 13:15 ` [PATCH AUTOSEL 5.3 92/99] net: bcmgenet: reset 40nm EPHY on energy detect Sasha Levin
2019-10-26 13:15 ` [PATCH AUTOSEL 5.3 93/99] net: usb: lan78xx: Connect PHY before registering MAC Sasha Levin
2019-10-26 13:15 ` [PATCH AUTOSEL 5.3 98/99] net: hns3: fix mis-counting IRQ vector numbers issue Sasha Levin
2019-10-26 13:16 ` [PATCH AUTOSEL 5.3 99/99] net: aquantia: add an error handling in aq_nic_set_multicast_list Sasha Levin

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=20191026131600.2507-20-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=dhowells@redhat.com \
    --cc=linux-afs@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=syzbot+b9be979c55f2bea8ed30@syzkaller.appspotmail.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).