Patchwork [net,1/1] Phonet: refuse to send bigger than MTU packets

login
register
mail settings
Submitter Rémi Denis-Courmont
Date Nov. 14, 2008, 9:08 a.m.
Message ID <1226653710-27642-1-git-send-email-remi.denis-courmont@nokia.com>
Download mbox | patch
Permalink /patch/8734/
State Accepted
Delegated to: David Miller
Headers show

Comments

Rémi Denis-Courmont - Nov. 14, 2008, 9:08 a.m.
Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>
---
 net/phonet/af_phonet.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
Ilpo Järvinen - Nov. 14, 2008, 10:25 a.m.
On Fri, 14 Nov 2008, Rémi Denis-Courmont wrote:

> Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>
> ---
>  net/phonet/af_phonet.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
> index defeb7a..7ab30f6 100644
> --- a/net/phonet/af_phonet.c
> +++ b/net/phonet/af_phonet.c
> @@ -144,8 +144,8 @@ static int pn_send(struct sk_buff *skb, struct net_device *dev,
>  	struct phonethdr *ph;
>  	int err;
>  
> -	if (skb->len + 2 > 0xffff) {
> -		/* Phonet length field would overflow */
> +	if (skb->len + 2 > 0xffff /* Phonet length field limit */ ||

It would by much better to have a well named constant there rather than 
such crazy and messy contruct with a comment.
David Miller - Nov. 17, 2008, 3:49 a.m.
From: "Ilpo Järvinen" <ilpo.jarvinen@helsinki.fi>
Date: Fri, 14 Nov 2008 12:25:40 +0200 (EET)

> On Fri, 14 Nov 2008, Rémi Denis-Courmont wrote:
> 
> > Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>
> > ---
> >  net/phonet/af_phonet.c |    4 ++--
> >  1 files changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
> > index defeb7a..7ab30f6 100644
> > --- a/net/phonet/af_phonet.c
> > +++ b/net/phonet/af_phonet.c
> > @@ -144,8 +144,8 @@ static int pn_send(struct sk_buff *skb, struct net_device *dev,
> >  	struct phonethdr *ph;
> >  	int err;
> >  
> > -	if (skb->len + 2 > 0xffff) {
> > -		/* Phonet length field would overflow */
> > +	if (skb->len + 2 > 0xffff /* Phonet length field limit */ ||
> 
> It would by much better to have a well named constant there rather than 
> such crazy and messy contruct with a comment.

Sure, but it would need to be "U16_MAX" or whatever, which we don't
have currently, since this is a field overflow check rather than some
specific constant defined by the protocol.

I'm applying Rémi's patch.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
index defeb7a..7ab30f6 100644
--- a/net/phonet/af_phonet.c
+++ b/net/phonet/af_phonet.c
@@ -144,8 +144,8 @@  static int pn_send(struct sk_buff *skb, struct net_device *dev,
 	struct phonethdr *ph;
 	int err;
 
-	if (skb->len + 2 > 0xffff) {
-		/* Phonet length field would overflow */
+	if (skb->len + 2 > 0xffff /* Phonet length field limit */ ||
+	    skb->len + sizeof(struct phonethdr) > dev->mtu) {
 		err = -EMSGSIZE;
 		goto drop;
 	}