[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87wq2mym03.fsf_-_@x220.int.ebiederm.org>
Date: Thu, 12 Mar 2015 15:54:52 -0500
From: ebiederm@...ssion.com (Eric W. Biederman)
To: Robert Shearman <rshearma@...cade.com>
Cc: "davem\@davemloft.net" <davem@...emloft.net>,
"netdev\@vger.kernel.org" <netdev@...r.kernel.org>
Subject: [PATCH net-next ] mpls: In mpls_egress verify the packet length.
Robert 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.
Reported-by: Robert Shearman <rshearma@...cade.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@...ssion.com>
---
net/mpls/af_mpls.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
index 0ad8f7141be2..d5882c5c176b 100644
--- a/net/mpls/af_mpls.c
+++ b/net/mpls/af_mpls.c
@@ -92,17 +92,25 @@ static bool mpls_egress(struct mpls_route *rt, struct sk_buff *skb,
* The strange cases if we choose to support them will require
* manual configuration.
*/
- struct iphdr *hdr4 = ip_hdr(skb);
+ struct iphdr *hdr4;
bool success = true;
- if (hdr4->version == 4) {
+ /* If the packet is empty we can't do anything */
+ if (!pskb_may_pull(skb, 1))
+ return false;
+
+ /* Use ip_hdr to find the ip protocol version */
+ hdr4 = ip_hdr(skb);
+ if ((hdr4->version == 4) &&
+ pskb_may_pull(skb, sizeof(struct iphdr))) {
skb->protocol = htons(ETH_P_IP);
csum_replace2(&hdr4->check,
htons(hdr4->ttl << 8),
htons(dec.ttl << 8));
hdr4->ttl = dec.ttl;
}
- else if (hdr4->version == 6) {
+ else if ((hdr4->version == 6) &&
+ pskb_may_pull(skb, sizeof(struct ipv6hdr))) {
struct ipv6hdr *hdr6 = ipv6_hdr(skb);
skb->protocol = htons(ETH_P_IPV6);
hdr6->hop_limit = dec.ttl;
--
2.2.1
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists