Skip to content

bpf: handle another corner case in getsockopt

Stanislav Fomichev bpf oe-kbuild-all 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest6 patches 8 repliesIn review 2 of 6 applied

Patches in v1 2 of 6 applied

#Subject and filesSizeRepliesApplied
1/6bpf: Don't EFAULT for getsockopt with optval=NULLkernel/bpf/cgroup.c+6 -30 repliesApplied
2/6selftests/bpf: Verify optval=NULL casetools/testing/selftests/bpf/prog_tests/sockopt_sk.c tools/testing/selftests/bpf/progs/sockopt_sk.c+40 -00 repliesApplied
3/6bpf: Don't EFAULT for {g,s}setsockopt with wrong optlenkernel/bpf/cgroup.c+6 -27 replies
4/6selftests/bpf: Update EFAULT {g,s}etsockopt selfteststools/testing/selftests/bpf/prog_tests/sockopt.c+13 -290 replies
5/6selftests/bpf: Correctly handle optlen > 4096tools/testing/selftests/bpf/progs/cgroup_getset_retval_getsockopt.c tools/testing/selftests/bpf/progs/cgroup_getset_retval_setsockopt.c tools/testing/selftests/bpf/progs/sockopt_inherit.c +3 more+88 -130 replies
6/6bpf: Document EFAULT changes for sockoptDocumentation/bpf/prog_cgroup_sockopt.rst+60 -41 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH bpf-next 0/6] bpf: handle another corner case in getsockopt

Martin reports another case where getsockopt EFAULTs perfectly valid callers. Let's fix it and also replace EFAULT with pr_info_ratelimited. That should hopefully make this place less error prone.

First 2 patches fix the issue with NETLINK_LIST_MEMBERSHIPS and test it.

Second 2 patches replace EFAULT with pr_inro_limited and update the tests.

The remaining patches update documentation and existing selftests to be more gentle with 'optlen > 4096' cases. People might be copy-pasting from there, so let's be more pedantic.

Cc Martin KaFai Lau <[email protected]>

Stanislav Fomichev (6):
bpf: Don't EFAULT for getsockopt with optval=NULL selftests/bpf: Verify optval=NULL case
bpf: Don't EFAULT for {g,s}setsockopt with wrong optlen selftests/bpf: Update EFAULT {g,s}etsockopt selftests selftests/bpf: Correctly handle optlen > 4096
bpf: Document EFAULT changes for sockopt

 Documentation/bpf/prog_cgroup_sockopt.rst     | 64 +++++++++++++++++--
 kernel/bpf/cgroup.c                           | 17 +++--
 .../selftests/bpf/prog_tests/sockopt.c        | 42 ++++--------
 .../selftests/bpf/prog_tests/sockopt_sk.c     | 28 ++++++++
 .../progs/cgroup_getset_retval_getsockopt.c   | 12 ++++
 .../progs/cgroup_getset_retval_setsockopt.c   | 16 +++++
 .../selftests/bpf/progs/sockopt_inherit.c     | 16 ++++-
 .../selftests/bpf/progs/sockopt_multi.c       | 24 ++++++-
 .../selftests/bpf/progs/sockopt_qos_to_cc.c   |  8 ++-
 .../testing/selftests/bpf/progs/sockopt_sk.c  | 33 ++++++++--
 10 files changed, 211 insertions(+), 49 deletions(-)
Signature · 1 line
2.40.0.634.g4ca3ef3211-goog