Commit e7135f48 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

ipv6: annotate data-races around cnf.mtu6

idev->cnf.mtu6 might be read locklessly, add appropriate READ_ONCE()
and WRITE_ONCE() annotations.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 553ced03
...@@ -332,7 +332,7 @@ static inline unsigned int ip6_dst_mtu_maybe_forward(const struct dst_entry *dst ...@@ -332,7 +332,7 @@ static inline unsigned int ip6_dst_mtu_maybe_forward(const struct dst_entry *dst
rcu_read_lock(); rcu_read_lock();
idev = __in6_dev_get(dst->dev); idev = __in6_dev_get(dst->dev);
if (idev) if (idev)
mtu = idev->cnf.mtu6; mtu = READ_ONCE(idev->cnf.mtu6);
rcu_read_unlock(); rcu_read_unlock();
out: out:
......
...@@ -3671,7 +3671,7 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event, ...@@ -3671,7 +3671,7 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
if (idev) { if (idev) {
rt6_mtu_change(dev, dev->mtu); rt6_mtu_change(dev, dev->mtu);
idev->cnf.mtu6 = dev->mtu; WRITE_ONCE(idev->cnf.mtu6, dev->mtu);
break; break;
} }
...@@ -3763,7 +3763,7 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event, ...@@ -3763,7 +3763,7 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
if (idev->cnf.mtu6 != dev->mtu && if (idev->cnf.mtu6 != dev->mtu &&
dev->mtu >= IPV6_MIN_MTU) { dev->mtu >= IPV6_MIN_MTU) {
rt6_mtu_change(dev, dev->mtu); rt6_mtu_change(dev, dev->mtu);
idev->cnf.mtu6 = dev->mtu; WRITE_ONCE(idev->cnf.mtu6, dev->mtu);
} }
WRITE_ONCE(idev->tstamp, jiffies); WRITE_ONCE(idev->tstamp, jiffies);
inet6_ifinfo_notify(RTM_NEWLINK, idev); inet6_ifinfo_notify(RTM_NEWLINK, idev);
......
...@@ -1578,8 +1578,8 @@ static enum skb_drop_reason ndisc_router_discovery(struct sk_buff *skb) ...@@ -1578,8 +1578,8 @@ static enum skb_drop_reason ndisc_router_discovery(struct sk_buff *skb)
if (mtu < IPV6_MIN_MTU || mtu > skb->dev->mtu) { if (mtu < IPV6_MIN_MTU || mtu > skb->dev->mtu) {
ND_PRINTK(2, warn, "RA: invalid mtu: %d\n", mtu); ND_PRINTK(2, warn, "RA: invalid mtu: %d\n", mtu);
} else if (in6_dev->cnf.mtu6 != mtu) { } else if (READ_ONCE(in6_dev->cnf.mtu6) != mtu) {
in6_dev->cnf.mtu6 = mtu; WRITE_ONCE(in6_dev->cnf.mtu6, mtu);
fib6_metric_set(rt, RTAX_MTU, mtu); fib6_metric_set(rt, RTAX_MTU, mtu);
rt6_mtu_change(skb->dev, mtu); rt6_mtu_change(skb->dev, mtu);
} }
......
...@@ -1596,7 +1596,7 @@ static unsigned int fib6_mtu(const struct fib6_result *res) ...@@ -1596,7 +1596,7 @@ static unsigned int fib6_mtu(const struct fib6_result *res)
rcu_read_lock(); rcu_read_lock();
idev = __in6_dev_get(dev); idev = __in6_dev_get(dev);
mtu = idev->cnf.mtu6; mtu = READ_ONCE(idev->cnf.mtu6);
rcu_read_unlock(); rcu_read_unlock();
} }
...@@ -3249,8 +3249,8 @@ u32 ip6_mtu_from_fib6(const struct fib6_result *res, ...@@ -3249,8 +3249,8 @@ u32 ip6_mtu_from_fib6(const struct fib6_result *res,
mtu = IPV6_MIN_MTU; mtu = IPV6_MIN_MTU;
idev = __in6_dev_get(dev); idev = __in6_dev_get(dev);
if (idev && idev->cnf.mtu6 > mtu) if (idev)
mtu = idev->cnf.mtu6; mtu = max_t(u32, mtu, READ_ONCE(idev->cnf.mtu6));
} }
mtu = min_t(unsigned int, mtu, IP6_MAX_MTU); mtu = min_t(unsigned int, mtu, IP6_MAX_MTU);
......
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