Skip to content

Commit

Permalink
net_sched: em_meta: add READ_ONCE() in var_sk_bound_if()
Browse files Browse the repository at this point in the history
sk->sk_bound_dev_if can change under us, use READ_ONCE() annotation.

Signed-off-by: Eric Dumazet <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Eric Dumazet authored and davem330 committed May 16, 2022
1 parent d2c1356 commit 70f87de
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions net/sched/em_meta.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,20 +311,23 @@ META_COLLECTOR(int_sk_bound_if)

META_COLLECTOR(var_sk_bound_if)
{
int bound_dev_if;

if (skip_nonlocal(skb)) {
*err = -1;
return;
}

if (skb->sk->sk_bound_dev_if == 0) {
bound_dev_if = READ_ONCE(skb->sk->sk_bound_dev_if);
if (bound_dev_if == 0) {
dst->value = (unsigned long) "any";
dst->len = 3;
} else {
struct net_device *dev;

rcu_read_lock();
dev = dev_get_by_index_rcu(sock_net(skb->sk),
skb->sk->sk_bound_dev_if);
bound_dev_if);
*err = var_dev(dev, dst);
rcu_read_unlock();
}
Expand Down

0 comments on commit 70f87de

Please sign in to comment.