bpf, x86: Sign-extend narrow signed kfunc returns - #13416
bpf, x86: Sign-extend narrow signed kfunc returns#13416kernel-patches-daemon-bpf[bot] wants to merge 1 commit into
Conversation
|
Upstream branch: 5e289c5 |
AI reviewed your patch. Please fix the bug or email reply why it's not a bug. In-Reply-To-Subject: |
|
Forwarding comment 5388518471 via email |
71e031f to
909ca3a
Compare
|
Upstream branch: d83fba2 |
2c041c0 to
b695e51
Compare
909ca3a to
b010507
Compare
|
Upstream branch: ce36e38 |
b695e51 to
7349f1f
Compare
b010507 to
975b11a
Compare
|
Upstream branch: 05ea1b6 |
7349f1f to
ef26a75
Compare
975b11a to
f8c8078
Compare
|
Upstream branch: 1555de3 |
bpf_res_spin_lock() returns a 32-bit int. On failure, the verifier models R0 as a signed 64-bit value in [-MAX_ERRNO, -1]. On x86-64, returning -EDEADLK writes 0xffffffdd to EAX and clears the upper half of RAX. Since the JIT leaves the native return value as-is, BPF sees 0x00000000ffffffdd instead of the sign-extended 0xffffffffffffffdd. A 64-bit signed comparison therefore treats the value as positive, while the verifier treats it as -35. As a result, a signed comparison against zero can take one path during verification and another at run time. With rqspinlock aliases, this can lead to unmatched bpf_res_spin_unlock() calls, corrupting the per-CPU rqspinlock state and unbalancing the preemption count. Use the kfunc's BTF model to sign-extend signed 8-, 16-, and 32-bit returns into R0 after the native call. Fixes: 0de2046 ("bpf: Implement verifier support for rqspinlock") Assisted-by: Codex:gpt-5 Signed-off-by: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>
ef26a75 to
a6457f3
Compare
|
At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=1150514 expired. Closing PR. |
Pull request for series with
subject: bpf, x86: Sign-extend narrow signed kfunc returns
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1150514