[PATCH] ebpf: emit correct src_reg for conditional jumps

2015-09-10 Thread Tycho Andersen
Instead of always emitting BPF_REG_X, let's emit BPF_REG_X only when the source actually is BPF_X. This causes programs generated by the classic converter to not be importable via bpf(), as the eBPF verifier checks that the src_reg is correct or 0. While not a problem yet, this will be a problem wh

Re: [PATCH] ebpf: emit correct src_reg for conditional jumps

2015-09-11 Thread Daniel Borkmann
On 09/11/2015 02:25 AM, Tycho Andersen wrote: Instead of always emitting BPF_REG_X, let's emit BPF_REG_X only when the source actually is BPF_X. This causes programs generated by the classic converter to not be importable via bpf(), as the eBPF verifier checks that the src_reg is correct or 0. Wh

Re: [PATCH] ebpf: emit correct src_reg for conditional jumps

2015-09-11 Thread Daniel Borkmann
On 09/11/2015 10:45 AM, Daniel Borkmann wrote: On 09/11/2015 02:25 AM, Tycho Andersen wrote: Instead of always emitting BPF_REG_X, let's emit BPF_REG_X only when the source actually is BPF_X. This causes programs generated by the classic converter to not be importable via bpf(), as the eBPF veri

Re: [PATCH] ebpf: emit correct src_reg for conditional jumps

2015-09-11 Thread Alexei Starovoitov
On Fri, Sep 11, 2015 at 11:28:24AM +0200, Daniel Borkmann wrote: > [off topic for this patch] > > ... this requirement also breaks down for cases where you have a single > classic BPF instruction that maps into 2 or more eBPF instructions, hitting > BPF_MAXINSNS early at the time when you try to c

Re: [PATCH] ebpf: emit correct src_reg for conditional jumps

2015-09-11 Thread Tycho Andersen
On Fri, Sep 11, 2015 at 08:40:43AM -0700, Alexei Starovoitov wrote: > On Fri, Sep 11, 2015 at 11:28:24AM +0200, Daniel Borkmann wrote: > > [off topic for this patch] > > > > ... this requirement also breaks down for cases where you have a single > > classic BPF instruction that maps into 2 or more

Re: [PATCH] ebpf: emit correct src_reg for conditional jumps

2015-09-11 Thread Daniel Borkmann
On 09/11/2015 05:50 PM, Tycho Andersen wrote: On Fri, Sep 11, 2015 at 08:40:43AM -0700, Alexei Starovoitov wrote: On Fri, Sep 11, 2015 at 11:28:24AM +0200, Daniel Borkmann wrote: [off topic for this patch] ... this requirement also breaks down for cases where you have a single classic BPF inst

Re: [PATCH] ebpf: emit correct src_reg for conditional jumps

2015-09-11 Thread David Miller
From: Tycho Andersen Date: Thu, 10 Sep 2015 18:25:07 -0600 > Instead of always emitting BPF_REG_X, let's emit BPF_REG_X only when the > source actually is BPF_X. This causes programs generated by the classic > converter to not be importable via bpf(), as the eBPF verifier checks that > the src_re