diff options
author | Ben Hutchings <ben@decadent.org.uk> | 2019-05-07 19:26:39 +0100 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2019-05-07 19:26:39 +0100 |
commit | ef21a9556d964e8da65ce0df6de508d5650308d7 (patch) | |
tree | 8a782c2418cb7735da46b2c7c37df49e5269a43e | |
parent | 5b9dc26c76bc7a1c6575c73de28a2cd15fecb531 (diff) | |
download | linux-stable-queue-ef21a9556d964e8da65ce0df6de508d5650308d7.tar.gz |
Add an ip_fib fix that we missed
After commit b427832009b9 "net: ipv4: update fnhe_pmtu when first
hop's MTU changes", sparse complained:
net/ipv4/fib_semantics.c:1140:18: sparse: incompatible types in comparison expression (different address spaces)
which revealed that we missed this fix.
-rw-r--r-- | queue-3.16/ipv4-fix-a-race-in-update_or_create_fnhe.patch | 83 | ||||
-rw-r--r-- | queue-3.16/series | 1 |
2 files changed, 84 insertions, 0 deletions
diff --git a/queue-3.16/ipv4-fix-a-race-in-update_or_create_fnhe.patch b/queue-3.16/ipv4-fix-a-race-in-update_or_create_fnhe.patch new file mode 100644 index 00000000..0357fc5d --- /dev/null +++ b/queue-3.16/ipv4-fix-a-race-in-update_or_create_fnhe.patch @@ -0,0 +1,83 @@ +From: Eric Dumazet <edumazet@google.com> +Date: Wed, 3 Sep 2014 22:21:56 -0700 +Subject: ipv4: fix a race in update_or_create_fnhe() + +commit caa415270c732505240bb60171c44a7838c555e8 upstream. + +nh_exceptions is effectively used under rcu, but lacks proper +barriers. Between kzalloc() and setting of nh->nh_exceptions(), +we need a proper memory barrier. + +Signed-off-by: Eric Dumazet <edumazet@google.com> +Fixes: 4895c771c7f00 ("ipv4: Add FIB nexthop exceptions.") +Signed-off-by: David S. Miller <davem@davemloft.net> +Signed-off-by: Ben Hutchings <ben@decadent.org.uk> +--- + include/net/ip_fib.h | 2 +- + net/ipv4/fib_semantics.c | 8 +++++--- + net/ipv4/route.c | 6 +++--- + 3 files changed, 9 insertions(+), 7 deletions(-) + +--- a/include/net/ip_fib.h ++++ b/include/net/ip_fib.h +@@ -89,7 +89,7 @@ struct fib_nh { + int nh_saddr_genid; + struct rtable __rcu * __percpu *nh_pcpu_rth_output; + struct rtable __rcu *nh_rth_input; +- struct fnhe_hash_bucket *nh_exceptions; ++ struct fnhe_hash_bucket __rcu *nh_exceptions; + }; + + /* +--- a/net/ipv4/fib_semantics.c ++++ b/net/ipv4/fib_semantics.c +@@ -157,9 +157,12 @@ static void rt_fibinfo_free(struct rtabl + + static void free_nh_exceptions(struct fib_nh *nh) + { +- struct fnhe_hash_bucket *hash = nh->nh_exceptions; ++ struct fnhe_hash_bucket *hash; + int i; + ++ hash = rcu_dereference_protected(nh->nh_exceptions, 1); ++ if (!hash) ++ return; + for (i = 0; i < FNHE_HASH_SIZE; i++) { + struct fib_nh_exception *fnhe; + +@@ -206,8 +209,7 @@ static void free_fib_info_rcu(struct rcu + change_nexthops(fi) { + if (nexthop_nh->nh_dev) + dev_put(nexthop_nh->nh_dev); +- if (nexthop_nh->nh_exceptions) +- free_nh_exceptions(nexthop_nh); ++ free_nh_exceptions(nexthop_nh); + rt_fibinfo_free_cpus(nexthop_nh->nh_pcpu_rth_output); + rt_fibinfo_free(&nexthop_nh->nh_rth_input); + } endfor_nexthops(fi); +--- a/net/ipv4/route.c ++++ b/net/ipv4/route.c +@@ -635,12 +635,12 @@ static void update_or_create_fnhe(struct + + spin_lock_bh(&fnhe_lock); + +- hash = nh->nh_exceptions; ++ hash = rcu_dereference(nh->nh_exceptions); + if (!hash) { + hash = kzalloc(FNHE_HASH_SIZE * sizeof(*hash), GFP_ATOMIC); + if (!hash) + goto out_unlock; +- nh->nh_exceptions = hash; ++ rcu_assign_pointer(nh->nh_exceptions, hash); + } + + hash += hval; +@@ -1293,7 +1293,7 @@ static void ip_del_fnhe(struct fib_nh *n + + static struct fib_nh_exception *find_exception(struct fib_nh *nh, __be32 daddr) + { +- struct fnhe_hash_bucket *hash = nh->nh_exceptions; ++ struct fnhe_hash_bucket *hash = rcu_dereference(nh->nh_exceptions); + struct fib_nh_exception *fnhe; + u32 hval; + diff --git a/queue-3.16/series b/queue-3.16/series index 2c085405..4fa59399 100644 --- a/queue-3.16/series +++ b/queue-3.16/series @@ -3,3 +3,4 @@ brcmfmac-add-length-checks-in-scheduled-scan-result-handler.patch inet-update-the-ip-id-generation-algorithm-to-higher-standards.patch spi-omap-100k-remove-unused-definitions.patch vxlan-fix-big-endian-declaration-of-vni.patch +ipv4-fix-a-race-in-update_or_create_fnhe.patch |