]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/3.4.51/team-check-return-value-of-team_get_port_by_index_rcu-for-null.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.4.51 / team-check-return-value-of-team_get_port_by_index_rcu-for-null.patch
CommitLineData
7a674766
GKH
1From 83ac5bd697e4fde6357fe4611f7f03edc547f8a9 Mon Sep 17 00:00:00 2001
2From: Jiri Pirko <jiri@resnulli.us>
3Date: Sat, 8 Jun 2013 15:00:53 +0200
4Subject: team: check return value of team_get_port_by_index_rcu() for NULL
5
6From: Jiri Pirko <jiri@resnulli.us>
7
8[ Upstream commit 76c455decbbad31de21c727edb184a963f42b40b ]
9
10team_get_port_by_index_rcu() might return NULL due to race between port
11removal and skb tx path. Panic is easily triggeable when txing packets
12and adding/removing port in a loop.
13
14introduced by commit 3d249d4ca "net: introduce ethernet teaming device"
15and commit 753f993911b "team: introduce random mode" (for random mode)
16
17Signed-off-by: Jiri Pirko <jiri@resnulli.us>
18Signed-off-by: David S. Miller <davem@davemloft.net>
19Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
20---
21 drivers/net/team/team_mode_roundrobin.c | 2 ++
22 1 file changed, 2 insertions(+)
23
24--- a/drivers/net/team/team_mode_roundrobin.c
25+++ b/drivers/net/team/team_mode_roundrobin.c
26@@ -52,6 +52,8 @@ static bool rr_transmit(struct team *tea
27
28 port_index = rr_priv(team)->sent_packets++ % team->port_count;
29 port = team_get_port_by_index_rcu(team, port_index);
30+ if (unlikely(!port))
31+ goto drop;
32 port = __get_first_port_up(team, port);
33 if (unlikely(!port))
34 goto drop;