]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
bpf: Fix key serial argument of bpf_lookup_user_key()
authorJames Bottomley <James.Bottomley@HansenPartnership.com>
Tue, 17 Jun 2025 14:57:36 +0000 (10:57 -0400)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 18 Jun 2025 01:15:27 +0000 (18:15 -0700)
commitbd07bd12f2c17d3e13d58c09f5eac5d021ec14ea
treea9b3c06d1e121a7d3f06e6f20f74726471cb13d7
parentf5527f0171f049e73c0aed21507662abd78821b8
bpf: Fix key serial argument of bpf_lookup_user_key()

The underlying lookup_user_key() function uses a signed 32 bit integer
for key serial numbers because legitimate serial numbers are positive
(and > 3) and keyrings are negative.  Using a u32 for the keyring in
the bpf function doesn't currently cause any conversion problems but
will start to trip the signed to unsigned conversion warnings when the
kernel enables them, so convert the argument to signed (and update the
tests accordingly) before it acquires more users.

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Reviewed-by: Roberto Sassu <roberto.sassu@huawei.com>
Link: https://lore.kernel.org/r/84cdb0775254d297d75e21f577089f64abdfbd28.camel@HansenPartnership.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/trace/bpf_trace.c
tools/testing/selftests/bpf/bpf_kfuncs.h
tools/testing/selftests/bpf/progs/rcu_read_lock.c
tools/testing/selftests/bpf/progs/test_lookup_key.c
tools/testing/selftests/bpf/progs/test_sig_in_xattr.c
tools/testing/selftests/bpf/progs/test_verify_pkcs7_sig.c
tools/testing/selftests/bpf/progs/verifier_ref_tracking.c