Commit b2ff42c6 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files
Daniel Borkmann says:

====================
pull-request: bpf 2024-04-26

We've added 12 non-merge commits during the last 22 day(s) which contain
a total of 14 files changed, 168 insertions(+), 72 deletions(-).

The main changes are:

1) Fix BPF_PROBE_MEM in verifier and JIT to skip loads from vsyscall page,
   from Puranjay Mohan.

2) Fix a crash in XDP with devmap broadcast redirect when the latter map
   is in process of being torn down, from Toke Høiland-Jørgensen.

3) Fix arm64 and riscv64 BPF JITs to properly clear start time for BPF
   program runtime stats, from Xu Kuohai.

4) Fix a sockmap KCSAN-reported data race in sk_psock_skb_ingress_enqueue,
    from Jason Xing.

5) Fix BPF verifier error message in resolve_pseudo_ldimm64,
   from Anton Protopopov.

6) Fix missing DEBUG_INFO_BTF_MODULES Kconfig menu item,
   from Andrii Nakryiko.

* tag 'for-netdev' of https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf:
  selftests/bpf: Test PROBE_MEM of VSYSCALL_ADDR on x86-64
  bpf, x86: Fix PROBE_MEM runtime load check
  bpf: verifier: prevent userspace memory access
  xdp: use flags field to disambiguate broadcast redirect
  arm32, bpf: Reimplement sign-extension mov instruction
  riscv, bpf: Fix incorrect runtime stats
  bpf, arm64: Fix incorrect runtime stats
  bpf: Fix a verifier verbose message
  bpf, skmsg: Fix NULL pointer dereference in sk_psock_skb_ingress_enqueue
  MAINTAINERS: bpf: Add Lehui and Puranjay as riscv64 reviewers
  MAINTAINERS: Update email address for Puranjay Mohan
  bpf, kconfig: Fix DEBUG_INFO_BTF_MODULES Kconfig definition
====================

Link: https://lore.kernel.org/r/20240426224248.26197-1-daniel@iogearbox.net


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 6a30653b a86538a2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -512,6 +512,7 @@ Praveen BP <praveenbp@ti.com>
Pradeep Kumar Chitrapu <quic_pradeepc@quicinc.com> <pradeepc@codeaurora.org>
Prasad Sodagudi <quic_psodagud@quicinc.com> <psodagud@codeaurora.org>
Punit Agrawal <punitagrawal@gmail.com> <punit.agrawal@arm.com>
Puranjay Mohan <puranjay@kernel.org> <puranjay12@gmail.com>
Qais Yousef <qyousef@layalina.io> <qais.yousef@imgtec.com>
Qais Yousef <qyousef@layalina.io> <qais.yousef@arm.com>
Quentin Monnet <qmo@kernel.org> <quentin.monnet@netronome.com>
+5 −3
Original line number Diff line number Diff line
@@ -553,7 +553,7 @@ F: Documentation/devicetree/bindings/iio/accel/adi,adxl345.yaml
F:	drivers/input/misc/adxl34x.c
ADXL355 THREE-AXIS DIGITAL ACCELEROMETER DRIVER
M:	Puranjay Mohan <puranjay12@gmail.com>
M:	Puranjay Mohan <puranjay@kernel.org>
L:	linux-iio@vger.kernel.org
S:	Supported
F:	Documentation/devicetree/bindings/iio/accel/adi,adxl355.yaml
@@ -3714,7 +3714,7 @@ F: drivers/iio/imu/bmi323/
BPF JIT for ARM
M:	Russell King <linux@armlinux.org.uk>
M:	Puranjay Mohan <puranjay12@gmail.com>
M:	Puranjay Mohan <puranjay@kernel.org>
L:	bpf@vger.kernel.org
S:	Maintained
F:	arch/arm/net/
@@ -3764,6 +3764,8 @@ X: arch/riscv/net/bpf_jit_comp64.c
BPF JIT for RISC-V (64-bit)
M:	Björn Töpel <bjorn@kernel.org>
R:	Pu Lehui <pulehui@huawei.com>
R:	Puranjay Mohan <puranjay@kernel.org>
L:	bpf@vger.kernel.org
S:	Maintained
F:	arch/riscv/net/
@@ -21925,7 +21927,7 @@ F: include/linux/soc/ti/ti_sci_inta_msi.h
F:	include/linux/soc/ti/ti_sci_protocol.h
TEXAS INSTRUMENTS' TMP117 TEMPERATURE SENSOR DRIVER
M:	Puranjay Mohan <puranjay12@gmail.com>
M:	Puranjay Mohan <puranjay@kernel.org>
L:	linux-iio@vger.kernel.org
S:	Supported
F:	Documentation/devicetree/bindings/iio/temperature/ti,tmp117.yaml
+43 −13
Original line number Diff line number Diff line
@@ -871,16 +871,11 @@ static inline void emit_a32_alu_r64(const bool is64, const s8 dst[],
}

