Skip to content

Potential race condition in modern_bpf/auxmap #2719

@darsto2

Description

@darsto2

The auxmap in driver/modern_bpf/helpers/store/auxmap_store_params.h assumes an ebpf program runs exclusively on a CPU without preemption.

But I only see ebpfs run with migrate_disable().
So an ebpf could be preempted after it started writing to the auxmap.
Then another program scheduled on that CPU overwrites the auxmap.
Then the original program is scheduled again and with bpf_ringbuf_output() it copies a malformed event from the auxmap.

Is there some other place where preemption gets disabled? I don't see anything i.e. in sys_exit.

I see also that historically epbf used preempt_disable().
In linux 5.7 it changed to migrate_disable() [1], although at the time migrate_disable() was just an alias for preempt_disable().
In 5.11 migrate_disable() moved away from preempt_disable() [2].

There was an bpf_preempt_disable() added in linux 6.10, quite late.
For 5.1+ there's bpf_spin_lock() that disables preemption.

[1] torvalds/linux@02ad059
[2] torvalds/linux@74d862b

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions