Commit 0c9fc2ed authored by David S. Miller's avatar David S. Miller
Browse files


Daniel Borkmann says:

====================
pull-request: bpf 2021-02-13

The following pull-request contains BPF updates for your *net* tree.

We've added 2 non-merge commits during the last 3 day(s) which contain
a total of 2 files changed, 9 insertions(+), 11 deletions(-).

The main changes are:

1) Fix mod32 truncation handling in verifier, from Daniel Borkmann.

2) Fix XDP redirect tests to explicitly use bash, from Björn Töpel.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 308daa19 9b00f1b7
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -11006,7 +11006,7 @@ static int fixup_bpf_calls(struct bpf_verifier_env *env)
			bool isdiv = BPF_OP(insn->code) == BPF_DIV;
			struct bpf_insn *patchlet;
			struct bpf_insn chk_and_div[] = {
				/* Rx div 0 -> 0 */
				/* [R,W]x div 0 -> 0 */
				BPF_RAW_INSN((is64 ? BPF_JMP : BPF_JMP32) |
					     BPF_JNE | BPF_K, insn->src_reg,
					     0, 2, 0),
@@ -11015,16 +11015,18 @@ static int fixup_bpf_calls(struct bpf_verifier_env *env)
				*insn,
			};
			struct bpf_insn chk_and_mod[] = {
				/* Rx mod 0 -> Rx */
				/* [R,W]x mod 0 -> [R,W]x */
				BPF_RAW_INSN((is64 ? BPF_JMP : BPF_JMP32) |
					     BPF_JEQ | BPF_K, insn->src_reg,
					     0, 1, 0),
					     0, 1 + (is64 ? 0 : 1), 0),
				*insn,
				BPF_JMP_IMM(BPF_JA, 0, 0, 1),
				BPF_MOV32_REG(insn->dst_reg, insn->dst_reg),
			};

			patchlet = isdiv ? chk_and_div : chk_and_mod;
			cnt = isdiv ? ARRAY_SIZE(chk_and_div) :
				      ARRAY_SIZE(chk_and_mod);
				      ARRAY_SIZE(chk_and_mod) - (is64 ? 2 : 0);

			new_prog = bpf_patch_insn_data(env, i + delta, patchlet, cnt);
			if (!new_prog)
+3 −7
Original line number Diff line number Diff line
#!/bin/sh
#!/bin/bash
# Create 2 namespaces with two veth peers, and
# forward packets in-between using generic XDP
#
@@ -57,12 +57,8 @@ test_xdp_redirect()
	ip link set dev veth1 $xdpmode obj test_xdp_redirect.o sec redirect_to_222 &> /dev/null
	ip link set dev veth2 $xdpmode obj test_xdp_redirect.o sec redirect_to_111 &> /dev/null

	ip netns exec ns1 ping -c 1 10.1.1.22 &> /dev/null
	local ret1=$?
	ip netns exec ns2 ping -c 1 10.1.1.11 &> /dev/null
	local ret2=$?

	if [ $ret1 -eq 0 -a $ret2 -eq 0 ]; then
	if ip netns exec ns1 ping -c 1 10.1.1.22 &> /dev/null &&
	   ip netns exec ns2 ping -c 1 10.1.1.11 &> /dev/null; then
		echo "selftests: test_xdp_redirect $xdpmode [PASS]";
	else
		ret=1