From: Tejun Heo <tj@kernel.org>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: davem@davemloft.net, daniel@iogearbox.net, andrii@kernel.org,
martin.lau@kernel.org, void@manifault.com,
davemarchevsky@meta.com, memxor@gmail.com,
netdev@vger.kernel.org, bpf@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH v3 bpf-next 2/5] bpf: Mark cgroups and dfl_cgrp fields as trusted.
Date: Tue, 28 Feb 2023 09:32:38 -1000 [thread overview]
Message-ID: <Y/5W1ju2DfmaxCIB@slm.duckdns.org> (raw)
In-Reply-To: <20230228040121.94253-3-alexei.starovoitov@gmail.com>
On Mon, Feb 27, 2023 at 08:01:18PM -0800, Alexei Starovoitov wrote:
> From: Alexei Starovoitov <ast@kernel.org>
>
> bpf programs sometimes do:
> bpf_cgrp_storage_get(&map, task->cgroups->dfl_cgrp, ...);
> It is safe to do, because cgroups->dfl_cgrp pointer is set diring init and
^
u
> never changes. The task->cgroups is also never NULL. It is also set during init
> and will change when task switches cgroups. For any trusted task pointer
> dereference of cgroups and dfl_cgrp should yield trusted pointers. The verifier
> wasn't aware of this. Hence in gcc compiled kernels task->cgroups dereference
> was producing PTR_TO_BTF_ID without modifiers while in clang compiled kernels
> the verifier recognizes __rcu tag in cgroups field and produces
> PTR_TO_BTF_ID | MEM_RCU | MAYBE_NULL.
> Tag cgroups and dfl_cgrp as trusted to equalize clang and gcc behavior.
> When GCC supports btf_type_tag such tagging will done directly in the type.
>
> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Tejun Heo <tj@kernel.org>
Thanks.
--
tejun
next prev parent reply other threads:[~2023-02-28 19:32 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-28 4:01 [PATCH v3 bpf-next 0/5] bpf: Introduce kptr_rcu Alexei Starovoitov
2023-02-28 4:01 ` [PATCH v3 bpf-next 1/5] bpf: Rename __kptr_ref -> __kptr and __kptr -> __kptr_untrusted Alexei Starovoitov
2023-02-28 15:16 ` David Vernet
2023-02-28 4:01 ` [PATCH v3 bpf-next 2/5] bpf: Mark cgroups and dfl_cgrp fields as trusted Alexei Starovoitov
2023-02-28 16:45 ` David Vernet
2023-02-28 19:32 ` Tejun Heo [this message]
2023-02-28 4:01 ` [PATCH v3 bpf-next 3/5] bpf: Introduce kptr_rcu Alexei Starovoitov
2023-02-28 16:45 ` David Vernet
2023-02-28 19:49 ` Alexei Starovoitov
2023-02-28 20:05 ` David Vernet
2023-02-28 19:39 ` Tejun Heo
2023-02-28 4:01 ` [PATCH v3 bpf-next 4/5] selftests/bpf: Add a test case for kptr_rcu Alexei Starovoitov
2023-02-28 16:52 ` David Vernet
2023-02-28 4:01 ` [PATCH v3 bpf-next 5/5] selftests/bpf: Tweak cgroup kfunc test Alexei Starovoitov
2023-02-28 17:07 ` David Vernet
2023-03-01 0:29 ` Alexei Starovoitov
2023-03-01 2:22 ` David Vernet
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=Y/5W1ju2DfmaxCIB@slm.duckdns.org \
--to=tj@kernel.org \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=davemarchevsky@meta.com \
--cc=kernel-team@fb.com \
--cc=martin.lau@kernel.org \
--cc=memxor@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=void@manifault.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).