Skip to contentSkip to conversation

pppoe: Add missing sock_put() in pppoe_rcv()

PATCH In review Jarek Poplawski 3 participants 4 messages Oct 30, 2008 – Oct 31, 2008

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

PATCH 1/1 pppoe: Add missing sock_put() in pppoe_rcv()

pppoe: Add missing sock_put() in pppoe_rcv()

Add missing sock_put() in pppoe_rcv() (introduced by commit 392fdb0e35055b96faa9c1cd6ab537805337cdce).

---
[needed for stables 2.6.26 and later]

 drivers/net/pppoe.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/net/pppoe.c +3 -1
index fc6f4b8..c074276 100644
@@ -403,8 +403,10 @@ static int pppoe_rcv(struct sk_buff *skb,
 	if (!po)
 		goto drop;
 
-	if (pskb_trim_rcsum(skb, len))
+	if (pskb_trim_rcsum(skb, len)) {
+		sock_put(sk_pppox(po));
 		goto drop;
+	}
 
 	return sk_receive_skb(sk_pppox(po), skb, 0);
 
#1 lore raw
Quoted 6 lines · Jarek Poplawski

pppoe: Add missing sock_put() in pppoe_rcv()

Add missing sock_put() in pppoe_rcv() (introduced by commit 392fdb0e35055b96faa9c1cd6ab537805337cdce).

Good cath!

Thanks,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#2 lore raw
In reply to Jarek Poplawski
Quoted 6 lines · Jarek Poplawski
drivers/net/pppoe.c +0 -0
index fc6f4b8..c074276 100644

drivers/net/pppoe.c static int pppoe_rcv(struct sk_buff *skb, · line 409

Quoted 8 lines
drivers/net/pppoe.c +3 -1
@@ -403,8 +403,10 @@ static int pppoe_rcv(struct sk_buff *skb,
 	if (!po)
 		goto drop;
 
-	if (pskb_trim_rcsum(skb, len))
+	if (pskb_trim_rcsum(skb, len)) {
+		sock_put(sk_pppox(po));
 		goto drop;
+	}

Actually we might be better off moving the trim before the get_item call.

Cheers,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
maintainer
#3 lore raw

From: Herbert Xu <[email protected]>
Date: Fri, 31 Oct 2008 12:29:20 +0800

Quoted 10 lines · Jarek Poplawski
Quoted 9 lines
drivers/net/pppoe.c +0 -0
index fc6f4b8..c074276 100644
@@ -403,8 +403,10 @@ static int pppoe_rcv(struct sk_buff *skb,
 	if (!po)
 		goto drop;
 
Quoted 8 lines

drivers/net/pppoe.c static int pppoe_rcv(struct sk_buff *skb, · line 409

Quoted 5 lines
drivers/net/pppoe.c +3 -1
-	if (pskb_trim_rcsum(skb, len))
+	if (pskb_trim_rcsum(skb, len)) {
+		sock_put(sk_pppox(po));
 		goto drop;
+	}

Actually we might be better off moving the trim before the get_item call.

That sounds like a good idea, I'll commit the following:

commit fb764c5b742fdab5615f4a1bac9f43df73599ce3

Author: David S. Miller <[email protected]>
Date:   Thu Oct 30 23:11:44 2008 -0700

pppoe: Fix socket leak.

Move SKB trim before we lookup the socket so we don't have to put it on failure.

Based upon an initial patch by Jarek Poplawski and suggestions from Herbert Xu.

drivers/net/pppoe.c +3 -3
index fc6f4b8..b646e92 100644
@@ -399,11 +399,11 @@ static int pppoe_rcv(struct sk_buff *skb,
 	if (skb->len < len)
 		goto drop;
 
-	po = get_item(ph->sid, eth_hdr(skb)->h_source, dev->ifindex);
-	if (!po)
+	if (pskb_trim_rcsum(skb, len))
 		goto drop;
 
-	if (pskb_trim_rcsum(skb, len))
+	po = get_item(ph->sid, eth_hdr(skb)->h_source, dev->ifindex);
+	if (!po)
 		goto drop;
 
 	return sk_receive_skb(sk_pppox(po), skb, 0);