From: "Toke Høiland-Jørgensen" <toke@redhat.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Network Development <netdev@vger.kernel.org>,
bpf <bpf@vger.kernel.org>,
Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Subject: Re: [PATCH bpf] bpf: fix potential race in tail call compatibility check
Date: Fri, 22 Oct 2021 12:54:45 +0200 [thread overview]
Message-ID: <87mtn1cosq.fsf@toke.dk> (raw)
In-Reply-To: <CAADnVQLPBLc0T32nqM7Q_LBEGWiJRp3JvGaY2Lsmf9yqJW+Yfw@mail.gmail.com>
Alexei Starovoitov <alexei.starovoitov@gmail.com> writes:
> On Thu, Oct 21, 2021 at 11:40 AM Toke Høiland-Jørgensen <toke@redhat.com> wrote:
>> + map_type = READ_ONCE(array->aux->type);
>> + if (!map_type) {
>> + /* There's no owner yet where we could check for compatibility.
>> + * Do an atomic swap to prevent racing with another invocation
>> + * of this branch (via simultaneous map_update syscalls).
>> */
>> - array->aux->type = fp->type;
>> - array->aux->jited = fp->jited;
>> + if (cmpxchg(&array->aux->type, 0, prog_type))
>> + return false;
>
> Other fields might be used in the compatibility check in the future.
> This hack is too fragile.
> Just use a spin_lock.
Well, yeah, we're adding another field for xdp_mb. I was just going to
eat more bits of the 'type' field, but OK, can switch to a spinlock
instead :)
-Toke
prev parent reply other threads:[~2021-10-22 10:54 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-21 18:39 [PATCH bpf] bpf: fix potential race in tail call compatibility check Toke Høiland-Jørgensen
2021-10-22 0:48 ` Alexei Starovoitov
2021-10-22 10:54 ` Toke Høiland-Jørgensen [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=87mtn1cosq.fsf@toke.dk \
--to=toke@redhat.com \
--cc=alexei.starovoitov@gmail.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=lorenzo.bianconi@redhat.com \
--cc=netdev@vger.kernel.org \
/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.