sockmap: Fix use-after-free in udp_bpf_recvmsg()
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ 9f2470fbc4cb4583c080bb729a998933ba61aca4 · < c010995b29c8939c6aa69e3cb26f8dbee163d156| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
sockmap: Fix use-after-free in udp_bpf_recvmsg()
syzbot reported use-after-free of struct sk_msg in sk_msg_recvmsg(). [0]
sk_msg_recvmsg() peeks sk_msg from psock->ingress_msg under a lock, but its processing is lockless.
Thus, sk_msg_recvmsg() must be serialised by callers, otherwise multiple threads could touch the same sk_msg.
For example, TCP uses lock_sock(), and AF_UNIX uses unix_sk(sk)->iolock.
Initially, udp_bpf_recvmsg() had used lock_sock(), but the cited commit removed it.
Let's serialise sk_msg_recvmsg() with lock_sock() in udp_bpf_recvmsg().
From the CVE record · Linux
The Linux kernel's udp_bpf_recvmsg() can trigger a use-after-free when multiple threads process the same socket message concurrently. A local caller making concurrent receive calls can reach the vulnerable path; the input does not establish whether special privileges or configuration are required.
Engineers running the Linux kernel should check whether their kernel includes the affected UDP sockmap code; affected versions are not specified.