Thread (3 messages) flat view 3 messages, 2 authors, 2021-10-22

Re: [PATCH bpf] bpf: fix potential race in tail call compatibility check

From: Alexei Starovoitov <hidden>
Date: 2021-10-22 00:48:32
Also in: bpf

On Thu, Oct 21, 2021 at 11:40 AM Toke Høiland-Jørgensen [off-list ref] 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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help