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
7patches for stable kernels.7patches for stable kernels.
8 8
9For general information about submitting patches, please refer to9For general information about submitting patches, please refer to
10`Documentation/process/`_. This document only describes additional specifics10Documentation/process/submitting-patches.rst. This document only describes
11related to BPF.11additional specifics related to BPF.
12 12
13.. contents::13.. contents::
14 :local:14 :local:
@@ -461,15 +461,15 @@ needed:: · 446 unmodified lines
461 461
462 $ sudo make run_tests462 $ sudo make run_tests
463 463
464See the kernels selftest `Documentation/dev-tools/kselftest.rst`_464See :doc:`kernel selftest documentation </dev-tools/kselftest>`
465document for further documentation.465for details.
466 466
467To maximize the number of tests passing, the .config of the kernel467To maximize the number of tests passing, the .config of the kernel
468under test should match the config file fragment in468under test should match the config file fragment in
469tools/testing/selftests/bpf as closely as possible.469tools/testing/selftests/bpf as closely as possible.
470 470
471Finally to ensure support for latest BPF Type Format features -471Finally to ensure support for latest BPF Type Format features -
472discussed in `Documentation/bpf/btf.rst`_ - pahole version 1.16472discussed in Documentation/bpf/btf.rst - pahole version 1.16
473is required for kernels built with CONFIG_DEBUG_INFO_BTF=y.473is required for kernels built with CONFIG_DEBUG_INFO_BTF=y.
474pahole is delivered in the dwarves package or can be built474pahole is delivered in the dwarves package or can be built
475from source at475from source at
@@ -684,12 +684,8 @@ when: · 208 unmodified lines
684 684
685 685
686.. Links686.. Links
687.. _Documentation/process/: https://www.kernel.org/doc/html/latest/process/
688.. _netdev-FAQ: Documentation/process/maintainer-netdev.rst687.. _netdev-FAQ: Documentation/process/maintainer-netdev.rst
689.. _selftests:688.. _selftests:
690 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/testing/selftests/bpf/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
695Happy BPF hacking!691Happy BPF hacking!
arch/riscv/net/bpf_jit_comp64.c+1−0
@@ -10,6 +10,7 @@ · 9 unmodified lines
10#include <linux/filter.h>10#include <linux/filter.h>
11#include <linux/memory.h>11#include <linux/memory.h>
12#include <linux/stop_machine.h>12#include <linux/stop_machine.h>
13#include <asm/patch.h>
13#include "bpf_jit.h"14#include "bpf_jit.h"
14 15
15#define RV_REG_TCC RV_REG_A616#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
4569 struct btf *btf = env->btf;4569 struct btf *btf = env->btf;
4570 u16 i;4570 u16 i;
4571 4571
4572 env->resolve_mode = RESOLVE_TBD;
4572 for_each_vsi_from(i, v->next_member, v->t, vsi) {4573 for_each_vsi_from(i, v->next_member, v->t, vsi) {
4573 u32 var_type_id = vsi->type, type_id, type_size = 0;4574 u32 var_type_id = vsi->type, type_id, type_size = 0;
4574 const struct btf_type *var_type = btf_type_by_id(env->btf,4575 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
97struct xdp_page_head {97struct xdp_page_head {
98 struct xdp_buff orig_ctx;98 struct xdp_buff orig_ctx;
99 struct xdp_buff ctx;99 struct xdp_buff ctx;
100 struct xdp_frame frm;100 union {
101 u8 data[];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
104struct xdp_test_data {107struct xdp_test_data {
@@ -113,6 +116,10 @@ struct xdp_test_data { · 8 unmodified lines
113 u32 frame_cnt;116 u32 frame_cnt;
114};117};
115 118
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 */
116#define TEST_XDP_FRAME_SIZE (PAGE_SIZE - sizeof(struct xdp_page_head))123#define TEST_XDP_FRAME_SIZE (PAGE_SIZE - sizeof(struct xdp_page_head))
117#define TEST_XDP_MAX_BATCH 256124#define TEST_XDP_MAX_BATCH 256
118 125
@@ -132,8 +139,8 @@ static void xdp_test_run_init_page(struct page *page, void *arg) · 13 unmodified lines
132 headroom -= meta_len;139 headroom -= meta_len;
133 140
134 new_ctx = &head->ctx;141 new_ctx = &head->ctx;
135 frm = &head->frm;142 frm = head->frame;
136 data = &head->data;143 data = head->data;
137 memcpy(data + headroom, orig_ctx->data_meta, frm_len);144 memcpy(data + headroom, orig_ctx->data_meta, frm_len);
138 145
139 xdp_init_buff(new_ctx, TEST_XDP_FRAME_SIZE, &xdp->rxq);146 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
223 head->ctx.data = head->orig_ctx.data;230 head->ctx.data = head->orig_ctx.data;
224 head->ctx.data_meta = head->orig_ctx.data_meta;231 head->ctx.data_meta = head->orig_ctx.data_meta;
225 head->ctx.data_end = head->orig_ctx.data_end;232 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);
227}234}
228 235
229static int xdp_recv_frames(struct xdp_frame **frames, int nframes,236static 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
285 head = phys_to_virt(page_to_phys(page));292 head = phys_to_virt(page_to_phys(page));
286 reset_ctx(head);293 reset_ctx(head);
287 ctx = &head->ctx;294 ctx = &head->ctx;
288 frm = &head->frm;295 frm = head->frame;
289 xdp->frame_cnt++;296 xdp->frame_cnt++;
290 297
291 act = bpf_prog_run_xdp(prog, ctx);298 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
186 if (unlikely(flags & MSG_ERRQUEUE))186 if (unlikely(flags & MSG_ERRQUEUE))
187 return inet_recv_error(sk, msg, len, addr_len);187 return inet_recv_error(sk, msg, len, addr_len);
188 188
189 if (!len)
190 return 0;
191
189 psock = sk_psock_get(sk);192 psock = sk_psock_get(sk);
190 if (unlikely(!psock))193 if (unlikely(!psock))
191 return tcp_recvmsg(sk, msg, len, flags, addr_len);194 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
244 if (unlikely(flags & MSG_ERRQUEUE))247 if (unlikely(flags & MSG_ERRQUEUE))
245 return inet_recv_error(sk, msg, len, addr_len);248 return inet_recv_error(sk, msg, len, addr_len);
246 249
250 if (!len)
251 return 0;
252
247 psock = sk_psock_get(sk);253 psock = sk_psock_get(sk);
248 if (unlikely(!psock))254 if (unlikely(!psock))
249 return tcp_recvmsg(sk, msg, len, flags, addr_len);255 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
68 if (unlikely(flags & MSG_ERRQUEUE))68 if (unlikely(flags & MSG_ERRQUEUE))
69 return inet_recv_error(sk, msg, len, addr_len);69 return inet_recv_error(sk, msg, len, addr_len);
70 70
71 if (!len)
72 return 0;
73
71 psock = sk_psock_get(sk);74 psock = sk_psock_get(sk);
72 if (unlikely(!psock))75 if (unlikely(!psock))
73 return sk_udp_recvmsg(sk, msg, len, flags, addr_len);76 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
54 struct sk_psock *psock;54 struct sk_psock *psock;
55 int copied;55 int copied;
56 56
57 if (!len)
58 return 0;
59
57 psock = sk_psock_get(sk);60 psock = sk_psock_get(sk);
58 if (unlikely(!psock))61 if (unlikely(!psock))
59 return __unix_recvmsg(sk, msg, len, flags);62 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
879 .btf_load_err = true,879 .btf_load_err = true,
880 .err_str = "Invalid elem",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/* Test member exceeds the size of struct.910/* Test member exceeds the size of struct.
883 *911 *
884 * struct A {912 * 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
65}65}
66 66
67/* The maximum permissible size is: PAGE_SIZE - sizeof(struct xdp_page_head) -67/* The maximum permissible size is: PAGE_SIZE - sizeof(struct xdp_page_head) -
68 * sizeof(struct skb_shared_info) - XDP_PACKET_HEADROOM = 3368 bytes68 * 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#if defined(__s390x__)71#if defined(__s390x__)
71#define MAX_PKT_SIZE 317672#define MAX_PKT_SIZE 3216
72#else73#else
73#define MAX_PKT_SIZE 336874#define MAX_PKT_SIZE 3408
74#endif75#endif
75static void test_max_pkt_size(int fd)76static void test_max_pkt_size(int fd)
76{77{

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