Skip to content

Commit 11695c6

Browse files
edumazetdavem330
authored andcommitted
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: b9bb53f ("sock: convert sk_peek_offset functions to WRITE_ONCE") Signed-off-by: Eric Dumazet <[email protected]> Cc: Willem de Bruijn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3c5b4d6 commit 11695c6

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

net/core/sock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1870,7 +1870,7 @@ int sk_getsockopt(struct sock *sk, int level, int optname,
18701870
if (!sock->ops->set_peek_off)
18711871
return -EOPNOTSUPP;
18721872

1873-
v.val = sk->sk_peek_off;
1873+
v.val = READ_ONCE(sk->sk_peek_off);
18741874
break;
18751875
case SO_NOFCS:
18761876
v.val = sock_flag(sk, SOCK_NOFCS);
@@ -3179,7 +3179,7 @@ EXPORT_SYMBOL(__sk_mem_reclaim);
31793179

31803180
int sk_set_peek_off(struct sock *sk, int val)
31813181
{
3182-
sk->sk_peek_off = val;
3182+
WRITE_ONCE(sk->sk_peek_off, val);
31833183
return 0;
31843184
}
31853185
EXPORT_SYMBOL_GPL(sk_set_peek_off);

net/unix/af_unix.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ static int unix_set_peek_off(struct sock *sk, int val)
790790
if (mutex_lock_interruptible(&u->iolock))
791791
return -EINTR;
792792

793-
sk->sk_peek_off = val;
793+
WRITE_ONCE(sk->sk_peek_off, val);
794794
mutex_unlock(&u->iolock);
795795

796796
return 0;

0 commit comments

Comments
 (0)