All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martin KaFai Lau <martin.lau@linux.dev>
To: Yonghong Song <yhs@fb.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	kernel-team@fb.com, Martin KaFai Lau <martin.lau@kernel.org>,
	bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v9 0/4] bpf: Add bpf_rcu_read_lock() support
Date: Wed, 23 Nov 2022 15:30:33 -0800	[thread overview]
Message-ID: <0bb01f0e-c19f-ad96-80e8-a51679f170c8@linux.dev> (raw)
In-Reply-To: <20221123045350.2322811-1-yhs@fb.com>

On 11/22/22 8:53 PM, Yonghong Song wrote:
> Currently, without rcu attribute info in BTF, the verifier treats
> rcu tagged pointer as a normal pointer. This might be a problem
> for sleepable program where rcu_read_lock()/unlock() is not available.
> For example, for a sleepable fentry program, if rcu protected memory
> access is interleaved with a sleepable helper/kfunc, it is possible
> the memory access after the sleepable helper/kfunc might be invalid
> since the object might have been freed then. Even without
> a sleepable helper/kfunc, without rcu_read_lock() protection,
> it is possible that the rcu protected object might be release
> in the middle of bpf program execution which may cause incorrect
> result.
> 
> To prevent above cases, enable btf_type_tag("rcu") attributes,
> introduce new bpf_rcu_read_lock/unlock() kfuncs and add verifier support.
> 
> In the rest of patch set, Patch 1 enabled btf_type_tag for __rcu
> attribute. Patche 2 added might_sleep in bpf_func_proto. Patch 3 added new
> bpf_rcu_read_lock/unlock() kfuncs and verifier support.
> Patch 4 added some tests for these two new kfuncs.
> 
> Changelogs:
>    v8 -> v9:
>      . remove sleepable prog check for ld_abs/ind checking in rcu read
>        lock region.
>      . fix a test failure with gcc-compiled kernel.
>      . a couple of other minor fixes.

Acked-by: Martin KaFai Lau <martin.lau@kernel.org>


      parent reply	other threads:[~2022-11-23 23:30 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-23  4:53 [PATCH bpf-next v9 0/4] bpf: Add bpf_rcu_read_lock() support Yonghong Song
2022-11-23  4:53 ` [PATCH bpf-next v9 1/4] compiler_types: Define __rcu as __attribute__((btf_type_tag("rcu"))) Yonghong Song
2022-11-23  4:54 ` [PATCH bpf-next v9 2/4] bpf: Introduce might_sleep field in bpf_func_proto Yonghong Song
2022-11-23  4:54 ` [PATCH bpf-next v9 3/4] bpf: Add kfunc bpf_rcu_read_lock/unlock() Yonghong Song
2022-11-23 23:32   ` Martin KaFai Lau
2022-11-24  1:40   ` Alexei Starovoitov
2022-11-24  2:57     ` Yonghong Song
2022-11-24  4:09       ` Alexei Starovoitov
2022-11-24  5:16         ` Yonghong Song
2022-11-23  4:54 ` [PATCH bpf-next v9 4/4] selftests/bpf: Add tests for bpf_rcu_read_lock() Yonghong Song
2022-11-23 23:30 ` Martin KaFai Lau [this message]

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=0bb01f0e-c19f-ad96-80e8-a51679f170c8@linux.dev \
    --to=martin.lau@linux.dev \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.com \
    --cc=martin.lau@kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.