Skip to contentSkip to conversation

cls_rsvp: add sanity check for the packet length

PATCH Applied Changli Gao 2 participants 2 messages Aug 4, 2010 – Aug 5, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 3/4 cls_rsvp: add sanity check for the packet length

The packet length should be checked before the packet data is dereferenced.

---
v2: use pskb_network_may_pull()

 net/sched/cls_rsvp.h |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
net/sched/cls_rsvp.h +10 -2
index dd9414e..425a179 100644
@@ -143,9 +143,17 @@ static int rsvp_classify(struct sk_buff *skb, struct tcf_proto *tp,
 	u8 tunnelid = 0;
 	u8 *xprt;
 #if RSVP_DST_LEN == 4
-	struct ipv6hdr *nhptr = ipv6_hdr(skb);
+	struct ipv6hdr *nhptr;
+
+	if (!pskb_network_may_pull(skb, sizeof(*nhptr)))
+		return -1;
+	nhptr = ipv6_hdr(skb);
 #else
-	struct iphdr *nhptr = ip_hdr(skb);
+	struct iphdr *nhptr;
+
+	if (!pskb_network_may_pull(skb, sizeof(*nhptr)))
+		return -1;
+	nhptr = ip_hdr(skb);
 #endif
 
 restart: