Patchwork [2/2] net: verify GSO flag bits against netdev features

login
register
mail settings
Submitter Michał Mirosław
Date Nov. 17, 2011, 12:05 a.m.
Message ID <d4513ed885d62d13873f9b7310fc20cbfa55f634.1321488025.git.mirq-linux@rere.qmqm.pl>
Download mbox | patch
Permalink /patch/126090/
State Accepted
Delegated to: David Miller
Headers show

Comments

Michał Mirosław - Nov. 17, 2011, 12:05 a.m.
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 include/linux/netdevice.h |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
Ben Hutchings - Nov. 17, 2011, 12:09 a.m.
On Thu, 2011-11-17 at 01:05 +0100, Michał Mirosław wrote:
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> ---
>  include/linux/netdevice.h |    9 +++++++++
>  1 files changed, 9 insertions(+), 0 deletions(-)
> 
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index b35ffd7..31da3bb 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -2492,6 +2492,15 @@ netdev_features_t netif_skb_features(struct sk_buff *skb);
>  static inline int net_gso_ok(netdev_features_t features, int gso_type)
>  {
>  	netdev_features_t feature = gso_type << NETIF_F_GSO_SHIFT;
> +
> +	/* check flags correspondence */
> +	BUILD_BUG_ON(SKB_GSO_TCPV4   != (NETIF_F_TSO >> NETIF_F_GSO_SHIFT));
> +	BUILD_BUG_ON(SKB_GSO_UDP     != (NETIF_F_UFO >> NETIF_F_GSO_SHIFT));
> +	BUILD_BUG_ON(SKB_GSO_DODGY   != (NETIF_F_GSO_ROBUST >> NETIF_F_GSO_SHIFT));
> +	BUILD_BUG_ON(SKB_GSO_TCP_ECN != (NETIF_F_TSO_ECN >> NETIF_F_GSO_SHIFT));
> +	BUILD_BUG_ON(SKB_GSO_TCPV6   != (NETIF_F_TSO6 >> NETIF_F_GSO_SHIFT));
> +	BUILD_BUG_ON(SKB_GSO_FCOE    != (NETIF_F_FSO >> NETIF_F_GSO_SHIFT));
> +
>  	return (features & feature) == feature;
>  }

This is fine but should still be done at the same time as changing the
definitions.

Ben.
Michał Mirosław - Nov. 17, 2011, 12:13 a.m.
On Thu, Nov 17, 2011 at 12:09:56AM +0000, Ben Hutchings wrote:
> On Thu, 2011-11-17 at 01:05 +0100, Michał Mirosław wrote:
> > Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> > ---
> >  include/linux/netdevice.h |    9 +++++++++
> >  1 files changed, 9 insertions(+), 0 deletions(-)
> > 
> > diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> > index b35ffd7..31da3bb 100644
> > --- a/include/linux/netdevice.h
> > +++ b/include/linux/netdevice.h
> > @@ -2492,6 +2492,15 @@ netdev_features_t netif_skb_features(struct sk_buff *skb);
> >  static inline int net_gso_ok(netdev_features_t features, int gso_type)
> >  {
> >  	netdev_features_t feature = gso_type << NETIF_F_GSO_SHIFT;
> > +
> > +	/* check flags correspondence */
> > +	BUILD_BUG_ON(SKB_GSO_TCPV4   != (NETIF_F_TSO >> NETIF_F_GSO_SHIFT));
> > +	BUILD_BUG_ON(SKB_GSO_UDP     != (NETIF_F_UFO >> NETIF_F_GSO_SHIFT));
> > +	BUILD_BUG_ON(SKB_GSO_DODGY   != (NETIF_F_GSO_ROBUST >> NETIF_F_GSO_SHIFT));
> > +	BUILD_BUG_ON(SKB_GSO_TCP_ECN != (NETIF_F_TSO_ECN >> NETIF_F_GSO_SHIFT));
> > +	BUILD_BUG_ON(SKB_GSO_TCPV6   != (NETIF_F_TSO6 >> NETIF_F_GSO_SHIFT));
> > +	BUILD_BUG_ON(SKB_GSO_FCOE    != (NETIF_F_FSO >> NETIF_F_GSO_SHIFT));
> > +
> >  	return (features & feature) == feature;
> >  }
> This is fine but should still be done at the same time as changing the
> definitions.

