diff options
| author | Jakub Sitnicki <jakub@cloudflare.com> | 2026-10-30 13:01:54 +0100 |
|---|---|---|
| committer | Alexei Starovoitov <ast@kernel.org> | 2026-10-31 20:50:56 +0000 |
| commit | bcd07fd1673beb873e2bee2731e4ef4d716e70c7 (patch) | |
| tree | 4413d6bf5129352a2020195dfea3c17aa163031b /scripts | |
| parent | 23503acb214cbefaf3945d05ab9667ff11ae3de9 (diff) | |
| download | linux-bcd07fd1673beb873e2bee2731e4ef4d716e70c7.tar.gz linux-bcd07fd1673beb873e2bee2731e4ef4d716e70c7.zip | |
bpf, sockmap: Fix psock update-side data races on sk->sk_prot and progs
The update side of the sockmap psock lifecycle has several unsynchronized
accesses to sk->sk_prot and psock prog state that KCSAN flags when the
new update-vs-delete race selftest runs. The fix comes from Alexei [1]:
* sock_map_link() installed psock programs and called sock_map_init_proto()
before taking sk->sk_callback_lock, racing a concurrent teardown's
tcp_bpf_update_proto() write of sk->sk_prot. Take the write_lock early,
before psock_set_prog() and sock_map_init_proto(), and drop the
psock->saved_data_ready gating from prog detection (it is re-checked
under the lock before stopping progs).
* sock_map_del_link() read psock->saved_data_ready outside the lock. Move
the saved_data_ready check under write_lock_bh(&sk->sk_callback_lock)
so prog teardown is serialized against the proto restore.
* sock_map_psock_get_checked() and sock_map_sk_is_suitable() did plain
sk->sk_prot reads. Convert to READ_ONCE() to mark the intentional racy
read against the WRITE_ONCE() swap in sock_replace_proto().
With these changes the sock_map_link/psock_set_prog side of the reported
KCSAN splats is silenced; the remaining teardown-vs-core-TCP pairings
are the separate read-side annotation problem.
[1] https://lore.kernel.org/bpf/DMBHB0TQOV1L.38MECMYFGUS5B@gmail.com
Suggested-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261030-bpf-next-v1-2-035eabf8eae7@cloudflare.com
Diffstat (limited to 'scripts')
0 files changed, 0 insertions, 0 deletions
