public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Daniel Borkmann <daniel@iogearbox•net>
To: William Tu <u9012063@gmail•com>
Cc: netdev@vger•kernel.org, alexei.starovoitov@gmail•com
Subject: Re: [PATCH net-next] bpf: fix verifier issue at check_packet_ptr_add
Date: Fri, 03 Feb 2017 00:46:37 +0100	[thread overview]
Message-ID: <5893C4DD.9000701@iogearbox.net> (raw)
In-Reply-To: <1486065553-5074-1-git-send-email-u9012063@gmail.com>

On 02/02/2017 08:59 PM, William Tu wrote:
> When adding a zero value to the packet pointer, the verifer
> reports the following error:
>
> R0=imm0,min_value=0,max_value=0 R1=pkt(id=0,off=0,r=4) R2=pkt_end R3=fp-12 R4=imm4,min_value=4,max_value=4 R5=pkt(id=0,off=4,r=4) R6=ctx R7=imm0,min_value=0,max_value=0 R8=inv,min_value=0,max_value=0 R9=inv R10=fp
> 269: (bf) r2 = r0
> 270: (77) r2 >>= 3
> 271: (bf) r4 = r1
> 272: (0f) r4 += r2
> addition of negative constant to packet pointer is not allowed

How do we get here? I mean compiler is not optimizing this away
as the reg is populated differently from various branches? Could
you elaborate more on that resp. how we end up with this? Thanks!

> Signed-off-by: William Tu <u9012063@gmail•com>
> Cc: Daniel Borkmann <daniel@iogearbox•net>
> ---
>   kernel/bpf/verifier.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index fb3513b..1a754e5 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -1397,7 +1397,7 @@ static int check_packet_ptr_add(struct bpf_verifier_env *env,
>   		imm = insn->imm;
>
>   add_imm:
> -		if (imm <= 0) {
> +		if (imm < 0) {
>   			verbose("addition of negative constant to packet pointer is not allowed\n");
>   			return -EACCES;
>   		}
>

  reply	other threads:[~2017-02-02 23:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-02 19:59 [PATCH net-next] bpf: fix verifier issue at check_packet_ptr_add William Tu
2017-02-02 23:46 ` Daniel Borkmann [this message]
2017-02-03  3:26   ` William Tu
2017-02-03  3:46     ` Alexei Starovoitov
2017-02-03  5:31       ` William Tu
2017-02-03  6:19         ` Alexei Starovoitov
2017-02-03 16:20           ` William Tu
2017-02-03  8:37         ` Daniel Borkmann

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=5893C4DD.9000701@iogearbox.net \
    --to=daniel@iogearbox$(echo .)net \
    --cc=alexei.starovoitov@gmail$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=u9012063@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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