rds: annotate data-race around rs_seen_congestion
Subsystems (4)
PATCH 1/1 rds: annotate data-race around rs_seen_congestion
rs_seen_congestion is read in rds_poll() and written in rds_sendmsg() and rds_poll() without any lock. Use READ_ONCE()/WRITE_ONCE() to annotate these lockless accesses and silence KCSAN.
--- net/rds/af_rds.c | 4 ++-- net/rds/send.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
net/rds/af_rds.c +2 -2
@@ -219,7 +219,7 @@ static __poll_t rds_poll(struct file *file, struct socket *sock,poll_wait (file,sk_sleep (sk), wait); -if (rs->rs_seen_congestion) +if (READ_ONCE (rs->rs_seen_congestion))poll_wait (file, &rds_poll_waitq, wait);read_lock_irqsave (&rs->rs_recv_lock, flags);
@@ -247,7 +247,7 @@ static __poll_t rds_poll(struct file *file, struct socket *sock,/* clear state any time we wake a seen-congested socket */ if (mask) - rs->rs_seen_congestion =0 ; +WRITE_ONCE (rs->rs_seen_congestion,0 );return mask; }
net/rds/send.c +1 -1
@@ -1388,7 +1388,7 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len) ret =rds_cong_wait (conn->c_fcong, dport, nonblock, rs);if (ret) { - rs->rs_seen_congestion =1 ; +WRITE_ONCE (rs->rs_seen_congestion,1 ); goto out; } while (!rds_send_queue_rm(rs, conn, cpath, rm, rs->rs_bound_port,
Signature · 1 line
2.43.0
Quoted 8 lines · Jiayuan Chen
rs_seen_congestionis read inrds_poll()and written inrds_sendmsg()andrds_poll()without any lock. Use READ_ONCE()/WRITE_ONCE() to annotate these lockless accesses and silence KCSAN.Fixes b98ba52f96e7 ("RDS: only put sockets that have seen congestion on the poll_waitq")Reported-by [email protected]Signed-off-by Jiayuan Chen <[email protected]>
Hi Jiayuan,
I was about to send the same patch, so no complaints here. Thanks for catching this.
Allison
Quoted 40 lines
--- net/rds/af_rds.c | 4 ++-- net/rds/send.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)net/rds/af_rds.c +2
-2@@ -219,7 +219,7 @@ static __poll_t rds_poll(struct file *file, struct socket *sock,poll_wait (file,sk_sleep (sk), wait); -if (rs->rs_seen_congestion) +if (READ_ONCE (rs->rs_seen_congestion))poll_wait (file, &rds_poll_waitq, wait);read_lock_irqsave (&rs->rs_recv_lock, flags);@@ -247,7 +247,7 @@ static __poll_t rds_poll(struct file *file, struct socket *sock,/* clear state any time we wake a seen-congested socket */ if (mask) - rs->rs_seen_congestion =0 ; +WRITE_ONCE (rs->rs_seen_congestion,0 );return mask; }net/rds/send.c +1
-1@@ -1388,7 +1388,7 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len) ret =rds_cong_wait (conn->c_fcong, dport, nonblock, rs);if (ret) { - rs->rs_seen_congestion =1 ; +WRITE_ONCE (rs->rs_seen_congestion,1 ); goto out; } while (!rds_send_queue_rm(rs, conn, cpath, rm, rs->rs_bound_port,
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Fri, 22 May 2026 09:16:20 +0800 you wrote:
rs_seen_congestionis read inrds_poll()and written inrds_sendmsg()andrds_poll()without any lock. Use READ_ONCE()/WRITE_ONCE() to annotate these lockless accesses and silence KCSAN.Fixes b98ba52f96e7 ("RDS: only put sockets that have seen congestion on the poll_waitq")Reported-by [email protected]Signed-off-by Jiayuan Chen <[email protected]>[...]
Here is the summary with links:
- [net] rds: annotate data-race around rs_seen_congestion
https://git.kernel.org/netdev/net-next/c/67636cab273e
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html