Agreed. But as Dave was quicker, we need to fix this in separate patch.

Best Regards,
Michał Mirosław
--
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
Ben Hutchings - Nov. 17, 2011, 12:35 a.m.
On Thu, 2011-11-17 at 01:13 +0100, Michał Mirosław wrote:
> On Thu, Nov 17, 2011 at 12:09:56AM +0000, Ben Hutchings wrote:
> > On Thu, 2011-11-17 at 01:05 +0100, Michał Mirosław wrote:
> > > Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> > > ---
> > >  include/linux/netdevice.h |    9 +++++++++
> > >  1 files changed, 9 insertions(+), 0 deletions(-)
> > > 
> > > diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> > > index b35ffd7..31da3bb 100644
> > > --- a/include/linux/netdevice.h
> > > +++ b/include/linux/netdevice.h
> > > @@ -2492,6 +2492,15 @@ netdev_features_t netif_skb_features(struct sk_buff *skb);
> > >  static inline int net_gso_ok(netdev_features_t features, int gso_type)
> > >  {
> > >  	netdev_features_t feature = gso_type << NETIF_F_GSO_SHIFT;
> > > +
> > > +	/* check flags correspondence */
> > > +	BUILD_BUG_ON(SKB_GSO_TCPV4   != (NETIF_F_TSO >> NETIF_F_GSO_SHIFT));
> > > +	BUILD_BUG_ON(SKB_GSO_UDP     != (NETIF_F_UFO >> NETIF_F_GSO_SHIFT));
> > > +	BUILD_BUG_ON(SKB_GSO_DODGY   != (NETIF_F_GSO_ROBUST >> NETIF_F_GSO_SHIFT));
> > > +	BUILD_BUG_ON(SKB_GSO_TCP_ECN != (NETIF_F_TSO_ECN >> NETIF_F_GSO_SHIFT));
> > > +	BUILD_BUG_ON(SKB_GSO_TCPV6   != (NETIF_F_TSO6 >> NETIF_F_GSO_SHIFT));
> > > +	BUILD_BUG_ON(SKB_GSO_FCOE    != (NETIF_F_FSO >> NETIF_F_GSO_SHIFT));
> > > +
> > >  	return (features & feature) == feature;
> > >  }
> > This is fine but should still be done at the same time as changing the
> > definitions.
> 
> Agreed. But as Dave was quicker, we need to fix this in separate patch.

Sorry, I somehow failed to spot that.

Ben.
David Miller - Nov. 17, 2011, 1:41 a.m.
From: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Date: Thu, 17 Nov 2011 01:05:33 +0100 (CET)

> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>

Applied.
--
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/include/linux/netdevice.h b/include/linux/netdevice.h
index b35ffd7..31da3bb 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2492,6 +2492,15 @@  netdev_features_t netif_skb_features(struct sk_buff *skb);
 static inline int net_gso_ok(netdev_features_t features, int gso_type)
 {
 	netdev_features_t feature = gso_type << NETIF_F_GSO_SHIFT;
+
+	/* check flags correspondence */
+	BUILD_BUG_ON(SKB_GSO_TCPV4   != (NETIF_F_TSO >> NETIF_F_GSO_SHIFT));
+	BUILD_BUG_ON(SKB_GSO_UDP     != (NETIF_F_UFO >> NETIF_F_GSO_SHIFT));
+	BUILD_BUG_ON(SKB_GSO_DODGY   != (NETIF_F_GSO_ROBUST >> NETIF_F_GSO_SHIFT));
+	BUILD_BUG_ON(SKB_GSO_TCP_ECN != (NETIF_F_TSO_ECN >> NETIF_F_GSO_SHIFT));
+	BUILD_BUG_ON(SKB_GSO_TCPV6   != (NETIF_F_TSO6 >> NETIF_F_GSO_SHIFT));
+	BUILD_BUG_ON(SKB_GSO_FCOE    != (NETIF_F_FSO >> NETIF_F_GSO_SHIFT));
+
 	return (features & feature) == feature;
 }