bpf: Reject negative optlen in cgroup getsockopt hook
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ 9cacf81f8161111db25f98e78a7a0e32ae142b3f · < 2bdbe00454200fcb0110f31eeca8d906a3515e74| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
bpf: Reject negative optlen in cgroup getsockopt hook
A cgroup getsockopt BPF program can shrink ctx->optlen after the kernel getsockopt handler has run. The kernel-buffer variant, used by TCP_ZEROCOPY_RECEIVE, only rejects values larger than the original length.
If BPF writes a negative optlen, that value is accepted and propagated back to the TCP getsockopt code. It can then be passed to copy_to_sockptr() as a size_t and trigger the hardened usercopy bytes > INT_MAX warning.
Reject negative ctx.optlen in __cgroup_bpf_run_filter_getsockopt_kern(), matching the lower-bound validation already present in the sockptr-based getsockopt hook.
From the CVE record · Linux
The Linux kernel’s cgroup getsockopt BPF hook accepts a negative optlen from a BPF program when the kernel-buffer variant is used by TCP_ZEROCOPY_RECEIVE. If the program writes a negative value, it can reach copy_to_sockptr() as a size_t and trigger a hardened usercopy warning. The input does not specify attacker access requirements or user interaction.
Anyone running the Linux kernel should check whether their version includes the fix; affected versions are not specified.