netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Florian Westphal <fw@strlen.de>,
	Pablo Neira Ayuso <pablo@netfilter.org>,
	Sasha Levin <sashal@kernel.org>,
	netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
	netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 4.19 36/97] netfilter: nat: can't use dst_hold on noref dst
Date: Wed, 26 Dec 2018 17:34:56 -0500	[thread overview]
Message-ID: <20181226223557.149329-36-sashal@kernel.org> (raw)
In-Reply-To: <20181226223557.149329-1-sashal@kernel.org>

From: Florian Westphal <fw@strlen.de>

[ Upstream commit 542fbda0f08f1cbbc250f9e59f7537649651d0c8 ]

The dst entry might already have a zero refcount, waiting on rcu list
to be free'd.  Using dst_hold() transitions its reference count to 1, and
next dst release will try to free it again -- resulting in a double free:

  WARNING: CPU: 1 PID: 0 at include/net/dst.h:239 nf_xfrm_me_harder+0xe7/0x130 [nf_nat]
  RIP: 0010:nf_xfrm_me_harder+0xe7/0x130 [nf_nat]
  Code: 48 8b 5c 24 60 65 48 33 1c 25 28 00 00 00 75 53 48 83 c4 68 5b 5d 41 5c c3 85 c0 74 0d 8d 48 01 f0 0f b1 0a 74 86 85 c0 75 f3 <0f> 0b e9 7b ff ff ff 29 c6 31 d2 b9 20 00 48 00 4c 89 e7 e8 31 27
  Call Trace:
  nf_nat_ipv4_out+0x78/0x90 [nf_nat_ipv4]
  nf_hook_slow+0x36/0xd0
  ip_output+0x9f/0xd0
  ip_forward+0x328/0x440
  ip_rcv+0x8a/0xb0

Use dst_hold_safe instead and bail out if we cannot take a reference.

Fixes: a4c2fd7f7891 ("net: remove DST_NOCACHE flag")
Reported-by: Martin Zaharinov <micron10@gmail.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/netfilter/nf_nat_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/netfilter/nf_nat_core.c b/net/netfilter/nf_nat_core.c
index e2b196054dfc..2268b10a9dcf 100644
--- a/net/netfilter/nf_nat_core.c
+++ b/net/netfilter/nf_nat_core.c
@@ -117,7 +117,8 @@ int nf_xfrm_me_harder(struct net *net, struct sk_buff *skb, unsigned int family)
 	dst = skb_dst(skb);
 	if (dst->xfrm)
 		dst = ((struct xfrm_dst *)dst)->route;
-	dst_hold(dst);
+	if (!dst_hold_safe(dst))
+		return -EHOSTUNREACH;
 
 	if (sk && !net_eq(net, sock_net(sk)))
 		sk = NULL;
