Commit 64cc41e6 authored by David S. Miller's avatar David S. Miller

Merge branch 'ipv6-route-rcu'

Paolo Abeni says:

====================
ipv6: route: enforce RCU protection for fib6_info->from

This series addresses a couple of RCU left-over dating back to rt6_info->from
conversion to RCU

v1 -> v2:
 - fix a possible race in patch 1
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents ae3b5641 bf1dc8ba
...@@ -1599,15 +1599,15 @@ static int rt6_remove_exception_rt(struct rt6_info *rt) ...@@ -1599,15 +1599,15 @@ static int rt6_remove_exception_rt(struct rt6_info *rt)
static void rt6_update_exception_stamp_rt(struct rt6_info *rt) static void rt6_update_exception_stamp_rt(struct rt6_info *rt)
{ {
struct rt6_exception_bucket *bucket; struct rt6_exception_bucket *bucket;
struct fib6_info *from = rt->from;
struct in6_addr *src_key = NULL; struct in6_addr *src_key = NULL;
struct rt6_exception *rt6_ex; struct rt6_exception *rt6_ex;
struct fib6_info *from;
if (!from ||
!(rt->rt6i_flags & RTF_CACHE))
return;
rcu_read_lock(); rcu_read_lock();
from = rcu_dereference(rt->from);
if (!from || !(rt->rt6i_flags & RTF_CACHE))
goto unlock;
bucket = rcu_dereference(from->rt6i_exception_bucket); bucket = rcu_dereference(from->rt6i_exception_bucket);
#ifdef CONFIG_IPV6_SUBTREES #ifdef CONFIG_IPV6_SUBTREES
...@@ -1626,6 +1626,7 @@ static void rt6_update_exception_stamp_rt(struct rt6_info *rt) ...@@ -1626,6 +1626,7 @@ static void rt6_update_exception_stamp_rt(struct rt6_info *rt)
if (rt6_ex) if (rt6_ex)
rt6_ex->stamp = jiffies; rt6_ex->stamp = jiffies;
unlock:
rcu_read_unlock(); rcu_read_unlock();
} }
...@@ -2742,20 +2743,24 @@ static int ip6_route_check_nh_onlink(struct net *net, ...@@ -2742,20 +2743,24 @@ static int ip6_route_check_nh_onlink(struct net *net,
u32 tbid = l3mdev_fib_table(dev) ? : RT_TABLE_MAIN; u32 tbid = l3mdev_fib_table(dev) ? : RT_TABLE_MAIN;
const struct in6_addr *gw_addr = &cfg->fc_gateway; const struct in6_addr *gw_addr = &cfg->fc_gateway;
u32 flags = RTF_LOCAL | RTF_ANYCAST | RTF_REJECT; u32 flags = RTF_LOCAL | RTF_ANYCAST | RTF_REJECT;
struct fib6_info *from;
struct rt6_info *grt; struct rt6_info *grt;
int err; int err;
err = 0; err = 0;
grt = ip6_nh_lookup_table(net, cfg, gw_addr, tbid, 0); grt = ip6_nh_lookup_table(net, cfg, gw_addr, tbid, 0);
if (grt) { if (grt) {
rcu_read_lock();
from = rcu_dereference(grt->from);
if (!grt->dst.error && if (!grt->dst.error &&
/* ignore match if it is the default route */ /* ignore match if it is the default route */
grt->from && !ipv6_addr_any(&grt->from->fib6_dst.addr) && from && !ipv6_addr_any(&from->fib6_dst.addr) &&
(grt->rt6i_flags & flags || dev != grt->dst.dev)) { (grt->rt6i_flags & flags || dev != grt->dst.dev)) {
NL_SET_ERR_MSG(extack, NL_SET_ERR_MSG(extack,
"Nexthop has invalid gateway or device mismatch"); "Nexthop has invalid gateway or device mismatch");
err = -EINVAL; err = -EINVAL;
} }
rcu_read_unlock();
ip6_rt_put(grt); ip6_rt_put(grt);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment