Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A94F31A556 for ; Wed, 24 Jun 2026 16:36:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782318982; cv=none; b=qgqV8OJdYH21IaNlkUpFATXnbxhmr3nO2y7tPrpfe94TouniqdnOwlf0JVfVVKs4NoBACPoqgpiXRltHRYwThv7XUM9Z+jvSkYIPtVhGCUTQyxLzh6XjJyo/PvPNM29uxBcM5tMZ2LAiXJ5RSSMGoLkl3Uy5/Yq0ikuHeogvIx8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782318982; c=relaxed/simple; bh=ygWlj6UF3SEUV5crw+gXtRmlnI3aM1+HlzmuzjYTfUU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=eJfSmzgU7d1z78KiDIHk4E1Pb4RLwH+JJBi6k2bVYfTROkQtqY9IJAwu51k7zq5aqJ7yiOtQc6g4QmcXSquyFB4upa7GKy8ZG7+/NngPAZaWaIXq2Mx3WCAuFP4NO5AjVzY2TqC3PrxFoP0/rusPdjygiRlaOAVyZWQlHRMLEMs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=nsOn5bEV; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="nsOn5bEV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 541981F000E9; Wed, 24 Jun 2026 16:36:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1782318979; bh=sTwmN+FtpmM0Efj5mOXJiCrmJR0vAOIfFEjzNXmETjE=; h=From:To:Cc:Subject:Date:Reply-To; b=nsOn5bEV7gUEfh+zi5ms0bbhZwLwKiT2EiVaemqHSJ0OJacdzomoqP/SWklMvNU3U Rd2+SXQlX/GmuzpRlgn7fT7Veny9ieo/N2S0bWeXyQflxaIXrrCKEmF0oKEOBVWdfW 6jWLuv+DUGXw5QdFtR9yTVb4a+/gqo7YzqO/pnGE= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2026-53034: bpf, sockmap: Fix af_unix null-ptr-deref in proto update Date: Wed, 24 Jun 2026 17:30:58 +0100 Message-ID: <2026062455-CVE-2026-53034-c0bb@gregkh> X-Mailer: git-send-email 2.54.0 Reply-To: , Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=9742; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=TkxdE0EXxlHreG0CqiT6nhGFn5kvPJ5flfOECr3+MKA=; b=owGbwMvMwCRo6H6F97bub03G02pJDFk2bMx+JknBl07v9e1pPHfUKvl0e0qzj7/p+bTXPuuc7 VJ8wjw6YlkYBJkYZMUUWb5s4zm6v+KQopeh7WmYOaxMIEMYuDgFYCLsjgwLlp858WyLr4NV2vX5 S3crtGz+eUfyGMOCKd72m0TEE0pfiFwLkOUurShNeC8GAA== X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit From: Greg Kroah-Hartman Description =========== In the Linux kernel, the following vulnerability has been resolved: bpf, sockmap: Fix af_unix null-ptr-deref in proto update unix_stream_connect() sets sk_state (`WRITE_ONCE(sk->sk_state, TCP_ESTABLISHED)`) _before_ it assigns a peer (`unix_peer(sk) = newsk`). sk_state == TCP_ESTABLISHED makes sock_map_sk_state_allowed() believe that socket is properly set up, which would include having a defined peer. IOW, there's a window when unix_stream_bpf_update_proto() can be called on socket which still has unix_peer(sk) == NULL. CPU0 bpf CPU1 connect -------- ------------ WRITE_ONCE(sk->sk_state, TCP_ESTABLISHED) sock_map_sk_state_allowed(sk) ... sk_pair = unix_peer(sk) sock_hold(sk_pair) sock_hold(newsk) smp_mb__after_atomic() unix_peer(sk) = newsk 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 Initial idea was to move peer assignment _before_ the sk_state update[1], but that involved an additional memory barrier, and changing the hot path was rejected. Then a NULL check during proto update in unix_stream_bpf_update_proto() was considered[2], but the follow-up discussion[3] focused on the root cause, i.e. sockmap update taking a wrong lock. Or, more specifically, missing unix_state_lock()[4]. In the end it was concluded that teaching sockmap about the af_unix locking would be unnecessarily complex[5]. Complexity aside, since BPF_PROG_TYPE_SCHED_CLS and BPF_PROG_TYPE_SCHED_ACT are allowed to update sockmaps, sock_map_update_elem() taking the unix lock, as it is currently implemented in unix_state_lock(): spin_lock(&unix_sk(s)->lock), would be problematic. unix_state_lock() taken in a process context, followed by a softirq-context TC BPF program attempting to take the same spinlock -- deadlock[6]. This way we circled back to the peer check idea[2]. [1]: https://lore.kernel.org/netdev/ba5c50aa-1df4-40c2-ab33-a72022c5a32e@rbox.co/ [2]: https://lore.kernel.org/netdev/20240610174906.32921-1-kuniyu@amazon.com/ [3]: https://lore.kernel.org/netdev/7603c0e6-cd5b-452b-b710-73b64bd9de26@linux.dev/ [4]: https://lore.kernel.org/netdev/CAAVpQUA+8GL_j63CaKb8hbxoL21izD58yr1NvhOhU=j+35+3og@mail.gmail.com/ [5]: https://lore.kernel.org/bpf/CAAVpQUAHijOMext28Gi10dSLuMzGYh+jK61Ujn+fZ-wvcODR2A@mail.gmail.com/ [6]: https://lore.kernel.org/bpf/dd043c69-4d03-46fe-8325-8f97101435cf@linux.dev/ Summary of scenarios where af_unix/stream connect() may race a sockmap update: 1. connect() vs. bpf(BPF_MAP_UPDATE_ELEM), i.e. sock_map_update_elem_sys() Implemented NULL check is sufficient. Once assigned, socket peer won't be released until socket fd is released. And that's not an issue because sock_map_update_elem_sys() bumps fd refcnf. 2. connect() vs BPF program doing update Update restricted per verifier.c:may_update_sockmap() to BPF_PROG_TYPE_TRACING/BPF_TRACE_ITER BPF_PROG_TYPE_SOCK_OPS (bpf_sock_map_update() only) BPF_PROG_TYPE_SOCKET_FILTER BPF_PROG_TYPE_SCHED_CLS BPF_PROG_TYPE_SCHED_ACT BPF_PROG_TYPE_XDP BPF_PROG_TYPE_SK_REUSEPORT BPF_PROG_TYPE_FLOW_DISSECTOR BPF_PROG_TYPE_SK_LOOKUP Plus one more race to consider: CPU0 bpf CPU1 connect -------- ------------ WRITE_ONCE(sk->sk_state, TCP_ESTABLISHED) sock_map_sk_state_allowed(sk) sock_hold(newsk) smp_mb__after_atomic() unix_peer(sk) = newsk sk_pair = unix_peer(sk) if (unlikely(!sk_pair)) return -EINVAL; CPU1 close ---------- skpair = unix_peer(sk); unix_peer(sk) = NULL; sock_put(skpair) // use after free? sock_hold(sk_pair) 2.1 BPF program invoking helper function bpf_sock_map_update() -> BPF_CALL_4(bpf_sock_map_update(), ...) Helper limited to BPF_PROG_TYPE_SOCK_OPS. Nevertheless, a unix sock might be accessible via bpf_map_lookup_elem(). Which implies sk already having psock, which in turn implies sk already having sk_pair. Since sk_psock_destroy() is queued as RCU work, sk_pair won't go away while BPF executes the update. 2.2 BPF program invoking helper function bpf_map_update_elem() -> sock_map_update_elem() 2.2.1 Unix sock accessible to BPF prog only via sockmap lookup in BPF_PROG_TYPE_SOCKET_FILTER, BPF_PROG_TYPE_SCHED_CLS, BPF_PROG_TYPE_SCHED_ACT, BPF_PROG_TYPE_XDP, BPF_PROG_TYPE_SK_REUSEPORT, BPF_PROG_TYPE_FLOW_DISSECTOR, BPF_PROG_TYPE_SK_LOOKUP. Pretty much the same as case 2.1. 2.2.2 Unix sock accessible to BPF program directly: BPF_PROG_TYPE_TRACING, narrowed down to BPF_TRACE_ITER. Sockmap iterator (sock_map_seq_ops) is safe: unix sock residing in a sockmap means that the sock already went through the proto update step. Unix sock iterator (bpf_iter_unix_seq_ops), on the other hand, gives access to socks that may still be unconnected. Which means iterator prog can race sockmap/proto update against connect(). BUG: KASAN: null-ptr-deref in unix_stream_bpf_update_proto+0x253/0x4d0 Write of size 4 at addr 0000000000000080 by task test_progs/3140 Call Trace: dump_stack_lvl+0x5d/0x80 kasan_report+0xe4/0x1c0 kasan_check_range+0x125/0x200 unix_stream_bpf_update_proto+0x253/0x4d0 sock_map_link+0x71c/0xec0 sock_map_update_common+0xbc/0x600 sock_map_update_elem+0x19a/0x1f0 bpf_prog_bbbf56096cdd4f01_selective_dump_unix+0x20c/0x217 bpf_iter_run_prog+0x21e/0xae0 bpf_iter_unix_seq_show+0x1e0/0x2a0 bpf_seq_read+0x42c/0x10d0 vfs_read+0x171/0xb20 ksys_read+0xff/0x200 do_syscall_64+0xf7/0x5e0 entry_SYSCALL_64_after_hwframe+0x76/0x7e While the introduced NULL check prevents null-ptr-deref in the BPF program path as well, it is insufficient to guard against a poorly timed close() leading to a use-after-free. This will be addressed in a subsequent patch. The Linux kernel CVE team has assigned CVE-2026-53034 to this issue. Affected and fixed versions =========================== Issue introduced in 5.15 with commit c63829182c37c2d6d0608976d15fa61ebebe9e6b and fixed in 6.1.175 with commit 75b7d3b3f8bd4e59eb3af1b11a43c64c0c2db6f4 Issue introduced in 5.15 with commit c63829182c37c2d6d0608976d15fa61ebebe9e6b and fixed in 6.6.141 with commit a94d3dd78ee8b63e6b8ad629081c952c93ee5a10 Issue introduced in 5.15 with commit c63829182c37c2d6d0608976d15fa61ebebe9e6b and fixed in 6.12.91 with commit 4913c94a3adcdbb64c552110c0c243cb1fdbb317 Issue introduced in 5.15 with commit c63829182c37c2d6d0608976d15fa61ebebe9e6b and fixed in 6.18.33 with commit 041eb6348d73ee5e15fc8161f1eac5a6e8289ca0 Issue introduced in 5.15 with commit c63829182c37c2d6d0608976d15fa61ebebe9e6b and fixed in 7.0.10 with commit 37bfcd164161b47d00b1c3bd20adc816a6977ce0 Issue introduced in 5.15 with commit c63829182c37c2d6d0608976d15fa61ebebe9e6b and fixed in 7.1 with commit dca38b7734d2ea00af4818ff3ae836fab33d5d5a Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community. Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at https://cve.org/CVERecord/?id=CVE-2026-53034 will be updated if fixes are backported, please check that for the most up to date information about this issue. Affected files ============== The file(s) affected by this issue are: net/unix/unix_bpf.c Mitigation ========== The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits: https://git.kernel.org/stable/c/75b7d3b3f8bd4e59eb3af1b11a43c64c0c2db6f4 https://git.kernel.org/stable/c/a94d3dd78ee8b63e6b8ad629081c952c93ee5a10 https://git.kernel.org/stable/c/4913c94a3adcdbb64c552110c0c243cb1fdbb317 https://git.kernel.org/stable/c/041eb6348d73ee5e15fc8161f1eac5a6e8289ca0 https://git.kernel.org/stable/c/37bfcd164161b47d00b1c3bd20adc816a6977ce0 https://git.kernel.org/stable/c/dca38b7734d2ea00af4818ff3ae836fab33d5d5a