]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.4/sit-check-if-ipv6-enabled-before-calling-ip6_err_gen_icmpv6_unreach.patch
Linux 3.18.137
[thirdparty/kernel/stable-queue.git] / queue-4.4 / sit-check-if-ipv6-enabled-before-calling-ip6_err_gen_icmpv6_unreach.patch
1 From foo@baz Sun Feb 24 14:41:29 CET 2019
2 From: Hangbin Liu <liuhangbin@gmail.com>
3 Date: Thu, 7 Feb 2019 18:36:11 +0800
4 Subject: sit: check if IPv6 enabled before calling ip6_err_gen_icmpv6_unreach()
5
6 From: Hangbin Liu <liuhangbin@gmail.com>
7
8 [ Upstream commit 173656accaf583698bac3f9e269884ba60d51ef4 ]
9
10 If we disabled IPv6 from the kernel command line (ipv6.disable=1), we should
11 not call ip6_err_gen_icmpv6_unreach(). This:
12
13 ip link add sit1 type sit local 192.0.2.1 remote 192.0.2.2 ttl 1
14 ip link set sit1 up
15 ip addr add 198.51.100.1/24 dev sit1
16 ping 198.51.100.2
17
18 if IPv6 is disabled at boot time, will crash the kernel.
19
20 v2: there's no need to use in6_dev_get(), use __in6_dev_get() instead,
21 as we only need to check that idev exists and we are under
22 rcu_read_lock() (from netif_receive_skb_internal()).
23
24 Reported-by: Jianlin Shi <jishi@redhat.com>
25 Fixes: ca15a078bd90 ("sit: generate icmpv6 error when receiving icmpv4 error")
26 Cc: Oussama Ghorbel <ghorbel@pivasoftware.com>
27 Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
28 Reviewed-by: Stefano Brivio <sbrivio@redhat.com>
29 Signed-off-by: David S. Miller <davem@davemloft.net>
30 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
31 ---
32 net/ipv6/sit.c | 2 +-
33 1 file changed, 1 insertion(+), 1 deletion(-)
34
35 --- a/net/ipv6/sit.c
36 +++ b/net/ipv6/sit.c
37 @@ -577,7 +577,7 @@ static int ipip6_err(struct sk_buff *skb
38 goto out;
39
40 err = 0;
41 - if (!ipip6_err_gen_icmpv6_unreach(skb))
42 + if (__in6_dev_get(skb->dev) && !ipip6_err_gen_icmpv6_unreach(skb))
43 goto out;
44
45 if (t->parms.iph.ttl == 0 && type == ICMP_TIME_EXCEEDED)