Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'for-netdev' of https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf

Daniel Borkmann says:

====================
pull-request: bpf 2023-03-06

We've added 8 non-merge commits during the last 7 day(s) which contain
a total of 9 files changed, 64 insertions(+), 18 deletions(-).

The main changes are:

1) Fix BTF resolver for DATASEC sections when a VAR points at a modifier,
that is, keep resolving such instances instead of bailing out,
from Lorenz Bauer.

2) Fix BPF test framework with regards to xdp_frame info misplacement
in the "live packet" code, from Alexander Lobakin.

3) Fix an infinite loop in BPF sockmap code for TCP/UDP/AF_UNIX,
from Liu Jian.

4) Fix a build error for riscv BPF JIT under PERF_EVENTS=n,
from Randy Dunlap.

5) Several BPF doc fixes with either broken links or external instead
of internal doc links, from Bagas Sanjaya.

* tag 'for-netdev' of https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf:
selftests/bpf: check that modifier resolves after pointer
btf: fix resolving BTF_KIND_VAR after ARRAY, STRUCT, UNION, PTR
bpf, test_run: fix &xdp_frame misplacement for LIVE_FRAMES
bpf, doc: Link to submitting-patches.rst for general patch submission info
bpf, doc: Do not link to docs.kernel.org for kselftest link
bpf, sockmap: Fix an infinite loop error when len is 0 in tcp_bpf_recvmsg_parser()
riscv, bpf: Fix patch_text implicit declaration
bpf, docs: Fix link to BTF doc
====================

