]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: Fix usage of pskb_trim_rcsum
authorRoss Lagerwall <ross.lagerwall@citrix.com>
Thu, 17 Jan 2019 15:34:38 +0000 (15:34 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 31 Jan 2019 07:12:33 +0000 (08:12 +0100)
[ Upstream commit 6c57f0458022298e4da1729c67bd33ce41c14e7a ]

In certain cases, pskb_trim_rcsum() may change skb pointers.
Reinitialize header pointers afterwards to avoid potential
use-after-frees. Add a note in the documentation of
pskb_trim_rcsum(). Found by KASAN.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ppp/pppoe.c
include/linux/skbuff.h
net/bridge/br_netfilter_ipv6.c
net/bridge/netfilter/nft_reject_bridge.c
net/ipv4/ip_input.c

index fa2c7bd638be945121f1ceba16c35be2b7bd70d9..8c93ed5c976324ced62c9ee4dadecdf04001d049 100644 (file)
@@ -442,6 +442,7 @@ static int pppoe_rcv(struct sk_buff *skb, struct net_device *dev,
        if (pskb_trim_rcsum(skb, len))
                goto drop;
 
+       ph = pppoe_hdr(skb);
        pn = pppoe_pernet(dev_net(dev));
 
        /* Note that get_item does a sock_hold(), so sk_pppox(po)
index e90fe6b83e00ce4dff5f4c551d2ec6d2cd0547e6..ed329a39d62178b6a95cf80de51b630667f0324f 100644 (file)
@@ -2962,6 +2962,7 @@ int pskb_trim_rcsum_slow(struct sk_buff *skb, unsigned int len);
  *
  *     This is exactly the same as pskb_trim except that it ensures the
  *     checksum of received packets are still valid after the operation.
+ *     It can change skb pointers.
  */
 
 static inline int pskb_trim_rcsum(struct sk_buff *skb, unsigned int len)
index 5989661c659f52e0ee352e8af8aba876e83290b4..a1b57cb07f1e6de24c5e921865bcb500394f9125 100644 (file)
@@ -131,6 +131,7 @@ int br_validate_ipv6(struct net *net, struct sk_buff *skb)
                                        IPSTATS_MIB_INDISCARDS);
                        goto drop;
                }
+               hdr = ipv6_hdr(skb);
        }
        if (hdr->nexthdr == NEXTHDR_HOP && br_nf_check_hbh_len(skb))
                goto drop;
index 4b3df6b0e3b93cc47531950a9b4c8e6c9b5d1c13..d94aaf7c76854a3a0da9076fb994b20f4489c0b4 100644 (file)
@@ -236,6 +236,7 @@ static bool reject6_br_csum_ok(struct sk_buff *skb, int hook)
            pskb_trim_rcsum(skb, ntohs(ip6h->payload_len) + sizeof(*ip6h)))
                return false;
 
+       ip6h = ipv6_hdr(skb);
        thoff = ipv6_skip_exthdr(skb, ((u8*)(ip6h+1) - skb->data), &proto, &fo);
        if (thoff < 0 || thoff >= skb->len || (fo & htons(~0x7)) != 0)
                return false;
index d6feabb0351607f282e1f78f159c0ccb88bcec96..bcadca26523b378095a5f097170b66fe2e6c6829 100644 (file)
@@ -475,6 +475,7 @@ int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt,
                goto drop;
        }
 
+       iph = ip_hdr(skb);
        skb->transport_header = skb->network_header + iph->ihl*4;
 
        /* Remove any debris in the socket control block */