History

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 ====================

Jakub Kicinski committed 3 years ago

Commit 757b56a2 parents e539a10 32dfc599 files · +64 −18Browse files

Unified · Split

9 files
  1. Documentation/bpf/bpf_devel_QA.rst +5 −9
  2. arch/riscv/net/bpf_jit_comp64.c +1 −0
  3. kernel/bpf/btf.c +1 −0
  4. net/bpf/test_run.c +13 −6
  5. net/ipv4/tcp_bpf.c +6 −0
  6. net/ipv4/udp_bpf.c +3 −0
  7. net/unix/unix_bpf.c +3 −0
  8. tools/testing/selftests/bpf/prog_tests/btf.c +28 −0
  9. tools/testing/selftests/bpf/prog_tests/xdp_do_redirect.c +4 −3
Documentation/bpf/bpf_devel_QA.rst+5−9
@@ -7,8 +7,8 @@ workflows related to reporting bugs, submitting patches, and queueing · 6 unmodified lines
77 patches for stable kernels.
88
99 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.
1212
1313 .. contents::
1414 :local:
@@ -461,15 +461,15 @@ needed:: · 446 unmodified lines
461461
462462 $ sudo make run_tests
463463
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.
466466
467467 To maximize the number of tests passing, the .config of the kernel
468468 under test should match the config file fragment in
469469 tools/testing/selftests/bpf as closely as possible.
470470
471471 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
473473 is required for kernels built with CONFIG_DEBUG_INFO_BTF=y.
474474 pahole is delivered in the dwarves package or can be built
475475 from source at
@@ -684,12 +684,8 @@ when: · 208 unmodified lines
684684
685685
686686 .. Links
687−.. _Documentation/process/: https://www.kernel.org/doc/html/latest/process/
688687 .. _netdev-FAQ: Documentation/process/maintainer-netdev.rst
689688 .. _selftests:
690689 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
694690
695691 Happy BPF hacking!
arch/riscv/net/bpf_jit_comp64.c+1−0
@@ -10,6 +10,7 @@ · 9 unmodified lines
1010 #include <linux/filter.h>
1111 #include <linux/memory.h>
1212 #include <linux/stop_machine.h>
13+#include <asm/patch.h>
1314 #include "bpf_jit.h"
1415
1516 #define RV_REG_TCC RV_REG_A6
kernel/bpf/btf.c+1−0
@@ -4569,6 +4569,7 @@ static int btf_datasec_resolve(struct btf_verifier_env *env, · 4568 unmodified lines
45694569 struct btf *btf = env->btf;
45704570 u16 i;
45714571
4572+ env->resolve_mode = RESOLVE_TBD;
45724573 for_each_vsi_from(i, v->next_member, v->t, vsi) {
45734574 u32 var_type_id = vsi->type, type_id, type_size = 0;
45744575 const struct btf_type *var_type = btf_type_by_id(env->btf,
net/bpf/test_run.c+13−6
@@ -97,8 +97,11 @@ reset: · 96 unmodified lines
9797 struct xdp_page_head {
9898 struct xdp_buff orig_ctx;
9999 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+ };
102105 };
103106
104107 struct xdp_test_data {
@@ -113,6 +116,10 @@ struct xdp_test_data { · 8 unmodified lines
113116 u32 frame_cnt;
114117 };
115118
119+/* tools/testing/selftests/bpf/prog_tests/xdp_do_redirect.c:%MAX_PKT_SIZE
120+ * must be updated accordingly this gets changed, otherwise BPF selftests
121+ * will fail.
122+ */
116123 #define TEST_XDP_FRAME_SIZE (PAGE_SIZE - sizeof(struct xdp_page_head))
117124 #define TEST_XDP_MAX_BATCH 256
118125
@@ -132,8 +139,8 @@ static void xdp_test_run_init_page(struct page *page, void *arg) · 13 unmodified lines
132139 headroom -= meta_len;
133140
134141 new_ctx = &head->ctx;
135− frm = &head->frm;
136− data = &head->data;
142+ frm = head->frame;
143+ data = head->data;
137144 memcpy(data + headroom, orig_ctx->data_meta, frm_len);
138145
139146 xdp_init_buff(new_ctx, TEST_XDP_FRAME_SIZE, &xdp->rxq);
@@ -223,7 +230,7 @@ static void reset_ctx(struct xdp_page_head *head) · 83 unmodified lines
223230 head->ctx.data = head->orig_ctx.data;
224231 head->ctx.data_meta = head->orig_ctx.data_meta;
225232 head->ctx.data_end = head->orig_ctx.data_end;
226− xdp_update_frame_from_buff(&head->ctx, &head->frm);
233+ xdp_update_frame_from_buff(&head->ctx, head->frame);
227234 }
228235
229236 static int xdp_recv_frames(struct xdp_frame **frames, int nframes,
@@ -285,7 +292,7 @@ static int xdp_test_run_batch(struct xdp_test_data *xdp, struct bpf_prog *prog, · 55 unmodified lines
285292 head = phys_to_virt(page_to_phys(page));
286293 reset_ctx(head);
287294 ctx = &head->ctx;
288− frm = &head->frm;
295+ frm = head->frame;
289296 xdp->frame_cnt++;
290297
291298 act = bpf_prog_run_xdp(prog, ctx);
net/ipv4/tcp_bpf.c+6−0
@@ -186,6 +186,9 @@ static int tcp_bpf_recvmsg_parser(struct sock *sk, · 185 unmodified lines
186186 if (unlikely(flags & MSG_ERRQUEUE))
187187 return inet_recv_error(sk, msg, len, addr_len);
188188
189+ if (!len)
190+ return 0;
191+
189192 psock = sk_psock_get(sk);
190193 if (unlikely(!psock))
191194 return tcp_recvmsg(sk, msg, len, flags, addr_len);
@@ -244,6 +247,9 @@ static int tcp_bpf_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, · 52 unmodified lines
244247 if (unlikely(flags & MSG_ERRQUEUE))
245248 return inet_recv_error(sk, msg, len, addr_len);
246249
250+ if (!len)
251+ return 0;
252+
247253 psock = sk_psock_get(sk);
248254 if (unlikely(!psock))
249255 return tcp_recvmsg(sk, msg, len, flags, addr_len);
net/ipv4/udp_bpf.c+3−0
@@ -68,6 +68,9 @@ static int udp_bpf_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, · 67 unmodified lines
6868 if (unlikely(flags & MSG_ERRQUEUE))
6969 return inet_recv_error(sk, msg, len, addr_len);
7070
71+ if (!len)
72+ return 0;
73+
7174 psock = sk_psock_get(sk);
7275 if (unlikely(!psock))
7376 return sk_udp_recvmsg(sk, msg, len, flags, addr_len);
net/unix/unix_bpf.c+3−0
@@ -54,6 +54,9 @@ static int unix_bpf_recvmsg(struct sock *sk, struct msghdr *msg, · 53 unmodified lines
5454 struct sk_psock *psock;
5555 int copied;
5656
57+ if (!len)
58+ return 0;
59+
5760 psock = sk_psock_get(sk);
5861 if (unlikely(!psock))
5962 return __unix_recvmsg(sk, msg, len, flags);
tools/testing/selftests/bpf/prog_tests/btf.c+28−0
@@ -879,6 +879,34 @@ static struct btf_raw_test raw_tests[] = { · 878 unmodified lines
879879 .btf_load_err = true,
880880 .err_str = "Invalid elem",
881881 },
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+},
882910 /* Test member exceeds the size of struct.
883911 *
884912 * struct A {
tools/testing/selftests/bpf/prog_tests/xdp_do_redirect.c+4−3
@@ -65,12 +65,13 @@ static int attach_tc_prog(struct bpf_tc_hook *hook, int fd) · 64 unmodified lines
6565 }
6666
6767 /* 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.
6970 */
7071 #if defined(__s390x__)
71−#define MAX_PKT_SIZE 3176
72+#define MAX_PKT_SIZE 3216
7273 #else
73−#define MAX_PKT_SIZE 3368
74+#define MAX_PKT_SIZE 3408
7475 #endif
7576 static void test_max_pkt_size(int fd)
7677 {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t