bpf: Free reuseport cBPF prog after RCU grace period.
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ 538950a1b7527a0a52ccd9337e3fcd304f027f13 · < 87dfb977bdb6eaa47e9993a34e18f44970f88b1f| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
bpf: Free reuseport cBPF prog after RCU grace period.
Eulgyu Kim reported the splat below with a repro. [0]
The repro sets up a UDP reuseport group with a cBPF prog and replaces it with a new one while another thread is sending a UDP packet to the group.
The reuseport prog is freed by sk_reuseport_prog_free(). bpf_prog_put() is called for "e"BPF prog to destruct through multiple stages while cBPF prog is freed immediately by bpf_release_orig_filter() and bpf_prog_free().
If a reuseport prog is detached from the setsockopt() path (reuseport_attach_prog() or reuseport_detach_prog()), sk_reuseport_prog_free() is called without waiting for RCU readers to complete, resulting in various bugs.
Let's defer freeing the reuseport cBPF prog after one RCU grace period.
Note "e"BPF prog is safe as is unless the fast path starts to touch fields destroyed in bpf_prog_put_deferred() and __bpf_prog_put_noref().
From the CVE record · Linux
The Linux kernel can free a UDP reuseport cBPF program before RCU readers finish using it. This can cause memory-access errors when a program is replaced or detached through setsockopt while another thread sends a UDP packet to the group. The input does not establish authentication requirements or a remote attack path.
Engineers running Linux kernels with UDP reuseport cBPF programs should check their kernel versions; affected versions are not specified.