Advertise PPPoE MTU / avoid memory leak.
Subsystems (2)
PATCH 1/1 Advertise PPPoE MTU / avoid memory leak.
PPPoE must advertise the underlying device's MTU via the ppp channel descriptor structure, as multilink functionality depends on it.
__pppoe_xmit must free any skb it allocates if there is an error submitting the skb downstream.
--- drivers/net/pppoe.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/net/pppoe.c +4 -1
@@ -600,6 +600,7 @@ static int pppoe_connect(struct socket * po->chan.hdrlen = (sizeof (struct pppoe_hdr ) + dev->hard_header_len); + po->chan.mtu = dev->mtu -sizeof (struct pppoe_hdr ); po->chan.private = sk; po->chan.ops = &pppoe_chan_ops;
@@ -831,7 +832,7 @@ static int __pppoe_xmit(struct sock *sk,struct pppoe_hdr *ph;int headroom =skb_headroom (skb);int data_len = skb->len; -struct sk_buff *skb2; +struct sk_buff *skb2 =NULL ;if (sock_flag (sk,SOCK_DEAD ) || !(sk->sk_state &PPPOX_CONNECTED )) goto abort;
@@ -887,6 +888,8 @@ static int __pppoe_xmit(struct sock *sk,return 1 ; abort: +if (skb2) +kfree_skb (skb2);return 0 ; }
Signature · 1 line
1.4.1.1
David Miller
maintainerFrom: [email protected]
Date: Sat, 23 Sep 2006 12:30:23 -0500
Quoted 2 lines
__pppoe_xmitmust free any skb it allocates if there is an error submitting the skb downstream.
This isn't right, dev_queue_xmit() can return -ENETDOWN and still free the SKB, so your change will cause the SKB to be freed up twice in that case, from dev_queue_xmit():
rc = -ENETDOWN; rcu_read_unlock_bh();
out_kfree_skb:
kfree_skb(skb); return rc;
dev_queue_xmit() is basically expected to consume the packet, error or not.
What case of calling dev_queue_xmit() did you discover that did not kfree the SKB on error? We should fix that. On a quick scan on the entire dev_queue_xmit() implmentation, I cannot find such a case.
Quoted 17 lines · David Miller
From: [email protected]
Date: Sat, 23 Sep 2006 12:30:23 -0500Quoted 2 lines
__pppoe_xmitmust free any skb it allocates if there is an error submitting the skb downstream.This isn't right,
dev_queue_xmit()can return-ENETDOWNand still free the SKB, so your change will cause the SKB to be freed up twice in that case, fromdev_queue_xmit():rc = -ENETDOWN; rcu_read_unlock_bh();
out_kfree_skb:kfree_skb(skb); return rc;
Quoted 7 lines
dev_queue_xmit()is basically expected to consume the packet, error or not.What case of calling
dev_queue_xmit()did you discover that did not kfree the SKB on error? We should fix that. On a quick scan on the entiredev_queue_xmit()implmentation, I cannot find such a case.
I think the call path via dev->hard_start_xmit, if it fails, may result in an skb not being freed. This appears to be the case with the e100.c driver. The qdisc_restart path to dev->hard_start_xmit also appears susceptible to this. It appears that not all devices agree as to who should clean-up an skb on error.
Signature · 1 line
Michal Ostrowski <[email protected]>
David Miller
maintainerFrom: Michal Ostrowski <[email protected]>
Date: Sun, 24 Sep 2006 07:29:25 -0500
Quoted 5 lines
I think the call path via
dev->hard_start_xmit, if it fails, may result in an skb not being freed. This appears to be the case with thee100.cdriver. Theqdisc_restartpath todev->hard_start_xmitalso appears susceptible to this. It appears that not all devices agree as to who should clean-up an skb on error.
There is a well defined policy about who frees the SKB or has ownership of it based upon dev->hard_start_xmit() return values.
Any driver deviating from this set of rules should simply be audited and fixed, as needed.
But, no matter, your change is buggy and we can't apply your patch (even if it does fix a leak in some legitimate case) because it introduces an obvious double-free bug.
Quoted 12 lines · David Miller
From: Michal Ostrowski <[email protected]>
Date: Sun, 24 Sep 2006 07:29:25 -0500Quoted 5 lines
I think the call path via
dev->hard_start_xmit, if it fails, may result in an skb not being freed. This appears to be the case with thee100.cdriver. Theqdisc_restartpath todev->hard_start_xmitalso appears susceptible to this. It appears that not all devices agree as to who should clean-up an skb on error.There is a well defined policy about who frees the SKB or has ownership of it based upon
dev->hard_start_xmit()return values.
Quoted 7 lines
Any driver deviating from this set of rules should simply be audited and fixed, as needed.
But, no matter, your change is buggy and we can't apply your patch (even if it does fix a leak in some legitimate case) because it introduces an obvious double-free bug.
Yup. I'll resubmit a fixed one.
Signature · 1 line
Michal Ostrowski <[email protected]>
Speaking of PPPoE and MTU, does Linux support recently-published RFC 4638:
Accommodating a Maximum Transit Unit/Maximum Receive Unit (MTU/MRU)
Greater Than 1492 in the
Point-to-Point Protocol over Ethernet (PPPoE)
Quoted 42 lines · On Sat, 23 Sep 2006, [email protected] wrote:
PPPoE must advertise the underlying device's MTU via the ppp channel descriptor structure, as multilink functionality depends on it.
__pppoe_xmitmust free any skb it allocates if there is an error submitting the skb downstream.Signed-off-by Michal Ostrowski <[email protected]>---
drivers/net/pppoe.c| 5 ++++-1 files changed, 4 insertions(+), 1 deletions(-)drivers/net/pppoe.c +2
-1@@ -600,6 +600,7 @@ static int pppoe_connect(struct socket * po->chan.hdrlen = (sizeof (struct pppoe_hdr ) + dev->hard_header_len); + po->chan.mtu = dev->mtu -sizeof (struct pppoe_hdr ); po->chan.private = sk; po->chan.ops = &pppoe_chan_ops;@@ -831,7 +832,7 @@ static int __pppoe_xmit(struct sock *sk,struct pppoe_hdr *ph;int headroom =skb_headroom (skb);int data_len = skb->len; -struct sk_buff *skb2; +struct sk_buff *skb2 =NULL ;if (sock_flag (sk,SOCK_DEAD ) || !(sk->sk_state &PPPOX_CONNECTED )) goto abort;@@ -887,6 +888,8 @@ static int __pppoe_xmit(struct sock *sk,return 1 ;abort:
drivers/net/pppoe.c +2
-0+if (skb2) +kfree_skb (skb2);return 0; }
Signature · 3 lines
Pekka Savola "You each name yourselves king, yet the Netcore Oy kingdom bleeds." Systems. Networks. Security. -- George R.R. Martin: A Clash of Kings
This is not currently supported.
Looking at the RFC, this is an issue that must be solved in the pppoe plugin that performs the PPPoE negotiation/discovery. The kernel code that runs the regular session traffic should be able to adjust (with minimal or no changes) as it does not depend on a hardcoded MTU.
Signature · 1 line
Michal Ostrowski <[email protected]>
Quoted 51 lines · Pekka Savola
Speaking of PPPoE and MTU, does Linux support recently-published RFC 4638:
Accommodating a Maximum Transit Unit/Maximum Receive Unit (MTU/MRU)
Greater Than 1492 in the
Point-to-Point Protocol over Ethernet (PPPoE)Quoted 42 lines · On Sat, 23 Sep 2006, [email protected] wrote:
PPPoE must advertise the underlying device's MTU via the ppp channel descriptor structure, as multilink functionality depends on it.
__pppoe_xmitmust free any skb it allocates if there is an error submitting the skb downstream.Signed-off-by Michal Ostrowski <[email protected]>---
drivers/net/pppoe.c| 5 ++++-1 files changed, 4 insertions(+), 1 deletions(-)drivers/net/pppoe.c +2
-1@@ -600,6 +600,7 @@ static int pppoe_connect(struct socket * po->chan.hdrlen = (sizeof (struct pppoe_hdr ) + dev->hard_header_len); + po->chan.mtu = dev->mtu -sizeof (struct pppoe_hdr ); po->chan.private = sk; po->chan.ops = &pppoe_chan_ops;@@ -831,7 +832,7 @@ static int __pppoe_xmit(struct sock *sk,struct pppoe_hdr *ph;int headroom =skb_headroom (skb);int data_len = skb->len; -struct sk_buff *skb2; +struct sk_buff *skb2 =NULL ;if (sock_flag (sk,SOCK_DEAD ) || !(sk->sk_state &PPPOX_CONNECTED )) goto abort;@@ -887,6 +888,8 @@ static int __pppoe_xmit(struct sock *sk,return 1 ;abort:
drivers/net/pppoe.c +2
-0+if (skb2) +kfree_skb (skb2);return 0; }