[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAADnVQ+woTCQ5JaEJvtWWsgU5OC+EA9NuRXhd2RmywU6mEYoEg@mail.gmail.com>
Date: Tue, 8 Sep 2020 09:20:21 -0700
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Daniel Borkmann <daniel@...earbox.net>
Cc: Alexei Starovoitov <ast@...nel.org>, bryce.kahle@...adoghq.com,
Network Development <netdev@...r.kernel.org>,
bpf <bpf@...r.kernel.org>
Subject: Re: [PATCH bpf] bpf: Fix clobbering of r2 in bpf_gen_ld_abs
On Mon, Sep 7, 2020 at 3:04 PM Daniel Borkmann <daniel@...earbox.net> wrote:
>
> Bryce reported that he saw the following with:
>
> 0: r6 = r1
> 1: r1 = 12
> 2: r0 = *(u16 *)skb[r1]
>
> The xlated sequence was incorrectly clobbering r2 with pointer
> value of r6 ...
>
> 0: (bf) r6 = r1
> 1: (b7) r1 = 12
> 2: (bf) r1 = r6
> 3: (bf) r2 = r1
> 4: (85) call bpf_skb_load_helper_16_no_cache#7692160
>
> ... and hence call to the load helper never succeeded given the
> offset was too high. Fix it by reordering the load of r6 to r1.
>
> Other than that the insn has similar calling convention than BPF
> helpers, that is, r0 - r5 are scratch regs, so nothing else
> affected after the insn.
>
> Fixes: e0cea7ce988c ("bpf: implement ld_abs/ld_ind in native bpf")
> Reported-by: Bryce Kahle <bryce.kahle@...adoghq.com>
> Signed-off-by: Daniel Borkmann <daniel@...earbox.net>
Applied. Thanks
Powered by blists - more mailing lists