/* dst = src (4 bytes)*/
static inline void emit_a32_mov_r(const s8 dst, const s8 src, const u8 off,
				  struct jit_ctx *ctx) {
static inline void emit_a32_mov_r(const s8 dst, const s8 src, struct jit_ctx *ctx) {
	const s8 *tmp = bpf2a32[TMP_REG_1];
	s8 rt;

	rt = arm_bpf_get_reg32(src, tmp[0], ctx);
	if (off && off != 32) {
		emit(ARM_LSL_I(rt, rt, 32 - off), ctx);
		emit(ARM_ASR_I(rt, rt, 32 - off), ctx);
	}
	arm_bpf_put_reg32(dst, rt, ctx);
}

@@ -889,15 +884,15 @@ static inline void emit_a32_mov_r64(const bool is64, const s8 dst[],
				  const s8 src[],
				  struct jit_ctx *ctx) {
	if (!is64) {
		emit_a32_mov_r(dst_lo, src_lo, 0, ctx);
		emit_a32_mov_r(dst_lo, src_lo, ctx);
		if (!ctx->prog->aux->verifier_zext)
			/* Zero out high 4 bytes */
			emit_a32_mov_i(dst_hi, 0, ctx);
	} else if (__LINUX_ARM_ARCH__ < 6 &&
		   ctx->cpu_architecture < CPU_ARCH_ARMv5TE) {
		/* complete 8 byte move */
		emit_a32_mov_r(dst_lo, src_lo, 0, ctx);
		emit_a32_mov_r(dst_hi, src_hi, 0, ctx);
		emit_a32_mov_r(dst_lo, src_lo, ctx);
		emit_a32_mov_r(dst_hi, src_hi, ctx);
	} else if (is_stacked(src_lo) && is_stacked(dst_lo)) {
		const u8 *tmp = bpf2a32[TMP_REG_1];

@@ -917,17 +912,52 @@ static inline void emit_a32_mov_r64(const bool is64, const s8 dst[],
static inline void emit_a32_movsx_r64(const bool is64, const u8 off, const s8 dst[], const s8 src[],
				      struct jit_ctx *ctx) {
	const s8 *tmp = bpf2a32[TMP_REG_1];
	const s8 *rt;
	s8 rs;
	s8 rd;

	if (is_stacked(dst_lo))
		rd = tmp[1];
	else
		rd = dst_lo;
	rs = arm_bpf_get_reg32(src_lo, rd, ctx);
	/* rs may be one of src[1], dst[1], or tmp[1] */

	/* Sign extend rs if needed. If off == 32, lower 32-bits of src are moved to dst and sign
	 * extension only happens in the upper 64 bits.
	 */
	if (off != 32) {
		/* Sign extend rs into rd */
		emit(ARM_LSL_I(rd, rs, 32 - off), ctx);
		emit(ARM_ASR_I(rd, rd, 32 - off), ctx);
	} else {
		rd = rs;
	}

	rt = arm_bpf_get_reg64(dst, tmp, ctx);
	/* Write rd to dst_lo
	 *
	 * Optimization:
	 * Assume:
	 * 1. dst == src and stacked.
	 * 2. off == 32
	 *
	 * In this case src_lo was loaded into rd(tmp[1]) but rd was not sign extended as off==32.
	 * So, we don't need to write rd back to dst_lo as they have the same value.
	 * This saves us one str instruction.
	 */
	if (dst_lo != src_lo || off != 32)
		arm_bpf_put_reg32(dst_lo, rd, ctx);

	emit_a32_mov_r(dst_lo, src_lo, off, ctx);
	if (!is64) {
		if (!ctx->prog->aux->verifier_zext)
			/* Zero out high 4 bytes */
			emit_a32_mov_i(dst_hi, 0, ctx);
	} else {
		emit(ARM_ASR_I(rt[0], rt[1], 31), ctx);
		if (is_stacked(dst_hi)) {
			emit(ARM_ASR_I(tmp[0], rd, 31), ctx);
			arm_bpf_put_reg32(dst_hi, tmp[0], ctx);
		} else {
			emit(ARM_ASR_I(dst_hi, rd, 31), ctx);
		}
	}
}

+3 −3
Original line number Diff line number Diff line
@@ -1844,15 +1844,15 @@ static void invoke_bpf_prog(struct jit_ctx *ctx, struct bpf_tramp_link *l,

	emit_call(enter_prog, ctx);

	/* save return value to callee saved register x20 */
	emit(A64_MOV(1, A64_R(20), A64_R(0)), ctx);

	/* if (__bpf_prog_enter(prog) == 0)
	 *         goto skip_exec_of_prog;
	 */
	branch = ctx->image + ctx->idx;
	emit(A64_NOP, ctx);

	/* save return value to callee saved register x20 */
	emit(A64_MOV(1, A64_R(20), A64_R(0)), ctx);

	emit(A64_ADD_I(1, A64_R(0), A64_SP, args_off), ctx);
	if (!p->jited)
		emit_addr_mov_i64(A64_R(1), (const u64)p->insnsi, ctx);
+3 −3
Original line number Diff line number Diff line
@@ -722,6 +722,9 @@ static int invoke_bpf_prog(struct bpf_tramp_link *l, int args_off, int retval_of
	if (ret)
		return ret;

	/* store prog start time */
	emit_mv(RV_REG_S1, RV_REG_A0, ctx);

	/* if (__bpf_prog_enter(prog) == 0)
	 *	goto skip_exec_of_prog;
	 */
@@ -729,9 +732,6 @@ static int invoke_bpf_prog(struct bpf_tramp_link *l, int args_off, int retval_of
	/* nop reserved for conditional jump */
	emit(rv_nop(), ctx);

	/* store prog start time */
	emit_mv(RV_REG_S1, RV_REG_A0, ctx);

	/* arg1: &args_off */
	emit_addi(RV_REG_A0, RV_REG_FP, -args_off, ctx);
	if (!p->jited)
Loading