Re: [PATCH v1 net 11/16] net: Fix a data-race around sysctl_mem.

From
Steven Rostedt <rostedt@goodmis.org>
Date
2022-07-06 13:17:35
Also in
lkml
Reply to
Kuniyuki Iwashima, 2022-07-06
On Tue, 5 Jul 2022 22:21:25 -0700
Kuniyuki Iwashima [off-list ref] wrote:
quoted hunk ↗ jump to hunk
--- a/include/trace/events/sock.h
+++ b/include/trace/events/sock.h
@@ -122,9 +122,9 @@ TRACE_EVENT(sock_exceed_buf_limit,
 
 	TP_printk("proto:%s sysctl_mem=%ld,%ld,%ld allocated=%ld sysctl_rmem=%d rmem_alloc=%d sysctl_wmem=%d wmem_alloc=%d wmem_queued=%d kind=%s",
 		__entry->name,
-		__entry->sysctl_mem[0],
-		__entry->sysctl_mem[1],
-		__entry->sysctl_mem[2],
+		READ_ONCE(__entry->sysctl_mem[0]),
+		READ_ONCE(__entry->sysctl_mem[1]),
+		READ_ONCE(__entry->sysctl_mem[2]),
This is not reading anything to do with sysctl. It's reading the content of
what was recorded in the ring buffer.

That is, the READ_ONCE() here is not necessary, and if anything will break
user space parsing, as this is exported to user space to tell it how to
read the binary format in the ring buffer.

-- Steve

 		__entry->allocated,
 		__entry->sysctl_rmem,
 		__entry->rmem_alloc,
Thread (22 messages) 22 messages, 3 authors, last reply 2022-07-06
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help