Skip to content

Commit cba3f17

Browse files
edumazetkuba-moo
authored andcommitted
dccp: annotate data-races in dccp_poll()
We changed tcp_poll() over time, bug never updated dccp. Note that we also could remove dccp instead of maintaining it. Fixes: 7c65787 ("[DCCP]: Initial implementation") Signed-off-by: Eric Dumazet <edumazet@google.com> Link: https://lore.kernel.org/r/20230818015820.2701595-1-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 76f3329 commit cba3f17

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

net/dccp/proto.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,15 @@ EXPORT_SYMBOL_GPL(dccp_disconnect);
315315
__poll_t dccp_poll(struct file *file, struct socket *sock,
316316
poll_table *wait)
317317
{
318-
__poll_t mask;
319318
struct sock *sk = sock->sk;
319+
__poll_t mask;
320+
u8 shutdown;
321+
int state;
320322

321323
sock_poll_wait(file, sock, wait);
322-
if (sk->sk_state == DCCP_LISTEN)
324+
325+
state = inet_sk_state_load(sk);
326+
if (state == DCCP_LISTEN)
323327
return inet_csk_listen_poll(sk);
324328

325329
/* Socket is not locked. We are protected from async events
@@ -328,20 +332,21 @@ __poll_t dccp_poll(struct file *file, struct socket *sock,
328332
*/
329333

330334
mask = 0;
331-
if (sk->sk_err)
335+
if (READ_ONCE(sk->sk_err))
332336
mask = EPOLLERR;
337+
shutdown = READ_ONCE(sk->sk_shutdown);
333338

334-
if (sk->sk_shutdown == SHUTDOWN_MASK || sk->sk_state == DCCP_CLOSED)
339+
if (shutdown == SHUTDOWN_MASK || state == DCCP_CLOSED)
335340
mask |= EPOLLHUP;
336-
if (sk->sk_shutdown & RCV_SHUTDOWN)
341+
if (shutdown & RCV_SHUTDOWN)
337342
mask |= EPOLLIN | EPOLLRDNORM | EPOLLRDHUP;
338343

339344
/* Connected? */
340-
if ((1 << sk->sk_state) & ~(DCCPF_REQUESTING | DCCPF_RESPOND)) {
345+
if ((1 << state) & ~(DCCPF_REQUESTING | DCCPF_RESPOND)) {
341346
if (atomic_read(&sk->sk_rmem_alloc) > 0)
342347
mask |= EPOLLIN | EPOLLRDNORM;
343348

344-
if (!(sk->sk_shutdown & SEND_SHUTDOWN)) {
349+
if (!(shutdown & SEND_SHUTDOWN)) {
345350
if (sk_stream_is_writeable(sk)) {
346351
mask |= EPOLLOUT | EPOLLWRNORM;
347352
} else { /* send SIGIO later */
@@ -359,7 +364,6 @@ __poll_t dccp_poll(struct file *file, struct socket *sock,
359364
}
360365
return mask;
361366
}
362-
363367
EXPORT_SYMBOL_GPL(dccp_poll);
364368

365369
int dccp_ioctl(struct sock *sk, int cmd, int *karg)

0 commit comments

Comments
 (0)