bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Cc: bpf@vger.kernel.org, "Alexei Starovoitov" <ast@kernel.org>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Joanne Koong" <joannelkoong@gmail.com>,
	"Toke Høiland-Jørgensen" <toke@redhat.com>,
	"Jesper Dangaard Brouer" <brouer@redhat.com>
Subject: Re: [PATCH bpf-next v6 03/13] bpf: Allow storing referenced kptr in map
Date: Mon, 25 Apr 2022 20:30:44 -0700	[thread overview]
Message-ID: <20220426033044.ifygawcnigdmg25y@MBP-98dd607d3435.dhcp.thefacebook.com> (raw)
In-Reply-To: <20220424214901.2743946-4-memxor@gmail.com>

On Mon, Apr 25, 2022 at 03:18:51AM +0530, Kumar Kartikeya Dwivedi wrote:
> +
> +static u32 bpf_kptr_xchg_btf_id;
> +
> +const struct bpf_func_proto bpf_kptr_xchg_proto = {
> +	.func         = bpf_kptr_xchg,
> +	.gpl_only     = false,
> +	.ret_type     = RET_PTR_TO_BTF_ID_OR_NULL,
> +	.ret_btf_id   = &bpf_kptr_xchg_btf_id,
> +	.arg1_type    = ARG_PTR_TO_KPTR,
> +	.arg2_type    = ARG_PTR_TO_BTF_ID_OR_NULL | OBJ_RELEASE,
> +	.arg2_btf_id  = &bpf_kptr_xchg_btf_id,
> +};

I've tweaked above with:
+/* Unlike other PTR_TO_BTF_ID helpers the btf_id in bpf_kptr_xchg()
+ * helper is determined dynamically by the verifier.
+ */
+#define BPF_PTR_POISON ((void *)((0xeB9FUL << 2) + POISON_POINTER_DELTA))
+
+const struct bpf_func_proto bpf_kptr_xchg_proto = {
+       .func         = bpf_kptr_xchg,
+       .gpl_only     = false,
+       .ret_type     = RET_PTR_TO_BTF_ID_OR_NULL,
+       .ret_btf_id   = BPF_PTR_POISON,
+       .arg1_type    = ARG_PTR_TO_KPTR,
+       .arg2_type    = ARG_PTR_TO_BTF_ID_OR_NULL | OBJ_RELEASE,
+       .arg2_btf_id  = BPF_PTR_POISON,

  reply	other threads:[~2022-04-26  3:30 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-24 21:48 [PATCH bpf-next v6 00/13] Introduce typed pointer support in BPF maps Kumar Kartikeya Dwivedi
2022-04-24 21:48 ` [PATCH bpf-next v6 01/13] bpf: Allow storing unreferenced kptr in map Kumar Kartikeya Dwivedi
2022-04-24 21:48 ` [PATCH bpf-next v6 02/13] bpf: Tag argument to be released in bpf_func_proto Kumar Kartikeya Dwivedi
2022-04-24 21:48 ` [PATCH bpf-next v6 03/13] bpf: Allow storing referenced kptr in map Kumar Kartikeya Dwivedi
2022-04-26  3:30   ` Alexei Starovoitov [this message]
2022-04-24 21:48 ` [PATCH bpf-next v6 04/13] bpf: Prevent escaping of kptr loaded from maps Kumar Kartikeya Dwivedi
2022-04-24 21:48 ` [PATCH bpf-next v6 05/13] bpf: Adapt copy_map_value for multiple offset case Kumar Kartikeya Dwivedi
2022-04-24 21:48 ` [PATCH bpf-next v6 06/13] bpf: Populate pairs of btf_id and destructor kfunc in btf Kumar Kartikeya Dwivedi
2022-04-24 21:48 ` [PATCH bpf-next v6 07/13] bpf: Wire up freeing of referenced kptr Kumar Kartikeya Dwivedi
2022-04-24 21:48 ` [PATCH bpf-next v6 08/13] bpf: Teach verifier about kptr_get kfunc helpers Kumar Kartikeya Dwivedi
2022-04-24 21:48 ` [PATCH bpf-next v6 09/13] bpf: Make BTF type match stricter for release arguments Kumar Kartikeya Dwivedi
2022-04-24 21:48 ` [PATCH bpf-next v6 10/13] libbpf: Add kptr type tag macros to bpf_helpers.h Kumar Kartikeya Dwivedi
2022-04-24 21:48 ` [PATCH bpf-next v6 11/13] selftests/bpf: Add C tests for kptr Kumar Kartikeya Dwivedi
2022-04-24 21:49 ` [PATCH bpf-next v6 12/13] selftests/bpf: Add verifier " Kumar Kartikeya Dwivedi
2022-04-26  3:35   ` Alexei Starovoitov
2022-05-09 20:03     ` Kumar Kartikeya Dwivedi
2022-04-24 21:49 ` [PATCH bpf-next v6 13/13] selftests/bpf: Add test for strict BTF type check Kumar Kartikeya Dwivedi
2022-04-26  3:39   ` Alexei Starovoitov
2022-05-08 21:59     ` Alexei Starovoitov
2022-05-09 19:49       ` Kumar Kartikeya Dwivedi
2022-04-26  3:30 ` [PATCH bpf-next v6 00/13] Introduce typed pointer support in BPF maps patchwork-bot+netdevbpf

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=20220426033044.ifygawcnigdmg25y@MBP-98dd607d3435.dhcp.thefacebook.com \
    --to=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=brouer@redhat.com \
    --cc=daniel@iogearbox.net \
    --cc=joannelkoong@gmail.com \
    --cc=memxor@gmail.com \
    --cc=toke@redhat.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).