Patchwork [net-next-2.6,1/2] ethtool: prevent null pointer dereference with NTUPLE set but no set_rx_ntuple

login
register
mail settings
Submitter Alexander Duyck
Date April 8, 2011, 10:07 p.m.
Message ID <20110408220722.25468.98089.stgit@gitlad.jf.intel.com>
Download mbox | patch
Permalink /patch/90432/
State Accepted
Delegated to: David Miller
Headers show

Comments

Alexander Duyck - April 8, 2011, 10:07 p.m.
This change is meant to prevent a possible null pointer dereference if
NETIF_F_NTUPLE is defined but the set_rx_ntuple function pointer is not.

The main motivation behind this patch is to eventually replace the ntuple
interfaces entirely with the network flow classifier interfaces.  This
allows the device drivers to maintain the ntuple check internally while
using the network flow classifier interface for setting up and displaying
rules.
Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
---

 net/core/ethtool.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)


--
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
David Miller - April 11, 2011, 8:21 p.m.
From: Alexander Duyck <alexander.h.duyck@intel.com>
Date: Fri, 08 Apr 2011 15:07:22 -0700

> This change is meant to prevent a possible null pointer dereference if
> NETIF_F_NTUPLE is defined but the set_rx_ntuple function pointer is not.
> 
> The main motivation behind this patch is to eventually replace the ntuple
> interfaces entirely with the network flow classifier interfaces.  This
> allows the device drivers to maintain the ntuple check internally while
> using the network flow classifier interface for setting up and displaying
> rules.
> Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>

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/net/core/ethtool.c b/net/core/ethtool.c
index 1b7fa98..704e176 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -910,6 +910,9 @@  static noinline_for_stack int ethtool_set_rx_ntuple(struct net_device *dev,
 	struct ethtool_rx_ntuple_flow_spec_container *fsc = NULL;
 	int ret;
 
+	if (!ops->set_rx_ntuple)
+		return -EOPNOTSUPP;
+
 	if (!(dev->features & NETIF_F_NTUPLE))
 		return -EINVAL;