bpf: Fix overlapping copies in bpf_dynptr_copy()
Status from this message: This series was applied to bpf/bpf.git (master)
Get series with b4
b4 am [email protected]Versions newest first
Changes in v2 from the cover letter
- Dropped the bpf_xdp_copy_buf() change and fixed everything in bpf_dynptr_copy(), as suggested by Alexei
- Reworked the tests into bpf_dynptr_copy() tests where only one of the ranges crosses into frag0
Patches in v2 All 2 applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | bpf: Fix bpf_dynptr_copy() for overlapping ranges in one packetkernel/ | +12 | 0 replies | Applied |
| 2/2 | selftests/bpf: Test overlapping dynptr copies on xdp fragstools/ tools/ | +93 | 0 replies | Applied |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.
Cover letter [PATCH bpf v2 0/2] bpf: Fix overlapping copies in bpf_dynptr_copy()
bpf_dynptr_copy() can corrupt data when both ranges are in the same xdp packet and overlap: a slice of one range is used as the buffer for __bpf_dynptr_read() or __bpf_dynptr_write(), and the chunk loop always copies forward.
Patch 1 does not use a slice as the buffer for a copy within one packet and copies from the end when the destination is above the source. Patch 2 adds selftests. They pass with the fix.
Changes in v2:
- Dropped the bpf_xdp_copy_buf() change and fixed everything in bpf_dynptr_copy(), as suggested by Alexei
- Reworked the tests into bpf_dynptr_copy() tests where only one of the ranges crosses into frag0
v1: https://lore.kernel.org/bpf/[email protected]/
Ayushman Rout (2):
bpf: Fix bpf_dynptr_copy() for overlapping ranges in one packet selftests/bpf: Test overlapping dynptr copies on xdp frags
kernel/bpf/helpers.c | 16 +++- .../testing/selftests/bpf/prog_tests/dynptr.c | 3 + .../selftests/bpf/progs/dynptr_success.c | 90 +++++++++++++++++++ 3 files changed, 105 insertions(+), 4 deletions(-)
Signature · 1 line
2.54.0