diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2015-03-12 19:22:59 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-03-12 23:05:04 -0400 |
commit | 76fecd8275be6de76513430e7526825944ab932f (patch) | |
tree | c04917753aa8f8cd07d54140c9580af45c7f5dd8 /net/mpls | |
parent | 2c29b2354a06f42493ddd2a5eb65962981e666ed (diff) |
mpls: In mpls_egress verify the packet length.
Reobert Shearman noticed that mpls_egress is failing to verify that
the bytes to be examined are in fact present in the packet before
mpls_egress reads those bytes.
As suggested by David Miller reduce this to a single pskb_may_pull
call so that we don't do unnecessary work in the fast path.
Reported-by: Robert Shearman <rshearma@brocade.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/mpls')
-rw-r--r-- | net/mpls/af_mpls.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c index 0ad8f7141be2..db8a2ea6d4de 100644 --- a/net/mpls/af_mpls.c +++ b/net/mpls/af_mpls.c | |||
@@ -92,9 +92,24 @@ static bool mpls_egress(struct mpls_route *rt, struct sk_buff *skb, | |||
92 | * The strange cases if we choose to support them will require | 92 | * The strange cases if we choose to support them will require |
93 | * manual configuration. | 93 | * manual configuration. |
94 | */ | 94 | */ |
95 | struct iphdr *hdr4 = ip_hdr(skb); | 95 | struct iphdr *hdr4; |
96 | bool success = true; | 96 | bool success = true; |
97 | 97 | ||
98 | /* The IPv4 code below accesses through the IPv4 header | ||
99 | * checksum, which is 12 bytes into the packet. | ||
100 | * The IPv6 code below accesses through the IPv6 hop limit | ||
101 | * which is 8 bytes into the packet. | ||
102 | * | ||
103 | * For all supported cases there should always be at least 12 | ||
104 | * bytes of packet data present. The IPv4 header is 20 bytes | ||
105 | * without options and the IPv6 header is always 40 bytes | ||
106 | * long. | ||
107 | */ | ||
108 | if (!pskb_may_pull(skb, 12)) | ||
109 | return false; | ||
110 | |||
111 | /* Use ip_hdr to find the ip protocol version */ | ||
112 | hdr4 = ip_hdr(skb); | ||
98 | if (hdr4->version == 4) { | 113 | if (hdr4->version == 4) { |
99 | skb->protocol = htons(ETH_P_IP); | 114 | skb->protocol = htons(ETH_P_IP); |
100 | csum_replace2(&hdr4->check, | 115 | csum_replace2(&hdr4->check, |