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 <martin.lau@xxxxxxxxxx> 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(-) -- 2.40.0.634.g4ca3ef3211-goog