Commit cbba5d1b authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull bpf fixes from Alexei Starovoitov:

 - Fix interaction between livepatch and BPF fexit programs (Song Liu)
   With Steven and Masami acks.

 - Fix stack ORC unwind from BPF kprobe_multi (Jiri Olsa)
   With Steven and Masami acks.

 - Fix out of bounds access in widen_imprecise_scalars() in the verifier
   (Eduard Zingerman)

 - Fix conflicts between MPTCP and BPF sockmap (Jiayuan Chen)

 - Fix net_sched storage collision with BPF data_meta/data_end (Eric
   Dumazet)

 - Add _impl suffix to BPF kfuncs with implicit args to avoid breaking
   them in bpf-next when KF_IMPLICIT_ARGS is added (Mykyta Yatsenko)

* tag 'bpf-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf:
  selftests/bpf: Test widen_imprecise_scalars() with different stack depth
  bpf: account for current allocated stack depth in widen_imprecise_scalars()
  bpf: Add bpf_prog_run_data_pointers()
  selftests/bpf: Add mptcp test with sockmap
  mptcp: Fix proto fallback detection with BPF
  mptcp: Disallow MPTCP subflows from sockmap
  selftests/bpf: Add stacktrace ips test for raw_tp
  selftests/bpf: Add stacktrace ips test for kprobe_multi/kretprobe_multi
  x86/fgraph,bpf: Fix stack ORC unwind from kprobe_multi return probe
  Revert "perf/x86: Always store regs->ip in perf_callchain_kernel()"
  bpf: add _impl suffix for bpf_stream_vprintk() kfunc
  bpf:add _impl suffix for bpf_task_work_schedule* kfuncs
  selftests/bpf: Add tests for livepatch + bpf trampoline
  ftrace: bpf: Fix IPMODIFY + DIRECT in modify_ftrace_direct()
  ftrace: Fix BPF fexit with livepatch
parents a752782a 6c762611
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -2789,13 +2789,13 @@ perf_callchain_kernel(struct perf_callchain_entry_ctx *entry, struct pt_regs *re
		return;
	}

	if (perf_hw_regs(regs)) {
		if (perf_callchain_store(entry, regs->ip))
			return;

	if (perf_hw_regs(regs))
		unwind_start(&state, current, regs, NULL);
	else
	} else {
		unwind_start(&state, current, NULL, (void *)regs->sp);
	}

	for (; !unwind_done(&state); unwind_next_frame(&state)) {
		addr = unwind_get_return_address(&state);
+5 −0
Original line number Diff line number Diff line
@@ -56,6 +56,11 @@ arch_ftrace_get_regs(struct ftrace_regs *fregs)
	return &arch_ftrace_regs(fregs)->regs;
}

#define arch_ftrace_partial_regs(regs) do {	\
	regs->flags &= ~X86_EFLAGS_FIXED;	\
	regs->cs = __KERNEL_CS;			\
} while (0)

#define arch_ftrace_fill_perf_regs(fregs, _regs) do {	\
		(_regs)->ip = arch_ftrace_regs(fregs)->regs.ip;		\
		(_regs)->sp = arch_ftrace_regs(fregs)->regs.sp;		\
+7 −1
Original line number Diff line number Diff line
@@ -354,12 +354,17 @@ SYM_CODE_START(return_to_handler)
	UNWIND_HINT_UNDEFINED
	ANNOTATE_NOENDBR

	/* Restore return_to_handler value that got eaten by previous ret instruction. */
	subq $8, %rsp
	UNWIND_HINT_FUNC

	/* Save ftrace_regs for function exit context  */
	subq $(FRAME_SIZE), %rsp

	movq %rax, RAX(%rsp)
	movq %rdx, RDX(%rsp)
	movq %rbp, RBP(%rsp)
	movq %rsp, RSP(%rsp)
	movq %rsp, %rdi

	call ftrace_return_to_handler
@@ -368,7 +373,8 @@ SYM_CODE_START(return_to_handler)
	movq RDX(%rsp), %rdx
	movq RAX(%rsp), %rax

	addq $(FRAME_SIZE), %rsp
	addq $(FRAME_SIZE) + 8, %rsp

	/*
	 * Jump back to the old return address. This cannot be JMP_NOSPEC rdi
	 * since IBT would demand that contain ENDBR, which simply isn't so for
+20 −0
Original line number Diff line number Diff line
@@ -901,6 +901,26 @@ static inline void bpf_compute_data_pointers(struct sk_buff *skb)
	cb->data_end  = skb->data + skb_headlen(skb);
}

static inline int bpf_prog_run_data_pointers(
	const struct bpf_prog *prog,
	struct sk_buff *skb)
{
	struct bpf_skb_data_end *cb = (struct bpf_skb_data_end *)skb->cb;
	void *save_data_meta, *save_data_end;
	int res;

	save_data_meta = cb->data_meta;
	save_data_end = cb->data_end;

	bpf_compute_data_pointers(skb);
	res = bpf_prog_run(prog, skb);

	cb->data_meta = save_data_meta;
	cb->data_end = save_data_end;

	return res;
}

/* Similar to bpf_compute_data_pointers(), except that save orginal
 * data in cb->data and cb->meta_data for restore.
 */
+9 −1
Original line number Diff line number Diff line
@@ -193,6 +193,10 @@ static __always_inline struct pt_regs *ftrace_get_regs(struct ftrace_regs *fregs
#if !defined(CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS) || \
	defined(CONFIG_HAVE_FTRACE_REGS_HAVING_PT_REGS)

#ifndef arch_ftrace_partial_regs
#define arch_ftrace_partial_regs(regs) do {} while (0)
#endif

static __always_inline struct pt_regs *
ftrace_partial_regs(struct ftrace_regs *fregs, struct pt_regs *regs)
{
@@ -202,7 +206,11 @@ ftrace_partial_regs(struct ftrace_regs *fregs, struct pt_regs *regs)
	 * Since arch_ftrace_get_regs() will check some members and may return
	 * NULL, we can not use it.
	 */
	return &arch_ftrace_regs(fregs)->regs;
	regs = &arch_ftrace_regs(fregs)->regs;

	/* Allow arch specific updates to regs. */
	arch_ftrace_partial_regs(regs);
	return regs;
}

#endif /* !CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS || CONFIG_HAVE_FTRACE_REGS_HAVING_PT_REGS */
Loading