[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20260207-unix-proto-update-null-ptr-deref-v2-0-9f091330e7cd@rbox.co>
Date: Sat, 07 Feb 2026 15:34:53 +0100
From: Michal Luczaj <mhal@...x.co>
To: John Fastabend <john.fastabend@...il.com>,
Jakub Sitnicki <jakub@...udflare.com>,
Kuniyuki Iwashima <kuniyu@...gle.com>,
"David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Simon Horman <horms@...nel.org>, Daniel Borkmann <daniel@...earbox.net>,
Willem de Bruijn <willemb@...gle.com>, Cong Wang <cong.wang@...edance.com>,
Alexei Starovoitov <ast@...nel.org>, Yonghong Song <yhs@...com>,
Andrii Nakryiko <andrii@...nel.org>, Eduard Zingerman <eddyz87@...il.com>,
Martin KaFai Lau <martin.lau@...ux.dev>, Song Liu <song@...nel.org>,
Yonghong Song <yonghong.song@...ux.dev>, KP Singh <kpsingh@...nel.org>,
Stanislav Fomichev <sdf@...ichev.me>, Hao Luo <haoluo@...gle.com>,
Jiri Olsa <jolsa@...nel.org>, Shuah Khan <shuah@...nel.org>
Cc: netdev@...r.kernel.org, bpf@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org,
Michal Luczaj <mhal@...x.co>
Subject: [PATCH bpf v2 0/4] bpf, sockmap: Fix af_unix null-ptr-deref in
proto update
BPF_MAP_UPDATE_ELEM races unix_stream_connect(): when
sock_map_sk_state_allowed() passes (sk_state == TCP_ESTABLISHED),
unix_peer(sk) in unix_stream_bpf_update_proto() may still return NULL.
BUG: kernel NULL pointer dereference, address: 0000000000000080
RIP: 0010:unix_stream_bpf_update_proto+0xa0/0x1b0
Call Trace:
sock_map_link+0x564/0x8b0
sock_map_update_common+0x6e/0x340
sock_map_update_elem_sys+0x17d/0x240
__sys_bpf+0x26db/0x3250
__x64_sys_bpf+0x21/0x30
do_syscall_64+0x6b/0x3a0
entry_SYSCALL_64_after_hwframe+0x76/0x7e
Series fixes the null-ptr-deref by teaching sockmap about the
af_unix-specific locking. Accidentally this also fixes a deadlock.
Signed-off-by: Michal Luczaj <mhal@...x.co>
---
Changes in v2:
- Instead of probing for unix peer, make sockmap take the right lock [Martin]
- Annotate data races [Kaniyuki, Martin]
- Extend bpf unix iter selftest to attempt a deadlock
- Link to v1: https://lore.kernel.org/r/20260129-unix-proto-update-null-ptr-deref-v1-1-e1daeb7012fd@rbox.co
---
Michal Luczaj (4):
bpf, sockmap: Annotate af_unix sock::sk_state data-races
bpf, sockmap: Use sock_map_sk_{acquire,release}() where open-coded
bpf, sockmap: Adapt for the af_unix-specific lock
selftests/bpf: Extend bpf_iter_unix to attempt deadlocking
net/core/sock_map.c | 72 +++++++++++++++--------
tools/testing/selftests/bpf/progs/bpf_iter_unix.c | 10 ++++
2 files changed, 58 insertions(+), 24 deletions(-)
---
base-commit: 2687c848e57820651b9f69d30c4710f4219f7dbf
change-id: 20260129-unix-proto-update-null-ptr-deref-6a2733bcbbf8
Best regards,
--
Michal Luczaj <mhal@...x.co>
Powered by blists - more mailing lists