Skip to content

bpf, sockmap: Restrict iter-context sockmap updates to sockmap iterators

Michal Luczaj bpf linux-doc linux-kselftest lkml netdev sashiko-reviews 3 versions – Applied

Status from this message: This series was applied to bpf/bpf.git (master)

Get series with b4
b4 am [email protected] change-id 20261008-sockmap-update-limit-iter-d03ea25f9775

Versions newest first

  1. v3 Latest8 patches 6 repliesApplied 8/8
  2. v2 RFC4 patches 1 replySuperseded
  3. v13 patches 9 repliesSuperseded

Changes in v3 from the cover letter

- Drop RFC prefix
- Update bpf_iter_reg::feature docs
- Fix tcp_request_sock BTF build error
- Restrict allowed callers of bpf_sock_destroy() to iter/{tcp,udp} (Alexei)
- Link to v2: https://patch.msgid.link/[email protected]

Patches in v3 All 8 applied

#Subject and filesSizeRepliesApplied
1/8selftests/bpf: Remove sockmap update from bpf_iter_unixtools/testing/selftests/bpf/progs/bpf_iter_unix.c+0 -101 replyApplied
2/8bpf, sockmap: Restrict iter-context sockmap updates to iter/sockmapkernel/bpf/verifier.c+3 -11 replyApplied
3/8selftests/bpf: Add negative test for sockmap update from non-sockmap itertools/testing/selftests/bpf/progs/verifier_sockmap_mutate.c+14 -00 repliesApplied
4/8bpf, docs: Document BPF_ITER_NOSLEEPDocumentation/bpf/bpf_iterators.rst+9 -30 repliesApplied
5/8bpf: Restrict bpf_sock_destroy() to iter/{tcp,udp}net/core/filter.c+10 -10 repliesApplied
6/8bpf: Mark bpf_iter__sockmap::sk as PTR_TRUSTEDnet/core/sock_map.c+1 -10 repliesApplied
7/8selftests/bpf: Add iter/sockmap bpf_sock_destroy() negative testtools/testing/selftests/bpf/progs/sock_destroy_prog_fail.c+11 -00 repliesApplied
8/8bpf: Fix "unresolved symbol tcp_request_sock" build errornet/core/filter.c+4 -01 replyApplied

Reviews trailers per patch

2 of 8 patches have a Reviewed-by or Acked-by.

PatchJiayuan Chen
1/8R-b
2/8R-b
3/8
4/8
5/8
6/8
7/8
8/8

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH bpf-next v3 0/8] bpf, sockmap: Restrict iter-context sockmap updates to sockmap iterators

Follow-up to Sashiko's report [1] and the decision to restrict which iterator may perform sockmap updates [2]. Series started short: remove about-to-be-stale test, restrict updates, add a negative test. Then it
expanded: mark bpf_iter__sockmap::sk as PTR_TRUSTED, restrict bpf_sock_destroy() callers to iter/{tcp,udp}, few little tweaks.

[1]: https://msgid.link/[email protected]
[2]: https://msgid.link/[email protected]

---
Changes in v3:
- Drop RFC prefix
- Update bpf_iter_reg::feature docs
- Fix tcp_request_sock BTF build error
- Restrict allowed callers of bpf_sock_destroy() to iter/{tcp,udp} (Alexei)
- Link to v2: https://patch.msgid.link/[email protected]

Changes in v2:
- Commit 7cc639dc45c5 ("bpf: Don't take an extension for an iterator
program") and commit b83bacf2161d ("bpf: Don't take a program with a
target program for an iterator") landed. Drop the redundant
env->prog->type check.
- Mark bpf_iter__sockmap::sk as PTR_TRUSTED (Alexei)
- Link to v1: https://patch.msgid.link/[email protected]

To: Alexei Starovoitov <[email protected]>
To: Daniel Borkmann <[email protected]>
To: Andrii Nakryiko <[email protected]>
To: Eduard Zingerman <[email protected]>
To: Kumar Kartikeya Dwivedi <[email protected]>
To: Martin KaFai Lau <[email protected]>
To: Song Liu <[email protected]>
To: Yonghong Song <[email protected]>
To: Jiri Olsa <[email protected]>
To: Emil Tsalapatis <[email protected]>
To: Ihor Solodrai <[email protected]>
To: Shuah Khan <[email protected]>
To: John Fastabend <[email protected]>
To: Eric Dumazet <[email protected]>
To: Kuniyuki Iwashima <[email protected]>
To: Paolo Abeni <[email protected]>
To: Willem de Bruijn <[email protected]>
To: Jakub Sitnicki <[email protected]>
To: Jiayuan Chen <[email protected]>
To: "David S. Miller" <[email protected]>
To: Jakub Kicinski <[email protected]>
To: Simon Horman <[email protected]>
To: Jonathan Corbet <[email protected]>
To: Shuah Khan <[email protected]>
To: Randy Dunlap <[email protected]>
To: Stanislav Fomichev <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

---
Michal Luczaj (8):
selftests/bpf: Remove sockmap update from bpf_iter_unix
bpf, sockmap: Restrict iter-context sockmap updates to iter/sockmap selftests/bpf: Add negative test for sockmap update from non-sockmap iter bpf, docs: Document BPF_ITER_NOSLEEP
bpf: Restrict bpf_sock_destroy() to iter/{tcp,udp}
bpf: Mark bpf_iter__sockmap::sk as PTR_TRUSTED selftests/bpf: Add iter/sockmap bpf_sock_destroy() negative test
bpf: Fix "unresolved symbol tcp_request_sock" build error

 Documentation/bpf/bpf_iterators.rst                       | 12 +++++++++---
 kernel/bpf/verifier.c                                     |  4 +++-
 net/core/filter.c                                         | 15 ++++++++++++++-
 net/core/sock_map.c                                       |  2 +-
 tools/testing/selftests/bpf/progs/bpf_iter_unix.c         | 10 ----------
 .../testing/selftests/bpf/progs/sock_destroy_prog_fail.c  | 11 +++++++++++
 .../testing/selftests/bpf/progs/verifier_sockmap_mutate.c | 14 ++++++++++++++
 7 files changed, 52 insertions(+), 16 deletions(-)

---
base-commit: 2d0b457611c06304138754a05e0873cc18acfb7e
change-id: 20261008-sockmap-update-limit-iter-d03ea25f9775

Best regards,

Signature · 1 line
Michal Luczaj <[email protected]>