linux/include/keys
Maoyi Xie 0d6a4268b0 keys: translate request_key_auth pid for the reading procfs instance
request_key_auth_describe() prints rka->pid into /proc/keys as a raw
pid_t in the initial pid namespace. A reader can open /proc/keys through
a mount in another pid namespace. That reader sees a number with no
meaning there. The number can even name an unrelated task. The line
needs VIEW on the key. So the reader either shares the key owner's uid
or possesses the key.

The fix keeps a struct pid. Commit 4f82f45730 ("net ip6 flowlabel:
Make owner a union of struct pid * and kuid_t") gave
/proc/net/ip6_flowlabel the same storage. The print goes through
pid_nr_ns(). It renders against the pid namespace of the procfs instance
the line is read through. Commit ad08978ab4 ("ipv6/flowlabel: simplify
pid namespace lookup") moved that print to the same anchor. Output
through an initial namespace /proc does not change. The line shows 0 for
a requestor with no number in that namespace.

Translating at read time was the alternative. find_pid_ns() can resolve
a recycled number. The line would then name a live task with no
connection to the key. A stored struct pid gives 0 instead when the
requestor has no number there.

Link: https://lore.kernel.org/keyrings/20260809110202.2180410-1-maoyixie.tju@gmail.com/
Fixes: 78b7280cce ("KEYS: Improve /proc/keys")
Cc: stable@vger.kernel.org # v5.10+
Assisted-by: Claude:claude-opus-5 codeql
Signed-off-by: Maoyi Xie <maoyixie.tju@gmail.com>
Link: https://lore.kernel.org/r/20260821095935.1864998-1-maoyixie.tju@gmail.com
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
2026-09-12 00:43:45 +03:00
..
asymmetric-parser.h
asymmetric-subtype.h
asymmetric-type.h keys: Annotate struct asymmetric_key_id with __counted_by 2025-10-31 17:43:56 +08:00
big_key-type.h
ceph-type.h
dns_resolver-type.h KEYS: Remove unused declarations 2024-09-20 18:28:26 +03:00
encrypted-type.h
keyring-type.h
request_key_auth-type.h keys: translate request_key_auth pid for the reading procfs instance 2026-09-12 00:43:45 +03:00
rxrpc-type.h rxrpc: Add YFS RxGK (GSSAPI) security class 2025-04-14 17:36:41 -07:00
system_keyring.h keys: drop shadowing dead prototype 2025-01-21 11:25:23 +02:00
trusted_caam.h
trusted_dcp.h KEYS: trusted: Introduce NXP DCP-backed trusted keys 2024-05-09 18:29:03 +03:00
trusted_pkwm.h keys/trusted_keys: establish PKWM as a trusted source 2026-01-30 09:27:26 +05:30
trusted_tee.h
trusted_tpm.h tpm: Initial step to reorganize TPM public headers 2026-08-25 18:13:35 +03:00
trusted-type.h KEYS: trusted: Debugging as a feature 2026-06-15 15:19:12 +03:00
user-type.h