Skip to contentSkip to conversation

syncppp needs to pullup headers

RFT Stephen Hemminger 2 participants 2 messages Oct 3, 2003 – Oct 4, 2003

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

In 2.6.0-test6 wan syncppp driver claims to be a "new" protocol and handle shared skb's but it needs to make sure data is contiguous before overlaying headers. It is not a serious problem because the sync drivers never generate nonlinear skbuff's anyway.

Don't have hardware that uses this, so could someone please do a sanity test on this.

drivers/net/wan/syncppp.c +6 -5
diff -Nru a/drivers/net/wan/syncppp.c b/drivers/net/wan/syncppp.c
@@ -236,7 +236,7 @@
 		sp->ipkts++;
 	}
 
-	if (skb->len <= PPP_HEADER_LEN) {
+	if (!pskb_may_pull(skb, PPP_HEADER_LEN)) {
 		/* Too small packet, drop it. */
 		if (sp->pp_flags & PP_DEBUG)
 			printk (KERN_DEBUG "%s: input packet is too small, %d bytes\n",
@@ -473,7 +473,7 @@
 	u8 *p, opt[6];
 	u32 rmagic;
 
-	if (len < 4) {
+	if (!pskb_may_pull(skb, sizeof(struct lcp_header))) {
 		if (sp->pp_flags & PP_DEBUG)
 			printk (KERN_WARNING "%s: invalid lcp packet length: %d bytes\n",
 				dev->name, len);
@@ -707,7 +707,9 @@
 	struct cisco_packet *h;
 	struct net_device *dev = sp->pp_if;
 
-	if (skb->len != CISCO_PACKET_LEN && skb->len != CISCO_BIG_PACKET_LEN) {
+	if (!pskb_may_pull(skb, sizeof(struct cisco_packet))
+	    || (skb->len != CISCO_PACKET_LEN
+		&& skb->len != CISCO_BIG_PACKET_LEN)) {
 		if (sp->pp_flags & PP_DEBUG)
 			printk (KERN_WARNING "%s: invalid cisco packet length: %d bytes\n",
 				dev->name,  skb->len);
@@ -1211,8 +1213,7 @@
 	struct net_device *dev = sp->pp_if;
 	int len = skb->len;
 
-	if (len < 4) 
-	{
+	if (!pskb_may_pull(skb, sizeof(struct lcp_header))) {
 		if (sp->pp_flags & PP_DEBUG)
 			printk (KERN_WARNING "%s: invalid ipcp packet length: %d bytes\n",
 				dev->name,  len);
#1 lore raw
Quoted 4 lines · On Fri, 3 Oct 2003 11:43:47 -0700 Stephen Hemminger <[email protected]> wrote:

In 2.6.0-test6 wan syncppp driver claims to be a "new" protocol and handle shared skb's but it needs to make sure data is contiguous before overlaying headers. It is not a serious problem because the sync drivers never generate nonlinear skbuff's anyway.

This looks obvious enough and correct to me, applied.