netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rabin Vincent <rabin@rab.in>
To: Daniel Borkmann <daniel@iogearbox.net>
Cc: David Laight <David.Laight@ACULAB.COM>,
	'Alexei Starovoitov' <alexei.starovoitov@gmail.com>,
	"davem@davemloft.net" <davem@davemloft.net>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"zlim.lnx@gmail.com" <zlim.lnx@gmail.com>,
	"yang.shi@linaro.org" <yang.shi@linaro.org>,
	"will.deacon@arm.com" <will.deacon@arm.com>,
	"catalin.marinas@arm.com" <catalin.marinas@arm.com>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH] arm64: net: bpf: don't BUG() on large shifts
Date: Fri, 8 Jan 2016 16:58:37 +0100	[thread overview]
Message-ID: <20160108155837.GA28291@debian> (raw)
In-Reply-To: <568E5EB0.8020102@iogearbox.net>

On Thu, Jan 07, 2016 at 01:48:48PM +0100, Daniel Borkmann wrote:
> The question is what is less risky in terms of uabi. To reject such
> filters with such K shift vals upfront in verifier, or to just allow
> [0, reg_size - 1] values and handle outliers silently. I think both
> might be possible, the latter just needs to be clearly specified in
> the documentation somewhere. If we go for the latter, then probably
> just rewriting that K value as masked one might seem better. Broken
> programs might then still be loadable (and still be broken) ... afaik
> in case of register (case of shifts with X) with large shift vals
> ARM64 is doing 'modulo reg_size' implicitly.

The case of what happens with such shifts with X is also already
architecture-specific, even when using the interpreters.  For example, the
following program returns 1 on ARM64 but 0 on ARM.

	BPF_STMT(BPF_LD | BPF_IMM, 1),
	BPF_STMT(BPF_LDX | BPF_IMM, 32),
	BPF_STMT(BPF_ALU | BPF_LSH | BPF_X, 0),
	BPF_STMT(BPF_RET | BPF_A, 0)

To start rejecting large K shifts in the verifier because they are
architecture-specific while continuing to allow the equally
architecture-specific large X shifts (because we can't verify them
statically) would be rather inconsistent.

If it is desired to enforce uniformity across architectures despite the
risk for subtly changing the behaviour of existing programs, then the
desired uniform semantics of these shifts should really be implemented
both for the K and X shifts, which would mean modifiying the interpreter
and the various arch JITs too.

  reply	other threads:[~2016-01-08 15:58 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-05 17:39 [PATCH] arm64: net: bpf: don't BUG() on large shifts Rabin Vincent
2016-01-05 17:55 ` Alexei Starovoitov
2016-01-06 20:31   ` Rabin Vincent
2016-01-06 22:12     ` Alexei Starovoitov
2016-01-07 11:07       ` David Laight
2016-01-07 12:48         ` Daniel Borkmann
2016-01-08 15:58           ` Rabin Vincent [this message]
2016-01-08 16:44             ` Daniel Borkmann
2016-01-08 19:18               ` Alexei Starovoitov
2016-01-08 15:44 ` Will Deacon
2016-01-08 19:09   ` Alexei Starovoitov
2016-01-12 17:17     ` Will Deacon
2016-01-12 19:23       ` Alexei Starovoitov
2016-01-13  4:45         ` Z Lim
2016-01-13 12:08           ` Will Deacon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160108155837.GA28291@debian \
    --to=rabin@rab.in \
    --cc=David.Laight@ACULAB.COM \
    --cc=alexei.starovoitov@gmail.com \
    --cc=catalin.marinas@arm.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=netdev@vger.kernel.org \
    --cc=will.deacon@arm.com \
    --cc=yang.shi@linaro.org \
    --cc=zlim.lnx@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).