bpf: Reject negative optlen in cgroup getsockopt hook
Status from this message: This series was applied to bpf/bpf-next.git (master)
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 Latest2 patches 1 replyApplied 2/2
- v11 patch 3 repliesSuperseded
Changes in v2 from the cover letter
- Add the selftest for negative optlen.
- Add Emil's Reviewed-by tag.
- Add Reported-by tag.
Patches in v2 All 2 applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | bpf: Reject negative optlen in cgroup getsockopt hookkernel/ | +1 | 0 replies | Applied |
| 2/2 | selftests/bpf: Exercise negative optlen in cgroup getsockopt hooktools/ | +22 | 1 reply | Applied |
Reviews trailers per patch
1 of 2 patches has a Reviewed-by or Acked-by.
| Patch | Emil Tsalapatis |
|---|---|
| 1/2 | R-b |
| 2/2 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH bpf v2 0/2] bpf: Reject negative optlen in cgroup getsockopt hook
A cgroup getsockopt BPF program can set a negative optlen after the kernel getsockopt handler has run. For TCP_ZEROCOPY_RECEIVE, the kernel-buffer hook did not validate the lower bound and the negative value could reach copy_to_sockptr() as a size_t.
Patch 1 rejects negative optlen values in the kernel-buffer hook. Patch 2 adds a test_progs selftest that reproduces the issue through TCP_ZEROCOPY_RECEIVE.
For patch 2, the userspace-visible errno is EFAULT on both fixed and unfixed kernels, so the broken behavior cannot be detected from the getsockopt() return value alone. The selftest exercises the problematic path and can be used to reproduce the hardened usercopy warning on unpatched kernels.
Changelog:
v1 -> v2:
- Add the selftest for negative optlen.
- Add Emil's Reviewed-by tag.
- Add Reported-by tag.
v1: https://lore.kernel.org/bpf/[email protected]/T/
Junseo Lim (2):
bpf: Reject negative optlen in cgroup getsockopt hook selftests/bpf: Exercise negative optlen in cgroup getsockopt hook
kernel/bpf/cgroup.c | 2 +- .../selftests/bpf/prog_tests/sockopt.c | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-)
Signature · 1 line
2.55.0