Link: https://lore.kernel.org/r/20230306215944.11981-1-daniel@iogearbox.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+64 -18
+5 -9
Documentation/bpf/bpf_devel_QA.rst
··· 7 7 patches for stable kernels. 8 8 9 9 For general information about submitting patches, please refer to 10 - `Documentation/process/`_. This document only describes additional specifics 11 - related to BPF. 10 + Documentation/process/submitting-patches.rst. This document only describes 11 + additional specifics related to BPF. 12 12 13 13 .. contents:: 14 14 :local: ··· 461 461 462 462 $ sudo make run_tests 463 463 464 - See the kernels selftest `Documentation/dev-tools/kselftest.rst`_ 465 - document for further documentation. 464 + See :doc:`kernel selftest documentation </dev-tools/kselftest>` 465 + for details. 466 466 467 467 To maximize the number of tests passing, the .config of the kernel 468 468 under test should match the config file fragment in 469 469 tools/testing/selftests/bpf as closely as possible. 470 470 471 471 Finally to ensure support for latest BPF Type Format features - 472 - discussed in `Documentation/bpf/btf.rst`_ - pahole version 1.16 472 + discussed in Documentation/bpf/btf.rst - pahole version 1.16 473 473 is required for kernels built with CONFIG_DEBUG_INFO_BTF=y. 474 474 pahole is delivered in the dwarves package or can be built 475 475 from source at ··· 684 684 685 685 686 686 .. Links 687 - .. _Documentation/process/: https://www.kernel.org/doc/html/latest/process/ 688 687 .. _netdev-FAQ: Documentation/process/maintainer-netdev.rst 689 688 .. _selftests: 690 689 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/testing/selftests/bpf/ 691 - .. _Documentation/dev-tools/kselftest.rst: 692 - https://www.kernel.org/doc/html/latest/dev-tools/kselftest.html 693 - .. _Documentation/bpf/btf.rst: btf.rst 694 690 695 691 Happy BPF hacking!
+1
arch/riscv/net/bpf_jit_comp64.c
··· 10 10 #include <linux/filter.h> 11 11 #include <linux/memory.h> 12 12 #include <linux/stop_machine.h> 13 + #include <asm/patch.h> 13 14 #include "bpf_jit.h" 14 15 15 16 #define RV_REG_TCC RV_REG_A6
+1
kernel/bpf/btf.c
··· 4569 4569 struct btf *btf = env->btf; 4570 4570 u16 i; 4571 4571 4572 + env->resolve_mode = RESOLVE_TBD; 4572 4573 for_each_vsi_from(i, v->next_member, v->t, vsi) { 4573 4574 u32 var_type_id = vsi->type, type_id, type_size = 0; 4574 4575 const struct btf_type *var_type = btf_type_by_id(env->btf,
+13 -6
net/bpf/test_run.c
··· 97 97 struct xdp_page_head { 98 98 struct xdp_buff orig_ctx; 99 99 struct xdp_buff ctx; 100 - struct xdp_frame frm; 101 - u8 data[]; 100 + union { 101 + /* ::data_hard_start starts here */ 102 + DECLARE_FLEX_ARRAY(struct xdp_frame, frame); 103 + DECLARE_FLEX_ARRAY(u8, data); 104 + }; 102 105 }; 103 106 104 107 struct xdp_test_data { ··· 116 113 u32 frame_cnt; 117 114 }; 118 115 116 + /* tools/testing/selftests/bpf/prog_tests/xdp_do_redirect.c:%MAX_PKT_SIZE 117 + * must be updated accordingly this gets changed, otherwise BPF selftests 118 + * will fail. 119 + */ 119 120 #define TEST_XDP_FRAME_SIZE (PAGE_SIZE - sizeof(struct xdp_page_head)) 120 121 #define TEST_XDP_MAX_BATCH 256 121 122 ··· 139 132 headroom -= meta_len; 140 133 141 134 new_ctx = &head->ctx; 142 - frm = &head->frm; 143 - data = &head->data; 135 + frm = head->frame; 136 + data = head->data; 144 137 memcpy(data + headroom, orig_ctx->data_meta, frm_len); 145 138 146 139 xdp_init_buff(new_ctx, TEST_XDP_FRAME_SIZE, &xdp->rxq); ··· 230 223 head->ctx.data = head->orig_ctx.data; 231 224 head->ctx.data_meta = head->orig_ctx.data_meta; 232 225 head->ctx.data_end = head->orig_ctx.data_end; 233 - xdp_update_frame_from_buff(&head->ctx, &head->frm); 226 + xdp_update_frame_from_buff(&head->ctx, head->frame); 234 227 } 235 228 236 229 static int xdp_recv_frames(struct xdp_frame **frames, int nframes, ··· 292 285 head = phys_to_virt(page_to_phys(page)); 293 286 reset_ctx(head); 294 287 ctx = &head->ctx; 295 - frm = &head->frm; 288 + frm = head->frame; 296 289 xdp->frame_cnt++; 297 290 298 291 act = bpf_prog_run_xdp(prog, ctx);
+6
net/ipv4/tcp_bpf.c
··· 186 186 if (unlikely(flags & MSG_ERRQUEUE)) 187 187 return inet_recv_error(sk, msg, len, addr_len); 188 188 189 + if (!len) 190 + return 0; 191 + 189 192 psock = sk_psock_get(sk); 190 193 if (unlikely(!psock)) 191 194 return tcp_recvmsg(sk, msg, len, flags, addr_len); ··· 246 243 247 244 if (unlikely(flags & MSG_ERRQUEUE)) 248 245 return inet_recv_error(sk, msg, len, addr_len); 246 + 247 + if (!len) 248 + return 0; 249 249 250 250 psock = sk_psock_get(sk); 251 251 if (unlikely(!psock))
+3
net/ipv4/udp_bpf.c
··· 68 68 if (unlikely(flags & MSG_ERRQUEUE)) 69 69 return inet_recv_error(sk, msg, len, addr_len); 70 70 71 + if (!len) 72 + return 0; 73 + 71 74 psock = sk_psock_get(sk); 72 75 if (unlikely(!psock)) 73 76 return sk_udp_recvmsg(sk, msg, len, flags, addr_len);
+3
net/unix/unix_bpf.c
··· 54 54 struct sk_psock *psock; 55 55 int copied; 56 56 57 + if (!len) 58 + return 0; 59 + 57 60 psock = sk_psock_get(sk); 58 61 if (unlikely(!psock)) 59 62 return __unix_recvmsg(sk, msg, len, flags);
+28
tools/testing/selftests/bpf/prog_tests/btf.c
··· 879 879 .btf_load_err = true, 880 880 .err_str = "Invalid elem", 881 881 }, 882 + { 883 + .descr = "var after datasec, ptr followed by modifier", 884 + .raw_types = { 885 + /* .bss section */ /* [1] */ 886 + BTF_TYPE_ENC(NAME_TBD, BTF_INFO_ENC(BTF_KIND_DATASEC, 0, 2), 887 + sizeof(void*)+4), 888 + BTF_VAR_SECINFO_ENC(4, 0, sizeof(void*)), 889 + BTF_VAR_SECINFO_ENC(6, sizeof(void*), 4), 890 + /* int */ /* [2] */ 891 + BTF_TYPE_INT_ENC(0, BTF_INT_SIGNED, 0, 32, 4), 892 + /* int* */ /* [3] */ 893 + BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_PTR, 0, 0), 2), 894 + BTF_VAR_ENC(NAME_TBD, 3, 0), /* [4] */ 895 + /* const int */ /* [5] */ 896 + BTF_TYPE_ENC(0, BTF_INFO_ENC(BTF_KIND_CONST, 0, 0), 2), 897 + BTF_VAR_ENC(NAME_TBD, 5, 0), /* [6] */ 898 + BTF_END_RAW, 899 + }, 900 + .str_sec = "\0a\0b\0c\0", 901 + .str_sec_size = sizeof("\0a\0b\0c\0"), 902 + .map_type = BPF_MAP_TYPE_ARRAY, 903 + .map_name = ".bss", 904 + .key_size = sizeof(int), 905 + .value_size = sizeof(void*)+4, 906 + .key_type_id = 0, 907 + .value_type_id = 1, 908 + .max_entries = 1, 909 + }, 882 910 /* Test member exceeds the size of struct. 883 911 * 884 912 * struct A {
+4 -3
tools/testing/selftests/bpf/prog_tests/xdp_do_redirect.c
··· 65 65 } 66 66 67 67 /* The maximum permissible size is: PAGE_SIZE - sizeof(struct xdp_page_head) - 68 - * sizeof(struct skb_shared_info) - XDP_PACKET_HEADROOM = 3368 bytes 68 + * SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) - XDP_PACKET_HEADROOM = 69 + * 3408 bytes for 64-byte cacheline and 3216 for 256-byte one. 69 70 */ 70 71 #if defined(__s390x__) 71 - #define MAX_PKT_SIZE 3176 72 + #define MAX_PKT_SIZE 3216 72 73 #else 73 - #define MAX_PKT_SIZE 3368 74 + #define MAX_PKT_SIZE 3408 74 75 #endif 75 76 static void test_max_pkt_size(int fd) 76 77 {