lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191218095825.GA15840@Omicron>
Date:   Wed, 18 Dec 2019 10:58:25 +0100
From:   Paul Chaignon <paul.chaignon@...nge.com>
To:     Alexander Lobakin <alobakin@...nk.ru>
Cc:     Paul Burton <paulburton@...nel.org>,
        Björn Töpel <bjorn.topel@...il.com>,
        Mahshid Khezri <khezri.mahshid@...il.com>,
        paul.chaignon@...il.com, bpf@...r.kernel.org,
        netdev@...r.kernel.org, Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Martin KaFai Lau <kafai@...com>,
        Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
        Andrii Nakryiko <andriin@...com>
Subject: Re: [PATCH bpf 2/2] bpf, mips: limit to 33 tail calls

On Wed, Dec 18, 2019 at 12:32:53PM +0300, Alexander Lobakin wrote:
> Paul Burton wrote 11.12.2019 02:23:
> > Hi Paul,
> > 
> > On Mon, Dec 09, 2019 at 07:52:52PM +0100, Paul Chaignon wrote:
> > > All BPF JIT compilers except RISC-V's and MIPS' enforce a 33-tail
> > > calls
> > > limit at runtime.  In addition, a test was recently added, in
> > > tailcalls2,
> > > to check this limit.
> > > 
> > > This patch updates the tail call limit in MIPS' JIT compiler to allow
> > > 33 tail calls.
> 
> Hi Paul,
> 
> You've restored MIPS cBPF in mips-fixes tree, doesn't it require any
> changes to limit tail calls to 33? This series includes only eBPF as
> there was no MIPS cBPF at the moment of writing.

cBPF doesn't support tail calls or even the call instruction for
helpers.

Paul C.

> 
> > > Fixes: b6bd53f9c4e8 ("MIPS: Add missing file for eBPF JIT.")
> > > Reported-by: Mahshid Khezri <khezri.mahshid@...il.com>
> > > Signed-off-by: Paul Chaignon <paul.chaignon@...nge.com>
> > 
> > I'd be happy to take this through mips-fixes, but equally happy for it
> > to go through the BPF/net trees in which case:
> > 
> >   Acked-by: Paul Burton <paulburton@...nel.org>
> > 
> > Thanks,
> >     Paul
> > 
> > > ---
> > >  arch/mips/net/ebpf_jit.c | 9 +++++----
> > >  1 file changed, 5 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/arch/mips/net/ebpf_jit.c b/arch/mips/net/ebpf_jit.c
> > > index 46b76751f3a5..3ec69d9cbe88 100644
> > > --- a/arch/mips/net/ebpf_jit.c
> > > +++ b/arch/mips/net/ebpf_jit.c
> > > @@ -604,6 +604,7 @@ static void emit_const_to_reg(struct jit_ctx
> > > *ctx, int dst, u64 value)
> > >  static int emit_bpf_tail_call(struct jit_ctx *ctx, int this_idx)
> > >  {
> > >  	int off, b_off;
> > > +	int tcc_reg;
> > > 
> > >  	ctx->flags |= EBPF_SEEN_TC;
> > >  	/*
> > > @@ -616,14 +617,14 @@ static int emit_bpf_tail_call(struct jit_ctx
> > > *ctx, int this_idx)
> > >  	b_off = b_imm(this_idx + 1, ctx);
> > >  	emit_instr(ctx, bne, MIPS_R_AT, MIPS_R_ZERO, b_off);
> > >  	/*
> > > -	 * if (--TCC < 0)
> > > +	 * if (TCC-- < 0)
> > >  	 *     goto out;
> > >  	 */
> > >  	/* Delay slot */
> > > -	emit_instr(ctx, daddiu, MIPS_R_T5,
> > > -		   (ctx->flags & EBPF_TCC_IN_V1) ? MIPS_R_V1 : MIPS_R_S4, -1);
> > > +	tcc_reg = (ctx->flags & EBPF_TCC_IN_V1) ? MIPS_R_V1 : MIPS_R_S4;
> > > +	emit_instr(ctx, daddiu, MIPS_R_T5, tcc_reg, -1);
> > >  	b_off = b_imm(this_idx + 1, ctx);
> > > -	emit_instr(ctx, bltz, MIPS_R_T5, b_off);
> > > +	emit_instr(ctx, bltz, tcc_reg, b_off);
> > >  	/*
> > >  	 * prog = array->ptrs[index];
> > >  	 * if (prog == NULL)
> > > --
> > > 2.17.1
> > > 
> 
> Regards,
> ᚷ ᛖ ᚢ ᚦ ᚠ ᚱ

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