Netdev List
 help / color / mirror / Atom feed
From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Alex Gartrell <agartrell@fb.com>
Cc: davem@davemloft.net, ast@kernel.org, daniel@iogearbox.net,
	netdev@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH net-next] ebpf: Allow dereferences of PTR_TO_STACK registers
Date: Thu, 23 Jul 2015 14:47:03 -0700	[thread overview]
Message-ID: <20150723214702.GA31886@Alexeis-MacBook-Pro.local> (raw)
In-Reply-To: <1437686680-1157510-1-git-send-email-agartrell@fb.com>

On Thu, Jul 23, 2015 at 02:24:40PM -0700, Alex Gartrell wrote:
>         mov %rsp, %r1           ; r1 = rsp
>         add $-8, %r1            ; r1 = rsp - 8
>         store_q $123, -8(%rsp)  ; *(u64*)r1 = 123  <- valid
>         store_q $123, (%r1)     ; *(u64*)r1 = 123  <- previously invalid
>         mov $0, %r0
>         exit                    ; Always need to exit
> 
> And we'd get the following error:
> 
> 	0: (bf) r1 = r10
> 	1: (07) r1 += -8
> 	2: (7a) *(u64 *)(r10 -8) = 999
> 	3: (7a) *(u64 *)(r1 +0) = 999
> 	R1 invalid mem access 'fp'
> 
> 	Unable to load program
> 
> We already know that a register is a stack address and the appropriate
> offset, so we should be able to validate those references as well.
> 
> Signed-off-by: Alex Gartrell <agartrell@fb.com>
> ---
>  kernel/bpf/verifier.c       |  6 ++++-
>  samples/bpf/test_verifier.c | 59 +++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 64 insertions(+), 1 deletion(-)

Looks good.
Acked-by: Alexei Starovoitov <ast@plumgrid.com>

> +			BPF_ST_MEM(BPF_DW, BPF_REG_1, 2, 0xfaceb00c),

nice constants :)

  reply	other threads:[~2015-07-23 21:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-23 21:24 [PATCH net-next] ebpf: Allow dereferences of PTR_TO_STACK registers Alex Gartrell
2015-07-23 21:47 ` Alexei Starovoitov [this message]
2015-07-27  7:54 ` David Miller

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=20150723214702.GA31886@Alexeis-MacBook-Pro.local \
    --to=alexei.starovoitov@gmail.com \
    --cc=agartrell@fb.com \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=kernel-team@fb.com \
    --cc=netdev@vger.kernel.org \
    /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