"BPF_STX uses reserved fields" validation error when using __sync_lock_test_and_set
- Dominant language
- C
- Stars
- 2.2k
- Forks
- 308
- PR merge metrics
- No merged PRs in 30d
Description
Hi, in an eBPF program that i'm loading with gobpf I need to perform atomic increments and atomic set. For the first, I use `__sync_fetch_and_add` with no issues, however if I try to use `__sync_lock_test_and_set` for the latter, while compilation passes, I get a runtime error from the validator:
```
BPF_STX uses reserved fields
processed 0 insns (limit 1000000) max_states_per_insn 0 total_states 0 peak_states 0 mark_read 0
```
How do I perform atomic set of a variable so that i don't have to use PER_CPU arrays?
eBPF program compiled with clang 12.0.1, running on 5.8.0-53-generic ( x86_64 )
Contributor guide
Research direction
Start with the eBPF program using __sync_lock_test_and_set and inspect the generated BPF instructions around the failing BPF_STX validation. Compare this with the working __sync_fetch_and_add case on clang 12.0.1 and Linux 5.8. Done means identifying a supported atomic-set approach that validates without using PER_CPU arrays.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, go, linux
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100