Florian Westphal
b0e56e3c56
netfilter: nat: can't use dst_hold on noref dst
...
[ 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>
2019-01-13 10:00:58 +01:00
..
2018-10-03 17:00:47 -07:00
2018-11-21 09:24:04 +01:00
2017-11-02 11:10:55 +01:00
2018-07-22 14:28:44 +02:00
2017-11-02 11:10:55 +01:00
2018-07-22 14:28:43 +02:00
2019-01-09 17:14:43 +01:00
2018-12-13 09:18:46 +01:00
2018-11-04 14:52:39 +01:00
2018-11-04 14:52:48 +01:00
2018-09-05 09:26:27 +02:00
2018-12-01 09:42:52 +01:00
2018-12-05 19:41:27 +01:00
2019-01-09 17:14:46 +01:00
2018-09-19 22:43:43 +02:00
2018-10-18 09:16:21 +02:00
2018-02-25 11:07:52 +01:00
2018-07-22 14:28:49 +02:00
2018-08-06 16:20:48 +02:00
2017-06-16 11:48:40 -04:00
2017-08-22 13:40:23 -07:00
2019-01-09 17:14:43 +01:00
2018-04-29 11:33:13 +02:00
2019-01-09 17:14:44 +01:00
2019-01-09 17:14:43 +01:00
2017-11-02 11:10:55 +01:00
2018-03-31 18:10:41 +02:00
2018-06-11 22:49:19 +02:00
2018-06-16 09:45:14 +02:00
2018-11-04 14:52:43 +01:00
2017-07-04 22:35:16 +01:00
2018-12-01 09:42:51 +01:00
2018-12-21 14:13:10 +01:00
2018-09-09 19:55:52 +02:00
2018-02-22 15:42:28 +01:00
2017-10-21 01:56:38 +01:00
2019-01-13 10:00:58 +01:00
2018-10-18 09:16:18 +02:00
2018-08-09 12:16:38 +02:00
2019-01-09 17:14:44 +01:00
2018-09-29 03:06:01 -07:00
2018-07-22 14:28:49 +02:00
2018-11-04 14:52:50 +01:00
2019-01-09 17:14:44 +01:00
2017-11-02 11:10:55 +01:00
2017-11-01 12:19:03 +09:00
2018-08-24 13:09:13 +02:00
2018-10-13 09:27:29 +02:00
2018-05-16 10:10:26 +02:00
2018-11-04 14:52:46 +01:00
2018-12-17 09:28:46 +01:00
2019-01-09 17:14:44 +01:00
2019-01-09 17:14:46 +01:00
2018-07-22 14:28:47 +02:00
2019-01-09 17:14:46 +01:00
2017-08-07 14:48:48 -07:00
2019-01-09 17:14:46 +01:00
2018-12-05 19:41:11 +01:00
2017-11-02 10:04:46 -07:00
2019-01-09 17:14:45 +01:00
2017-11-02 11:10:55 +01:00
2018-11-04 14:52:40 +01:00
2017-11-02 11:10:55 +01:00
2019-01-13 10:00:57 +01:00
2019-01-09 17:14:46 +01:00
2017-09-04 13:25:20 +02:00
2017-11-02 11:10:55 +01:00
2018-11-04 14:52:49 +01:00