Skip to content

bpf: allocate extra memory for setsockopt hook buffer

Stanislav Fomichev bpf netdev 1 version Applied

Status from this message: Applied, Thanks

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 3 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/2bpf: always allocate at least 16 bytes for setsockopt hookkernel/bpf/cgroup.c+13 -40 replies
2/2selftests/bpf: extend sockopt_sk selftest with TCP_CONGESTION use casetools/testing/selftests/bpf/progs/sockopt_sk.c tools/testing/selftests/bpf/test_sockopt_sk.c+47 -00 replies

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/2] bpf: allocate extra memory for setsockopt hook buffer

Current setsockopt hook is limited to the size of the buffer that user had supplied. Since we always allocate memory and copy the value into kernel space, allocate just a little bit more in case BPF program needs to override input data with a larger value.

The canonical example is TCP_CONGESTION socket option where input buffer is a string and if user calls it with a short string, BPF program has no way of extending it.

The tests are extended with TCP_CONGESTION use case.

Stanislav Fomichev (2):
bpf: always allocate at least 16 bytes for setsockopt hook selftests/bpf: extend sockopt_sk selftest with TCP_CONGESTION use case

 kernel/bpf/cgroup.c                           | 17 ++++++++++---
 .../testing/selftests/bpf/progs/sockopt_sk.c  | 22 ++++++++++++++++
 tools/testing/selftests/bpf/test_sockopt_sk.c | 25 +++++++++++++++++++
 3 files changed, 60 insertions(+), 4 deletions(-)
Signature · 1 line
2.22.0.709.g102302147b-goog