Commit 757b56a6 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files
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: default avatarJakub Kicinski <kuba@kernel.org>
parents e539a105 32dfc59e
Loading
Loading
Loading
Loading
+5 −9
Original line number Original line Diff line number Diff line
@@ -7,8 +7,8 @@ workflows related to reporting bugs, submitting patches, and queueing
patches for stable kernels.
patches for stable kernels.


For general information about submitting patches, please refer to
For general information about submitting patches, please refer to
`Documentation/process/`_. This document only describes additional specifics
Documentation/process/submitting-patches.rst. This document only describes
related to BPF.
additional specifics related to BPF.


.. contents::
.. contents::
    :local:
    :local:
@@ -461,15 +461,15 @@ needed::


  $ sudo make run_tests
  $ sudo make run_tests


See the kernels selftest `Documentation/dev-tools/kselftest.rst`_
See :doc:`kernel selftest documentation </dev-tools/kselftest>`
document for further documentation.
for details.


To maximize the number of tests passing, the .config of the kernel
To maximize the number of tests passing, the .config of the kernel
under test should match the config file fragment in
under test should match the config file fragment in
tools/testing/selftests/bpf as closely as possible.
tools/testing/selftests/bpf as closely as possible.


Finally to ensure support for latest BPF Type Format features -
Finally to ensure support for latest BPF Type Format features -
discussed in `Documentation/bpf/btf.rst`_ - pahole version 1.16
discussed in Documentation/bpf/btf.rst - pahole version 1.16
is required for kernels built with CONFIG_DEBUG_INFO_BTF=y.
is required for kernels built with CONFIG_DEBUG_INFO_BTF=y.
pahole is delivered in the dwarves package or can be built
pahole is delivered in the dwarves package or can be built
from source at
from source at
@@ -684,12 +684,8 @@ when:




.. Links
.. Links
.. _Documentation/process/: https://www.kernel.org/doc/html/latest/process/
.. _netdev-FAQ: Documentation/process/maintainer-netdev.rst
.. _netdev-FAQ: Documentation/process/maintainer-netdev.rst
.. _selftests:
.. _selftests:
   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/testing/selftests/bpf/
   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/testing/selftests/bpf/
.. _Documentation/dev-tools/kselftest.rst:
   https://www.kernel.org/doc/html/latest/dev-tools/kselftest.html
.. _Documentation/bpf/btf.rst: btf.rst


Happy BPF hacking!
Happy BPF hacking!
+1 −0
Original line number Original line Diff line number Diff line
@@ -10,6 +10,7 @@
#include <linux/filter.h>
#include <linux/filter.h>
#include <linux/memory.h>
#include <linux/memory.h>
#include <linux/stop_machine.h>
#include <linux/stop_machine.h>
#include <asm/patch.h>
#include "bpf_jit.h"
#include "bpf_jit.h"


