[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ECD336F1-A130-47BA-8FBB-E3573445380F@fb.com>
Date: Wed, 6 Jul 2022 22:15:47 +0000
From: Song Liu <songliubraving@...com>
To: Steven Rostedt <rostedt@...dmis.org>
CC: Song Liu <song@...nel.org>, Networking <netdev@...r.kernel.org>,
bpf <bpf@...r.kernel.org>, lkml <linux-kernel@...r.kernel.org>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>,
Kernel Team <Kernel-team@...com>,
"jolsa@...nel.org" <jolsa@...nel.org>,
"mhiramat@...nel.org" <mhiramat@...nel.org>
Subject: Re: [PATCH v2 bpf-next 5/5] bpf: trampoline: support
FTRACE_OPS_FL_SHARE_IPMODIFY
> On Jul 6, 2022, at 2:40 PM, Steven Rostedt <rostedt@...dmis.org> wrote:
>
> On Wed, 6 Jul 2022 21:37:52 +0000
> Song Liu <songliubraving@...com> wrote:
>
>>> Can you comment here that returning -EAGAIN will not cause this to repeat.
>>> That it will change things where the next try will not return -EGAIN?
>>
>> Hmm.. this is not the guarantee here. This conflict is a real race condition
>> that an IPMODIFY function (i.e. livepatch) is being registered at the same time
>> when something else, for example bpftrace, is updating the BPF trampoline.
>>
>> This EAGAIN will propagate to the user of the IPMODIFY function (i.e. livepatch),
>> and we need to retry there. In the case of livepatch, the retry is initiated
>> from user space.
>
> We need to be careful here then. If there's a userspace application that
> runs at real-time and does a:
>
> do {
> errno = 0;
> regsiter_bpf();
> } while (errno != -EAGAIN);
Actually, do you mean:
do {
errno = 0;
regsiter_bpf();
} while (errno == -EAGAIN);
(== -EAGAIN) here?
In this specific race condition, register_bpf() will succeed, as it already
got tr->mutex. But the IPMODIFY (livepatch) side will fail and retry.
Since both livepatch and bpf trampoline changes are rare operations, I think
the chance of the race condition is low enough.
Does this make sense?
Thanks,
Song
Powered by blists - more mailing lists