]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.14.97/net-fix-usage-of-pskb_trim_rcsum.patch
Linux 4.14.97
[thirdparty/kernel/stable-queue.git] / releases / 4.14.97 / net-fix-usage-of-pskb_trim_rcsum.patch
1 From foo@baz Sat Jan 26 10:34:35 CET 2019
2 From: Ross Lagerwall <ross.lagerwall@citrix.com>
3 Date: Thu, 17 Jan 2019 15:34:38 +0000
4 Subject: net: Fix usage of pskb_trim_rcsum
5
6 From: Ross Lagerwall <ross.lagerwall@citrix.com>
7
8 [ Upstream commit 6c57f0458022298e4da1729c67bd33ce41c14e7a ]
9
10 In certain cases, pskb_trim_rcsum() may change skb pointers.
11 Reinitialize header pointers afterwards to avoid potential
12 use-after-frees. Add a note in the documentation of
13 pskb_trim_rcsum(). Found by KASAN.
14
15 Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
16 Signed-off-by: David S. Miller <davem@davemloft.net>
17 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
18 ---
19 drivers/net/ppp/pppoe.c | 1 +
20 include/linux/skbuff.h | 1 +
21 net/bridge/br_netfilter_ipv6.c | 1 +
22 net/bridge/netfilter/nft_reject_bridge.c | 1 +
23 net/ipv4/ip_input.c | 1 +
24 5 files changed, 5 insertions(+)
25
26 --- a/drivers/net/ppp/pppoe.c
27 +++ b/drivers/net/ppp/pppoe.c
28 @@ -445,6 +445,7 @@ static int pppoe_rcv(struct sk_buff *skb
29 if (pskb_trim_rcsum(skb, len))
30 goto drop;
31
32 + ph = pppoe_hdr(skb);
33 pn = pppoe_pernet(dev_net(dev));
34
35 /* Note that get_item does a sock_hold(), so sk_pppox(po)
36 --- a/include/linux/skbuff.h
37 +++ b/include/linux/skbuff.h
38 @@ -3163,6 +3163,7 @@ int pskb_trim_rcsum_slow(struct sk_buff
39 *
40 * This is exactly the same as pskb_trim except that it ensures the
41 * checksum of received packets are still valid after the operation.
42 + * It can change skb pointers.
43 */
44
45 static inline int pskb_trim_rcsum(struct sk_buff *skb, unsigned int len)
46 --- a/net/bridge/br_netfilter_ipv6.c
47 +++ b/net/bridge/br_netfilter_ipv6.c
48 @@ -131,6 +131,7 @@ int br_validate_ipv6(struct net *net, st
49 IPSTATS_MIB_INDISCARDS);
50 goto drop;
51 }
52 + hdr = ipv6_hdr(skb);
53 }
54 if (hdr->nexthdr == NEXTHDR_HOP && br_nf_check_hbh_len(skb))
55 goto drop;
56 --- a/net/bridge/netfilter/nft_reject_bridge.c
57 +++ b/net/bridge/netfilter/nft_reject_bridge.c
58 @@ -230,6 +230,7 @@ static bool reject6_br_csum_ok(struct sk
59 pskb_trim_rcsum(skb, ntohs(ip6h->payload_len) + sizeof(*ip6h)))
60 return false;
61
62 + ip6h = ipv6_hdr(skb);
63 thoff = ipv6_skip_exthdr(skb, ((u8*)(ip6h+1) - skb->data), &proto, &fo);
64 if (thoff < 0 || thoff >= skb->len || (fo & htons(~0x7)) != 0)
65 return false;
66 --- a/net/ipv4/ip_input.c
67 +++ b/net/ipv4/ip_input.c
68 @@ -481,6 +481,7 @@ int ip_rcv(struct sk_buff *skb, struct n
69 goto drop;
70 }
71
72 + iph = ip_hdr(skb);
73 skb->transport_header = skb->network_header + iph->ihl*4;
74
75 /* Remove any debris in the socket control block */