#define RV_REG_TCC RV_REG_A6
#define RV_REG_TCC RV_REG_A6
+1 −0
Original line number Original line Diff line number Diff line
@@ -4569,6 +4569,7 @@ static int btf_datasec_resolve(struct btf_verifier_env *env,
	struct btf *btf = env->btf;
	struct btf *btf = env->btf;
	u16 i;
	u16 i;


	env->resolve_mode = RESOLVE_TBD;
	for_each_vsi_from(i, v->next_member, v->t, vsi) {
	for_each_vsi_from(i, v->next_member, v->t, vsi) {
		u32 var_type_id = vsi->type, type_id, type_size = 0;
		u32 var_type_id = vsi->type, type_id, type_size = 0;
		const struct btf_type *var_type = btf_type_by_id(env->btf,
		const struct btf_type *var_type = btf_type_by_id(env->btf,
+13 −6
Original line number Original line Diff line number Diff line
@@ -97,8 +97,11 @@ static bool bpf_test_timer_continue(struct bpf_test_timer *t, int iterations,
struct xdp_page_head {
struct xdp_page_head {
	struct xdp_buff orig_ctx;
	struct xdp_buff orig_ctx;
	struct xdp_buff ctx;
	struct xdp_buff ctx;
	struct xdp_frame frm;
	union {
	u8 data[];
		/* ::data_hard_start starts here */
		DECLARE_FLEX_ARRAY(struct xdp_frame, frame);
		DECLARE_FLEX_ARRAY(u8, data);
	};
};
};


struct xdp_test_data {
struct xdp_test_data {
@@ -113,6 +116,10 @@ struct xdp_test_data {
	u32 frame_cnt;
	u32 frame_cnt;
};
};


/* tools/testing/selftests/bpf/prog_tests/xdp_do_redirect.c:%MAX_PKT_SIZE
 * must be updated accordingly this gets changed, otherwise BPF selftests
 * will fail.
 */
#define TEST_XDP_FRAME_SIZE (PAGE_SIZE - sizeof(struct xdp_page_head))
#define TEST_XDP_FRAME_SIZE (PAGE_SIZE - sizeof(struct xdp_page_head))
#define TEST_XDP_MAX_BATCH 256
#define TEST_XDP_MAX_BATCH 256


@@ -132,8 +139,8 @@ static void xdp_test_run_init_page(struct page *page, void *arg)
	headroom -= meta_len;
	headroom -= meta_len;


	new_ctx = &head->ctx;
	new_ctx = &head->ctx;
	frm = &head->frm;
	frm = head->frame;
	data = &head->data;
	data = head->data;
	memcpy(data + headroom, orig_ctx->data_meta, frm_len);
	memcpy(data + headroom, orig_ctx->data_meta, frm_len);


	xdp_init_buff(new_ctx, TEST_XDP_FRAME_SIZE, &xdp->rxq);
	xdp_init_buff(new_ctx, TEST_XDP_FRAME_SIZE, &xdp->rxq);
@@ -223,7 +230,7 @@ static void reset_ctx(struct xdp_page_head *head)
	head->ctx.data = head->orig_ctx.data;
	head->ctx.data = head->orig_ctx.data;
	head->ctx.data_meta = head->orig_ctx.data_meta;
	head->ctx.data_meta = head->orig_ctx.data_meta;
	head->ctx.data_end = head->orig_ctx.data_end;
	head->ctx.data_end = head->orig_ctx.data_end;
	xdp_update_frame_from_buff(&head->ctx, &head->frm);
	xdp_update_frame_from_buff(&head->ctx, head->frame);
}
}


static int xdp_recv_frames(struct xdp_frame **frames, int nframes,
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,
		head = phys_to_virt(page_to_phys(page));
		head = phys_to_virt(page_to_phys(page));
		reset_ctx(head);
		reset_ctx(head);
		ctx = &head->ctx;
		ctx = &head->ctx;
		frm = &head->frm;
		frm = head->frame;
		xdp->frame_cnt++;
		xdp->frame_cnt++;


		act = bpf_prog_run_xdp(prog, ctx);
		act = bpf_prog_run_xdp(prog, ctx);
+6 −0
Original line number Original line Diff line number Diff line
@@ -186,6 +186,9 @@ static int tcp_bpf_recvmsg_parser(struct sock *sk,
	if (unlikely(flags & MSG_ERRQUEUE))
	if (unlikely(flags & MSG_ERRQUEUE))
		return inet_recv_error(sk, msg, len, addr_len);
		return inet_recv_error(sk, msg, len, addr_len);


	if (!len)
		return 0;

	psock = sk_psock_get(sk);
	psock = sk_psock_get(sk);
	if (unlikely(!psock))
	if (unlikely(!psock))
		return tcp_recvmsg(sk, msg, len, flags, addr_len);
		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,
	if (unlikely(flags & MSG_ERRQUEUE))
	if (unlikely(flags & MSG_ERRQUEUE))
		return inet_recv_error(sk, msg, len, addr_len);
		return inet_recv_error(sk, msg, len, addr_len);


	if (!len)
		return 0;

	psock = sk_psock_get(sk);
	psock = sk_psock_get(sk);
	if (unlikely(!psock))
	if (unlikely(!psock))
		return tcp_recvmsg(sk, msg, len, flags, addr_len);
		return tcp_recvmsg(sk, msg, len, flags, addr_len);
Loading