-- 
2.19.1

  parent reply	other threads:[~2018-12-26 22:34 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20181226223557.149329-1-sashal@kernel.org>
2018-12-26 22:34 ` [PATCH AUTOSEL 4.19 16/97] xfrm: Fix error return code in xfrm_output_one() Sasha Levin
2018-12-26 22:34 ` [PATCH AUTOSEL 4.19 17/97] xfrm: Fix bucket count reported to userspace Sasha Levin
2018-12-26 22:34 ` [PATCH AUTOSEL 4.19 18/97] xfrm: Fix NULL pointer dereference in xfrm_input when skb_dst_force clears the dst_entry Sasha Levin
2018-12-26 22:34 ` [PATCH AUTOSEL 4.19 19/97] ieee802154: hwsim: fix off-by-one in parse nested Sasha Levin
2018-12-26 22:34 ` [PATCH AUTOSEL 4.19 20/97] netfilter: nf_tables: fix suspicious RCU usage in nft_chain_stats_replace() Sasha Levin
2018-12-26 22:34 ` [PATCH AUTOSEL 4.19 21/97] netfilter: seqadj: re-load tcp header pointer after possible head reallocation Sasha Levin
2018-12-26 22:34 ` [PATCH AUTOSEL 4.19 26/97] ibmvnic: Convert reset work item mutex to spin lock Sasha Levin
2018-12-26 22:34 ` [PATCH AUTOSEL 4.19 27/97] ibmvnic: Fix non-atomic memory allocation in IRQ context Sasha Levin
2018-12-26 22:34 ` [PATCH AUTOSEL 4.19 28/97] nfp: flower: ensure TCP flags can be placed in IPv6 frame Sasha Levin
2018-12-26 22:34 ` [PATCH AUTOSEL 4.19 29/97] ieee802154: ca8210: fix possible u8 overflow in ca8210_rx_done Sasha Levin
2018-12-26 22:34 ` [PATCH AUTOSEL 4.19 32/97] i40e: fix mac filter delete when setting mac address Sasha Levin
2018-12-26 22:34 ` [PATCH AUTOSEL 4.19 33/97] USB: hso: Fix OOB memory access in hso_probe/hso_get_config_data Sasha Levin
2018-12-26 22:34 ` [PATCH AUTOSEL 4.19 34/97] ixgbe: Fix race when the VF driver does a reset Sasha Levin
2018-12-26 22:34 ` [PATCH AUTOSEL 4.19 35/97] netfilter: ipset: do not call ipset_nest_end after nla_nest_cancel Sasha Levin
2018-12-26 22:34 ` Sasha Levin [this message]
2018-12-26 22:34 ` [PATCH AUTOSEL 4.19 37/97] netfilter: nf_conncount: use rb_link_node_rcu() instead of rb_link_node() Sasha Levin
2018-12-26 22:34 ` [PATCH AUTOSEL 4.19 38/97] bnx2x: Clear fip MAC when fcoe offload support is disabled Sasha Levin
2018-12-26 22:34 ` [PATCH AUTOSEL 4.19 39/97] bnx2x: Remove configured vlans as part of unload sequence Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 40/97] bnx2x: Send update-svid ramrod with retry/poll flags enabled Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 43/97] net/mlx5e: RX, Verify MPWQE stride size is in range Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 44/97] net/mlx5e: Cancel DIM work on close SQ Sasha Levin
     [not found] ` <20181226223557.149329-1-sashal-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
2018-12-26 22:35   ` [PATCH AUTOSEL 4.19 45/97] mt76: fix potential NULL pointer dereference in mt76_stop_tx_queues Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 47/97] qed: Fix command number mismatch between driver and the mfw Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 48/97] drivers: net: xgene: Remove unnecessary forward declarations Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 49/97] net/tls: Init routines in create_ctx Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 50/97] w90p910_ether: remove incorrect __init annotation Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 51/97] qmi_wwan: Added support for Fibocom NL668 series Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 52/97] qmi_wwan: Added support for Telit LN940 series Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 53/97] net: clear skb->tstamp in forwarding paths Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 54/97] net: hns: Incorrect offset address used for some registers Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 55/97] net: hns: All ports can not work when insmod hns ko after rmmod Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 56/97] net: hns: Some registers use wrong address according to the datasheet Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 57/97] net: hns: Fixed bug that netdev was opened twice Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 58/97] net: hns: Clean rx fbd when ae stopped Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 59/97] net: hns: Free irq when exit from abnormal branch Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 60/97] net: hns: Avoid net reset caused by pause frames storm Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 61/97] net: hns: Fix ntuple-filters status error Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 62/97] net: hns: Add mac pcs config when enable|disable mac Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 63/97] net: hns: Fix ping failed when use net bridge and send multicast Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 64/97] net: mvneta: fix operation for 64K PAGE_SIZE Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 65/97] mac80211: fix a kernel panic when TXing after TXQ teardown Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 66/97] SUNRPC: Fix a race with XPRT_CONNECTING Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 67/97] mlxsw: core: Increase timeout during firmware flash process Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 68/97] net: mvpp2: 10G modes aren't supported on all ports Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 70/97] qed: Fix an error code qed_ll2_start_xmit() Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 71/97] net: stmmac: Fix an error code in probe() Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 72/97] net: macb: restart tx after tx used bit read Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 73/97] net: macb: fix random memory corruption on RX with 64-bit DMA Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 74/97] net: macb: fix dropped RX frames due to a race Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 75/97] net: macb: add missing barriers when reading descriptors Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 76/97] lan743x: Expand phy search for LAN7431 Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 77/97] lan78xx: Resolve issue with changing MAC address Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 78/97] xen/netfront: tolerate frags with no data Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 79/97] vxge: ensure data0 is initialized in when fetching firmware version information Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 80/97] nl80211: fix memory leak if validate_pae_over_nl80211() fails Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 81/97] mac80211: free skb fraglist before freeing the skb Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 84/97] net/mlx5e: RX, Fix wrong early return in receive queue poll Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 85/97] net/mlx5: Typo fix in del_sw_hw_rule Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 86/97] net/mlx5e: Remove the false indication of software timestamping support Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 88/97] lan743x: Remove MAC Reset from initialization Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 89/97] net: mvpp2: fix the phylink mode validation Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 90/97] mscc: Configured MAC entries should be locked Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 93/97] net: netxen: fix a missing check and an uninitialized use Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 94/97] qmi_wwan: Add support for Fibocom NL678 series Sasha Levin
2018-12-26 22:35 ` [PATCH AUTOSEL 4.19 95/97] qmi_wwan: Fix qmap header retrieval in qmimux_rx_fixup 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=20181226223557.149329-36-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=coreteam@netfilter.org \
    --cc=fw@strlen.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    --cc=stable@vger.kernel.org \
    /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).