From: Eduard Zingerman <eddyz87@gmail.com>
To: Leon Hwang <leon.hwang@linux.dev>, bpf@vger.kernel.org
Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
toke@redhat.com, martin.lau@kernel.org, yonghong.song@linux.dev,
puranjay@kernel.org, xukuohai@huaweicloud.com,
iii@linux.ibm.com, kernel-patches-bot@fb.com
Subject: Re: [PATCH bpf-next v4 0/4] bpf: Fix tailcall infinite loop caused by freplace
Date: Tue, 01 Oct 2024 04:14:08 -0700 [thread overview]
Message-ID: <1ea99d1e31c3f52f8962b186a150dfb0ffd23e45.camel@gmail.com> (raw)
In-Reply-To: <20240929132757.79826-1-leon.hwang@linux.dev>
On Sun, 2024-09-29 at 21:27 +0800, Leon Hwang wrote:
> Previously, I fixed a tailcall infinite loop issue caused by trampoline[0].
>
> At this time, I fix a tailcall infinite loop issue caused by tailcall and
> freplace combination by preventing updating extended prog to prog_array map
> and preventing extending tail callee prog with freplace:
>
> 1. If a prog or its subprog has been extended by freplace prog, the prog
> can not be updated to prog_array map.
> 2. If a prog has been updated to prog_array map, it or its subprog can not
> be extended by freplace prog.
So, once this series is applied we essentially have:
- three variables:
- tgt_prog->aux->is_extended
- tgt_prog->aux->prog_array_member_cnt
- trampoline->extension_prog
- four operations:
- link/attach extension program 'prog' using trampoline 'tr'
- unlink/detach extension program 'prog' using trampoline 'tr'
- put program 'tgt_prog' into prog array
- remove program 'tgt_prog' from prog array
And above four operations have the following pseudo-code with regards
to update of the variables:
- link/attach extension program 'prog' using trampoline 'tr':
with lock(tgt_prog->ext_mutex):
if tgt_prog->aux->prog_array_member_cnt:
return error
if tr->extension_prog:
return error
tr->extension_prog = prog
tgt_prog->is_extended = true
- unlink/detach extension program 'prog' using trampoline 'tr':
with lock(tgt_prog->ext_mutex):
tr->extension_prog = NULL
tgt_prog->is_extended = false
- put program 'tgt_prog' into prog array:
with lock(tgt_prog->ext_mutex):
if tgt_prog->aux->is_extended:
return error
tgt_prog->aux->prog_array_member_cnt++
- remove program 'tgt_prog' from prog array:
with lock(tgt_prog->ext_mutex):
tgt_prog->aux->prog_array_member_cnt--
I think this is correct, would be great if someone with more
concurrency related experience would take a look.
[...]
prev parent reply other threads:[~2024-10-01 11:14 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-29 13:27 [PATCH bpf-next v4 0/4] bpf: Fix tailcall infinite loop caused by freplace Leon Hwang
2024-09-29 13:27 ` [PATCH bpf-next v4 1/4] bpf: Prevent updating extended prog to prog_array map Leon Hwang
2024-10-01 11:13 ` Eduard Zingerman
2024-10-01 13:20 ` Leon Hwang
2024-10-01 16:54 ` Eduard Zingerman
2024-09-29 13:27 ` [PATCH bpf-next v4 2/4] bpf: Prevent extending tail callee prog with freplace prog Leon Hwang
2024-09-30 1:53 ` Leon Hwang
2024-10-04 19:33 ` Alexei Starovoitov
2024-10-04 20:37 ` Eduard Zingerman
2024-10-04 20:52 ` Eduard Zingerman
2024-10-04 23:30 ` Alexei Starovoitov
2024-09-29 13:27 ` [PATCH bpf-next v4 3/4] selftests/bpf: Add a test case to confirm a tailcall infinite loop issue has been prevented Leon Hwang
2024-09-29 13:27 ` [PATCH bpf-next v4 4/4] selftests/bpf: Add cases to test tailcall in freplace Leon Hwang
2024-10-01 11:14 ` Eduard Zingerman [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=1ea99d1e31c3f52f8962b186a150dfb0ffd23e45.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=iii@linux.ibm.com \
--cc=kernel-patches-bot@fb.com \
--cc=leon.hwang@linux.dev \
--cc=martin.lau@kernel.org \
--cc=puranjay@kernel.org \
--cc=toke@redhat.com \
--cc=xukuohai@huaweicloud.com \
--cc=yonghong.song@linux.dev \
/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