public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next v2 0/4] bpf: Don't EFAULT for {g,s}setsockopt with wrong optlen
@ 2023-04-27 20:04 Stanislav Fomichev
  2023-04-27 20:04 ` [PATCH bpf-next v2 1/4] " Stanislav Fomichev
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: Stanislav Fomichev @ 2023-04-27 20:04 UTC (permalink / raw)
  To: bpf
  Cc: ast, daniel, andrii, martin.lau, song, yhs, john.fastabend,
	kpsingh, sdf, haoluo, jolsa

optval larger than PAGE_SIZE leads to EFAULT if the BPF program
isn't careful enough. This is often overlooked and might break
completely unrelated socket options. Instead of EFAULT,
let's ignore BPF program buffer changes. See the first patch for
more info.

In addition, clearly document this corner case and reset optlen
in our selftests (in case somebody copy-pastes from them).

Stanislav Fomichev (4):
  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     | 57 ++++++++++++-
 kernel/bpf/cgroup.c                           | 12 +++
 .../selftests/bpf/prog_tests/sockopt.c        | 80 +++++++++++++++++--
 .../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  | 25 ++++--
 9 files changed, 230 insertions(+), 20 deletions(-)

-- 
2.40.1.495.gc816e09b53d-goog


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2023-05-01 19:37 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-27 20:04 [PATCH bpf-next v2 0/4] bpf: Don't EFAULT for {g,s}setsockopt with wrong optlen Stanislav Fomichev
2023-04-27 20:04 ` [PATCH bpf-next v2 1/4] " Stanislav Fomichev
2023-05-01  5:51   ` Martin KaFai Lau
2023-05-01 16:55     ` Stanislav Fomichev
2023-05-01 18:58       ` Martin KaFai Lau
2023-05-01 19:33         ` Stanislav Fomichev
2023-04-27 20:04 ` [PATCH bpf-next v2 2/4] selftests/bpf: Update EFAULT {g,s}etsockopt selftests Stanislav Fomichev
2023-04-28 23:57   ` Martin KaFai Lau
2023-04-28 23:59     ` Stanislav Fomichev
2023-04-29  0:32       ` Stanislav Fomichev
2023-04-29  0:44         ` Martin KaFai Lau
2023-05-01 17:22           ` Stanislav Fomichev
2023-05-01 19:04             ` Martin KaFai Lau
2023-04-27 20:04 ` [PATCH bpf-next v2 3/4] selftests/bpf: Correctly handle optlen > 4096 Stanislav Fomichev
2023-04-27 20:04 ` [PATCH bpf-next v2 4/4] bpf: Document EFAULT changes for sockopt Stanislav Fomichev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox