Skip to contentSkip to conversation

Patch "switchdev: pass pointer to fib_info instead of copy" has been added to the 4.6-stable tree

PATCH [email protected] 1 participant 1 message Jun 17, 2016

Subsystems (5)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

switchdev: pass pointer to fib_info instead of copy

to the 4.6-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
switchdev-pass-pointer-to-fib_info-instead-of-copy.patch
and it can be found in the queue-4.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From foo@baz Fri Jun 17 08:34:39 PDT 2016

From: Jiri Pirko <[email protected]>
Date: Tue, 17 May 2016 18:58:08 +0200
Subject: switchdev: pass pointer to fib_info instead of copy

From: Jiri Pirko <[email protected]>

[ Upstream commit da4ed55165d41b1073f9a476f1c18493e9bf8c8e ]

The problem is that fib_info->nh is [0] so the struct fib_info allocation size depends on number of nexthops. If we just copy fib_info, we do not copy the nexthops info and driver accesses memory which is not ours.

Given the fact that fib4 does not defer operations and therefore it does not need copy, just pass the pointer down to drivers as it was done before.

Fixes 850d0cbc91 ("switchdev: remove pointers from switchdev objects")
---
 drivers/net/ethernet/rocker/rocker_ofdpa.c |    4 ++--
 include/net/switchdev.h                    |    2 +-
 net/switchdev/switchdev.c                  |    6 ++----
 3 files changed, 5 insertions(+), 7 deletions(-)
drivers/net/ethernet/rocker/rocker_ofdpa.c +2 -2
@@ -2727,7 +2727,7 @@ static int ofdpa_port_obj_fib4_add(struc
 
 	return ofdpa_port_fib_ipv4(ofdpa_port, trans,
 				   htonl(fib4->dst), fib4->dst_len,
-				   &fib4->fi, fib4->tb_id, 0);
+				   fib4->fi, fib4->tb_id, 0);
 }
 
 static int ofdpa_port_obj_fib4_del(struct rocker_port *rocker_port,
@@ -2737,7 +2737,7 @@ static int ofdpa_port_obj_fib4_del(struc
 
 	return ofdpa_port_fib_ipv4(ofdpa_port, NULL,
 				   htonl(fib4->dst), fib4->dst_len,
-				   &fib4->fi, fib4->tb_id,
+				   fib4->fi, fib4->tb_id,
 				   OFDPA_OP_FLAG_REMOVE);
 }
 
include/net/switchdev.h +1 -1
@@ -97,7 +97,7 @@ struct switchdev_obj_ipv4_fib {
 	struct switchdev_obj obj;
 	u32 dst;
 	int dst_len;
-	struct fib_info fi;
+	struct fib_info *fi;
 	u8 tos;
 	u8 type;
 	u32 nlflags;
net/switchdev/switchdev.c +2 -4
@@ -1188,6 +1188,7 @@ int switchdev_fib_ipv4_add(u32 dst, int
 		.obj.id = SWITCHDEV_OBJ_ID_IPV4_FIB,
 		.dst = dst,
 		.dst_len = dst_len,
+		.fi = fi,
 		.tos = tos,
 		.type = type,
 		.nlflags = nlflags,
@@ -1196,8 +1197,6 @@ int switchdev_fib_ipv4_add(u32 dst, int
 	struct net_device *dev;
 	int err = 0;
 
-	memcpy(&ipv4_fib.fi, fi, sizeof(ipv4_fib.fi));
-
 	/* Don't offload route if using custom ip rules or if
 	 * IPv4 FIB offloading has been disabled completely.
 	 */
@@ -1242,6 +1241,7 @@ int switchdev_fib_ipv4_del(u32 dst, int
 		.obj.id = SWITCHDEV_OBJ_ID_IPV4_FIB,
 		.dst = dst,
 		.dst_len = dst_len,
+		.fi = fi,
 		.tos = tos,
 		.type = type,
 		.nlflags = 0,
@@ -1250,8 +1250,6 @@ int switchdev_fib_ipv4_del(u32 dst, int
 	struct net_device *dev;
 	int err = 0;
 
-	memcpy(&ipv4_fib.fi, fi, sizeof(ipv4_fib.fi));
-
 	if (!(fi->fib_flags & RTNH_F_OFFLOAD))
 		return 0;
 

Patches currently in stable-queue which might be from [email protected] are

queue-4.6/team-don-t-call-netdev_change_features-under-team-lock.patch queue-4.6/switchdev-pass-pointer-to-fib_info-instead-of-copy.patch