All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] nfp: flower: fix port metadata conversion bug
@ 2018-07-28  3:56 Jakub Kicinski
  2018-07-28 21:28 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Kicinski @ 2018-07-28  3:56 UTC (permalink / raw)
  To: davem; +Cc: oss-drivers, netdev, John Hurley, Jakub Kicinski

From: John Hurley <john.hurley@netronome.com>

Function nfp_flower_repr_get_type_and_port expects an enum nfp_repr_type
return value but, if the repr type is unknown, returns a value of type
enum nfp_flower_cmsg_port_type.  This means that if FW encodes the port
ID in a way the driver does not understand instead of dropping the frame
driver may attribute it to a physical port (uplink) provided the port
number is less than physical port count.

Fix this and ensure a net_device of NULL is returned if the repr can not
be determined.

Fixes: 1025351a88a4 ("nfp: add flower app")
Signed-off-by: John Hurley <john.hurley@netronome.com>
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
This is low impact and unlikely, but also fix is trivial so either
net or net-next works.

 drivers/net/ethernet/netronome/nfp/flower/main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/netronome/nfp/flower/main.c b/drivers/net/ethernet/netronome/nfp/flower/main.c
index 1decf3a1cad3..e57d23746585 100644
--- a/drivers/net/ethernet/netronome/nfp/flower/main.c
+++ b/drivers/net/ethernet/netronome/nfp/flower/main.c
@@ -80,7 +80,7 @@ nfp_flower_repr_get_type_and_port(struct nfp_app *app, u32 port_id, u8 *port)
 			return NFP_REPR_TYPE_VF;
 	}
 
-	return NFP_FLOWER_CMSG_PORT_TYPE_UNSPEC;
+	return __NFP_REPR_TYPE_MAX;
 }
 
 static struct net_device *
@@ -91,6 +91,8 @@ nfp_flower_repr_get(struct nfp_app *app, u32 port_id)
 	u8 port = 0;
 
 	repr_type = nfp_flower_repr_get_type_and_port(app, port_id, &port);
+	if (repr_type > NFP_REPR_TYPE_MAX)
+		return NULL;
 
 	reprs = rcu_dereference(app->reprs[repr_type]);
 	if (!reprs)
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] nfp: flower: fix port metadata conversion bug
  2018-07-28  3:56 [PATCH net] nfp: flower: fix port metadata conversion bug Jakub Kicinski
@ 2018-07-28 21:28 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-07-28 21:28 UTC (permalink / raw)
  To: jakub.kicinski; +Cc: oss-drivers, netdev, john.hurley

From: Jakub Kicinski <jakub.kicinski@netronome.com>
Date: Fri, 27 Jul 2018 20:56:52 -0700

> From: John Hurley <john.hurley@netronome.com>
> 
> Function nfp_flower_repr_get_type_and_port expects an enum nfp_repr_type
> return value but, if the repr type is unknown, returns a value of type
> enum nfp_flower_cmsg_port_type.  This means that if FW encodes the port
> ID in a way the driver does not understand instead of dropping the frame
> driver may attribute it to a physical port (uplink) provided the port
> number is less than physical port count.
> 
> Fix this and ensure a net_device of NULL is returned if the repr can not
> be determined.
> 
> Fixes: 1025351a88a4 ("nfp: add flower app")
> Signed-off-by: John Hurley <john.hurley@netronome.com>
> Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
> ---
> This is low impact and unlikely, but also fix is trivial so either
> net or net-next works.

Applied to 'net', thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-07-28 22:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-28  3:56 [PATCH net] nfp: flower: fix port metadata conversion bug Jakub Kicinski
2018-07-28 21:28 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.