Skip to content

RFC bpf_sk_lookup.remote_port fixes

Ilya Leoshkevich bpf 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest3 patches 14 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3bpf: Fix certain narrow loads with offsetskernel/bpf/verifier.c+9 -58 replies
2/3bpf: Fix bpf_sk_lookup.remote_port on big-endianinclude/uapi/linux/bpf.h net/core/filter.c tools/include/uapi/linux/bpf.h+32 -76 replies
3/3selftests/bpf: Adapt bpf_sk_lookup.remote_port loadstools/testing/selftests/bpf/progs/test_sk_lookup.c+11 -60 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [PATCH RFC bpf-next 0/3] bpf_sk_lookup.remote_port fixes

Hi,

These are my current patches for the discussion from [1] and [2].

With these changes tests pass on both x86_64 and s390x, but there are quite a few things I'm not sure about, hence it's just an RFC:

- Can moving size < target_size check lead to incorrect shifts in some corner cases that I missed?

- Are different layouts of remote_port on little- and big-endian a bug or a feature? Do we want things to be this way? If not, are we bound by the ABI anyway?

- Is there any way to make uapi changes look nicer? A wall of nested structs, unions and ifdefs in an otherwise clean struct definition isn't looking particularly good.

- What is the Officially Approved way to access the remote_port field from C code? I'm leaning towards bpf_ntohs((__u16)remote_port), like in [3], and I adjusted the test accordingly.

[1] https://lore.kernel.org/bpf/CAEf4BzaRNLw9_EnaMo5e46CdEkzbJiVU3j9oxnsemBKjNFf3wQ@mail.gmail.com/
[2] https://lore.kernel.org/bpf/[email protected]/
[3] https://lore.kernel.org/bpf/[email protected]/

Ilya Leoshkevich (3):
bpf: Fix certain narrow loads with offsets
bpf: Fix bpf_sk_lookup.remote_port on big-endian selftests/bpf: Adapt bpf_sk_lookup.remote_port loads

 include/uapi/linux/bpf.h                        | 17 +++++++++++++++--
 kernel/bpf/verifier.c                           | 14 +++++++++-----
 net/core/filter.c                               |  5 ++---
 tools/include/uapi/linux/bpf.h                  | 17 +++++++++++++++--
 .../selftests/bpf/progs/test_sk_lookup.c        | 17 +++++++++++------
 5 files changed, 52 insertions(+), 18 deletions(-)
Signature · 1 line
2.34.1