From: Jann Horn <jannh@google.com>
To: Daniel Borkmann <daniel@iogearbox.net>
Cc: Alexei Starovoitov <ast@fb.com>,
bpf@vger.kernel.org, Network Development <netdev@vger.kernel.org>,
joe@wand.net.nz, john.fastabend@gmail.com, tgraf@suug.ch,
yhs@fb.com, andriin@fb.com, jakub.kicinski@netronome.com,
lmb@cloudflare.com
Subject: Re: [PATCH bpf-next v2 1/7] bpf: implement lookup-free direct value access
Date: Fri, 1 Mar 2019 04:33:44 +0100 [thread overview]
Message-ID: <CAG48ez1_LiFVJkTXPhgF_aD+c+20iwzduqb7m13TyShUUwMnUw@mail.gmail.com> (raw)
In-Reply-To: <20190228231829.11993-2-daniel@iogearbox.net>
On Fri, Mar 1, 2019 at 12:19 AM Daniel Borkmann <daniel@iogearbox.net> wrote:
> This generic extension to BPF maps allows for directly loading an
> address residing inside a BPF map value as a single BPF ldimm64
> instruction.
[...]
> @@ -6698,16 +6705,44 @@ static int replace_map_fd_with_map_ptr(struct bpf_verifier_env *env)
> return err;
> }
>
> - /* store map pointer inside BPF_LD_IMM64 instruction */
> - insn[0].imm = (u32) (unsigned long) map;
> - insn[1].imm = ((u64) (unsigned long) map) >> 32;
> + aux = &env->insn_aux_data[i];
> + if (insn->src_reg == BPF_PSEUDO_MAP_FD) {
> + addr = (unsigned long)map;
> + } else {
> + u32 off = insn[1].imm;
> +
> + if (off >= BPF_MAX_VAR_OFF) {
> + verbose(env, "direct value offset of %u is not allowed\n",
> + off);
> + return -EINVAL;
> + }
> + if (!map->ops->map_direct_value_access) {
> + verbose(env, "no direct value access support for this map type\n");
> + return -EINVAL;
> + }
> +
> + err = map->ops->map_direct_value_access(map, off, &addr);
> + if (err) {
> + verbose(env, "invalid access to map value pointer, value_size=%u off=%u\n",
> + map->value_size, off);
> + return err;
> + }
All these error returns need fdput(f), I think.
next prev parent reply other threads:[~2019-03-01 18:01 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-28 23:18 [PATCH bpf-next v2 0/7] BPF support for global data Daniel Borkmann
2019-02-28 23:18 ` [PATCH bpf-next v2 1/7] bpf: implement lookup-free direct value access Daniel Borkmann
2019-03-01 3:33 ` Jann Horn [this message]
2019-03-01 3:58 ` kbuild test robot
2019-03-01 5:46 ` Andrii Nakryiko
2019-03-01 9:49 ` Daniel Borkmann
2019-03-01 18:50 ` Jakub Kicinski
2019-03-01 19:35 ` Andrii Nakryiko
2019-03-01 20:08 ` Jakub Kicinski
2019-03-01 17:18 ` Yonghong Song
2019-03-01 19:51 ` Daniel Borkmann
2019-03-01 23:02 ` Yonghong Song
2019-03-04 6:03 ` Andrii Nakryiko
2019-03-04 15:59 ` Daniel Borkmann
2019-03-04 17:32 ` Andrii Nakryiko
2019-02-28 23:18 ` [PATCH bpf-next v2 2/7] bpf: add program side {rd,wr}only support Daniel Borkmann
2019-03-01 3:51 ` Jakub Kicinski
2019-03-01 9:01 ` Daniel Borkmann
2019-02-28 23:18 ` [PATCH bpf-next v2 3/7] bpf, obj: allow . char as part of the name Daniel Borkmann
2019-03-01 5:52 ` Andrii Nakryiko
2019-03-01 9:04 ` Daniel Borkmann
2019-02-28 23:18 ` [PATCH bpf-next v2 4/7] bpf, libbpf: refactor relocation handling Daniel Borkmann
2019-02-28 23:18 ` [PATCH bpf-next v2 5/7] bpf, libbpf: support global data/bss/rodata sections Daniel Borkmann
2019-02-28 23:41 ` Stanislav Fomichev
2019-03-01 0:19 ` Daniel Borkmann
2019-03-02 0:23 ` Yonghong Song
2019-03-02 0:27 ` Daniel Borkmann
2019-03-01 6:53 ` Andrii Nakryiko
2019-03-01 10:46 ` Daniel Borkmann
2019-03-01 18:10 ` Stanislav Fomichev
2019-03-01 18:46 ` Andrii Nakryiko
2019-03-01 18:11 ` Yonghong Song
2019-03-01 18:48 ` Andrii Nakryiko
2019-03-01 18:58 ` Yonghong Song
2019-03-01 19:10 ` Andrii Nakryiko
2019-03-01 19:19 ` Yonghong Song
2019-03-01 20:06 ` Daniel Borkmann
2019-03-01 20:25 ` Yonghong Song
2019-03-01 20:33 ` Daniel Borkmann
2019-03-05 2:28 ` static bpf vars. Was: " Alexei Starovoitov
2019-03-05 9:31 ` Daniel Borkmann
2019-03-01 19:56 ` Daniel Borkmann
2019-02-28 23:18 ` [PATCH bpf-next v2 6/7] bpf, selftest: test " Daniel Borkmann
2019-03-01 19:13 ` Andrii Nakryiko
2019-03-01 20:02 ` Daniel Borkmann
2019-03-04 8:48 ` [LKP] [bpf, selftest] 4beb1a5f45: kernel_selftests.bpf.make_fail kernel test robot
2019-02-28 23:18 ` [PATCH bpf-next v2 7/7] bpf, selftest: test {rd,wr}only flags and direct value access 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=CAG48ez1_LiFVJkTXPhgF_aD+c+20iwzduqb7m13TyShUUwMnUw@mail.gmail.com \
--to=jannh@google.com \
--cc=andriin@fb.com \
--cc=ast@fb.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=jakub.kicinski@netronome.com \
--cc=joe@wand.net.nz \
--cc=john.fastabend@gmail.com \
--cc=lmb@cloudflare.com \
--cc=netdev@vger.kernel.org \
--cc=tgraf@suug.ch \
--cc=yhs@fb.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).