mbox series

[bpf-next,0/6] bpf: handle another corner case in getsockopt

Message ID 20230418225343.553806-1-sdf@google.com (mailing list archive)
Headers show
Series bpf: handle another corner case in getsockopt | expand

Message

Stanislav Fomichev April 18, 2023, 10:53 p.m. UTC
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@kernel.org>

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(-)

Comments

patchwork-bot+netdevbpf@kernel.org April 21, 2023, 3:20 p.m. UTC | #1
Hello:

This series was applied to bpf/bpf-next.git (master)
by Daniel Borkmann <daniel@iogearbox.net>:

On Tue, 18 Apr 2023 15:53:37 -0700 you wrote:
> 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.
> 
> [...]

Here is the summary with links:
  - [bpf-next,1/6] bpf: Don't EFAULT for getsockopt with optval=NULL
    https://git.kernel.org/bpf/bpf-next/c/00e74ae08638
  - [bpf-next,2/6] selftests/bpf: Verify optval=NULL case
    https://git.kernel.org/bpf/bpf-next/c/833d67ecdc5f
  - [bpf-next,3/6] bpf: Don't EFAULT for {g,s}setsockopt with wrong optlen
    (no matching commit)
  - [bpf-next,4/6] selftests/bpf: Update EFAULT {g,s}etsockopt selftests
    (no matching commit)
  - [bpf-next,5/6] selftests/bpf: Correctly handle optlen > 4096
    (no matching commit)
  - [bpf-next,6/6] bpf: Document EFAULT changes for sockopt
    (no matching commit)

You are awesome, thank you!