]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
net: devmem: use READ_ONCE/WRITE_ONCE on binding->dev
authorBobby Eshleman <bobbyeshleman@meta.com>
Tue, 3 Mar 2026 00:32:56 +0000 (16:32 -0800)
committerJakub Kicinski <kuba@kernel.org>
Thu, 5 Mar 2026 01:59:27 +0000 (17:59 -0800)
commit40bf00ec2ee271df5ba67593991760adf8b5d0ed
tree5763550848ee64fcc49883936dbb88d382c9b4f2
parenta4c2b8be2e5329e7fac6e8f64ddcb8958155cfcb
net: devmem: use READ_ONCE/WRITE_ONCE on binding->dev

binding->dev is protected on the write-side in
mp_dmabuf_devmem_uninstall() against concurrent writes, but due to the
concurrent bare reads in net_devmem_get_binding() and
validate_xmit_unreadable_skb() it should be wrapped in a
READ_ONCE/WRITE_ONCE pair to make sure no compiler optimizations play
with the underlying register in unforeseen ways.

Doesn't present a critical bug because the known compiler optimizations
don't result in bad behavior. There is no tearing on u64, and load
omissions/invented loads would only break if additional binding->dev
references were inlined together (they aren't right now).

This just more strictly follows the linux memory model (i.e.,
"Lock-Protected Writes With Lockless Reads" in
tools/memory-model/Documentation/access-marking.txt).

Fixes: bd61848900bf ("net: devmem: Implement TX path")
Signed-off-by: Bobby Eshleman <bobbyeshleman@meta.com>
Link: https://patch.msgid.link/20260302-devmem-membar-fix-v2-1-5b33c9cbc28b@meta.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/core/dev.c
net/core/devmem.c