]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
net: Drop the lock in skb_may_tx_timestamp()
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Fri, 20 Feb 2026 18:38:58 +0000 (19:38 +0100)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 24 Feb 2026 10:27:29 +0000 (11:27 +0100)
commit983512f3a87fd8dc4c94dfa6b596b6e57df5aad7
tree2bcf18f6c41ddaa5d75811ed9061b6fafa2ceef0
parent82aec772fca2223bc5774bd9af486fd95766e578
net: Drop the lock in skb_may_tx_timestamp()

skb_may_tx_timestamp() may acquire sock::sk_callback_lock. The lock must
not be taken in IRQ context, only softirq is okay. A few drivers receive
the timestamp via a dedicated interrupt and complete the TX timestamp
from that handler. This will lead to a deadlock if the lock is already
write-locked on the same CPU.

Taking the lock can be avoided. The socket (pointed by the skb) will
remain valid until the skb is released. The ->sk_socket and ->file
member will be set to NULL once the user closes the socket which may
happen before the timestamp arrives.
If we happen to observe the pointer while the socket is closing but
before the pointer is set to NULL then we may use it because both
pointer (and the file's cred member) are RCU freed.

Drop the lock. Use READ_ONCE() to obtain the individual pointer. Add a
matching WRITE_ONCE() where the pointer are cleared.

Link: https://lore.kernel.org/all/20260205145104.iWinkXHv@linutronix.de
Fixes: b245be1f4db1a ("net-timestamp: no-payload only sysctl")
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Reviewed-by: Jason Xing <kerneljasonxing@gmail.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20260220183858.N4ERjFW6@linutronix.de
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
include/net/sock.h
net/core/skbuff.c
net/socket.c