diff mbox series

[net] nfp: refuse offloading filters that redirects to upper devices

Message ID 20171025184705.4336-1-jakub.kicinski@netronome.com
State Accepted, archived
Delegated to: David Miller
Headers show
Series [net] nfp: refuse offloading filters that redirects to upper devices | expand

Commit Message

Jakub Kicinski Oct. 25, 2017, 6:47 p.m. UTC
From: Pieter Jansen van Vuuren <pieter.jansenvanvuuren@netronome.com>

Previously we did not ensure that a netdev is a representative netdev
before dereferencing its private data. This can occur when an upper netdev
is created on a representative netdev. This patch corrects this by first
ensuring that the netdev is a representative netdev before using it.
Checking only switchdev_port_same_parent_id is not sufficient to ensure
that we can safely use the netdev. Failing to check that the netdev is also
a representative netdev would result in incorrect dereferencing.

Fixes: 1a1e586f54bf ("nfp: add basic action capabilities to flower offloads")
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Pieter Jansen van Vuuren <pieter.jansenvanvuuren@netronome.com>
---
 drivers/net/ethernet/netronome/nfp/flower/action.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

David Miller Oct. 26, 2017, 1:09 a.m. UTC | #1
From: Jakub Kicinski <jakub.kicinski@netronome.com>
Date: Wed, 25 Oct 2017 11:47:05 -0700

> From: Pieter Jansen van Vuuren <pieter.jansenvanvuuren@netronome.com>
> 
> Previously we did not ensure that a netdev is a representative netdev
> before dereferencing its private data. This can occur when an upper netdev
> is created on a representative netdev. This patch corrects this by first
> ensuring that the netdev is a representative netdev before using it.
> Checking only switchdev_port_same_parent_id is not sufficient to ensure
> that we can safely use the netdev. Failing to check that the netdev is also
> a representative netdev would result in incorrect dereferencing.
> 
> Fixes: 1a1e586f54bf ("nfp: add basic action capabilities to flower offloads")
> Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
> Signed-off-by: Pieter Jansen van Vuuren <pieter.jansenvanvuuren@netronome.com>

Applied and queued up for -stable.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/netronome/nfp/flower/action.c b/drivers/net/ethernet/netronome/nfp/flower/action.c
index db9750695dc7..8ea9320014ee 100644
--- a/drivers/net/ethernet/netronome/nfp/flower/action.c
+++ b/drivers/net/ethernet/netronome/nfp/flower/action.c
@@ -110,6 +110,8 @@  nfp_fl_output(struct nfp_fl_output *output, const struct tc_action *action,
 	 */
 	if (!switchdev_port_same_parent_id(in_dev, out_dev))
 		return -EOPNOTSUPP;
+	if (!nfp_netdev_is_nfp_repr(out_dev))
+		return -EOPNOTSUPP;
 
 	output->port = cpu_to_be32(nfp_repr_get_port_id(out_dev));
 	if (!output->port)