Skip to content

Commit 982f37b

Browse files
edumazetsmb49
authored andcommitted
net: add missing data-race annotations around sk->sk_peek_off
BugLink: https://bugs.launchpad.net/bugs/2038236 [ Upstream commit 11695c6 ] 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 <edumazet@google.com> Cc: Willem de Bruijn <willemb@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Kamal Mostafa <kamal@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent c3aa975 commit 982f37b

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

net/core/sock.c

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

1826-
v.val = sk->sk_peek_off;
1826+
v.val = READ_ONCE(sk->sk_peek_off);
18271827
break;
18281828
case SO_NOFCS:
18291829
v.val = sock_flag(sk, SOCK_NOFCS);
@@ -3141,7 +3141,7 @@ EXPORT_SYMBOL(__sk_mem_reclaim);
31413141

31423142
int sk_set_peek_off(struct sock *sk, int val)
31433143
{
3144-
sk->sk_peek_off = val;
3144+
WRITE_ONCE(sk->sk_peek_off, val);
31453145
return 0;
31463146
}
31473147
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
@@ -779,7 +779,7 @@ static int unix_set_peek_off(struct sock *sk, int val)
779779
if (mutex_lock_interruptible(&u->iolock))
780780
return -EINTR;
781781

782-
sk->sk_peek_off = val;
782+
WRITE_ONCE(sk->sk_peek_off, val);
783783
mutex_unlock(&u->iolock);
784784

785785
return 0;

0 commit comments

Comments
 (0)