bpf: Fix SOCK_OPS_GET_SK same-register OOB read in sock_ops and add selftest
Status from this message: This series was applied to netdev/net.git (main)
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v3 Latest2 patches 2 repliesApplied 2/2
- v22 patches 6 repliesSuperseded
Changes in v3 from the cover letter
https://lore.kernel.org/bpf/[email protected]/
- Addressed selftest review from Martin KaFai Lau: removed unused skel parameter, renamed to test_ns_ for automatic netns, ASSERT_GE -> ASSERT_OK_FD
- Add reviewed-by tags.
Patches in v3 All 2 applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | bpf: Fix same-register dst/src OOB read and pointer leak in sock_opsnet/ | +4 | 1 reply | Applied |
| 2/2 | selftests/bpf: Add tests for sock_ops ctx access with same src/dst registertools/ tools/ | +193 | 0 replies | Applied |
Reviews trailers per patch
All 2 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.
| Patch | Emil Tsalapatis | Sun Jian | Martin KaFai Lau |
|---|---|---|---|
| Series | A-b | ||
| 1/2 | R-b | ||
| 2/2 | R-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.
Cover letter [PATCH bpf v3 0/2] bpf: Fix SOCK_OPS_GET_SK same-register OOB read in sock_ops and add selftest
When a BPF sock_ops program accesses ctx fields with dst_reg == src_reg, the SOCK_OPS_GET_SK() and SOCK_OPS_GET_FIELD() macros fail to zero the destination register in the !fullsock / !locked_tcp_sock path, leading to OOB read (GET_SK) and kernel pointer leak (GET_FIELD).
Patch 1: Fix both macros by adding BPF_MOV64_IMM(si->dst_reg, 0) in the !fullsock landing pad.
Patch 2: Add selftests covering same-register and different-register cases for both GET_SK and GET_FIELD.
[1] https://lore.kernel.org/bpf/[email protected]/T/#u
Changes since v2:
https://lore.kernel.org/bpf/[email protected]/
- Addressed selftest review from Martin KaFai Lau: removed unused skel parameter, renamed to test_ns_ for automatic netns, ASSERT_GE -> ASSERT_OK_FD
- Add reviewed-by tags.
Changes since v1:
https://lore.kernel.org/bpf/[email protected]/
- Fixed the same bug in SOCK_OPS_GET_FIELD() (pointed out by AI review)
- Added SOCK_OPS_GET_FIELD same-register and GET_SK different-register subtests
Jiayuan Chen (2):
bpf: Fix same-register dst/src OOB read and pointer leak in sock_ops selftests/bpf: Add tests for sock_ops ctx access with same src/dst
register
net/core/filter.c | 6 +- .../bpf/prog_tests/sock_ops_get_sk.c | 76 ++++++++++++ .../selftests/bpf/progs/sock_ops_get_sk.c | 117 ++++++++++++++++++ 3 files changed, 197 insertions(+), 2 deletions(-) create mode 100644 tools/testing/selftests/bpf/prog_tests/sock_ops_get_sk.c create mode 100644 tools/testing/selftests/bpf/progs/sock_ops_get_sk.c
Signature · 1 line
2.43.0