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

net: add missing data-race annotations around sk->sk_peek_off

sk_getsockopt() runs locklessly, thus we need to annotate the read
of sk->sk_peek_off.

While we are at it, add corresponding annotations to sk_set_peek_off()
and unix_set_peek_off().

Fixes: b9bb53f3 ("sock: convert sk_peek_offset functions to WRITE_ONCE")
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Cc: Willem de Bruijn <willemb@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3c5b4d69
...@@ -1870,7 +1870,7 @@ int sk_getsockopt(struct sock *sk, int level, int optname, ...@@ -1870,7 +1870,7 @@ int sk_getsockopt(struct sock *sk, int level, int optname,
if (!sock->ops->set_peek_off) if (!sock->ops->set_peek_off)
return -EOPNOTSUPP; return -EOPNOTSUPP;
v.val = sk->sk_peek_off; v.val = READ_ONCE(sk->sk_peek_off);
break; break;
case SO_NOFCS: case SO_NOFCS:
v.val = sock_flag(sk, SOCK_NOFCS); v.val = sock_flag(sk, SOCK_NOFCS);
...@@ -3179,7 +3179,7 @@ EXPORT_SYMBOL(__sk_mem_reclaim); ...@@ -3179,7 +3179,7 @@ EXPORT_SYMBOL(__sk_mem_reclaim);
int sk_set_peek_off(struct sock *sk, int val) int sk_set_peek_off(struct sock *sk, int val)
{ {
sk->sk_peek_off = val; WRITE_ONCE(sk->sk_peek_off, val);
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(sk_set_peek_off); EXPORT_SYMBOL_GPL(sk_set_peek_off);
......
...@@ -790,7 +790,7 @@ static int unix_set_peek_off(struct sock *sk, int val) ...@@ -790,7 +790,7 @@ static int unix_set_peek_off(struct sock *sk, int val)
if (mutex_lock_interruptible(&u->iolock)) if (mutex_lock_interruptible(&u->iolock))
return -EINTR; return -EINTR;
sk->sk_peek_off = val; WRITE_ONCE(sk->sk_peek_off, val);
mutex_unlock(&u->iolock); mutex_unlock(&u->iolock);
return 0; return 0;
......
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