// SPDX-License-Identifier: GPL-2.0-or-later /* procfs files for key database enumeration * * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved. * Written by David Howells (dhowells@redhat.com)
*/
p = proc_create_seq("keys", 0, NULL, &proc_keys_ops); if (!p)
panic("Cannot create /proc/keys\n");
p = proc_create_seq("key-users", 0, NULL, &proc_key_users_ops); if (!p)
panic("Cannot create /proc/key-users\n");
return0;
}
__initcall(key_proc_init);
/* * Implement "/proc/keys" to provide a list of the keys on the system that * grant View permission to the caller.
*/ staticstruct rb_node *key_serial_next(struct seq_file *p, struct rb_node *n)
{ struct user_namespace *user_ns = seq_user_ns(p);
n = rb_next(n); while (n) { struct key *key = rb_entry(n, struct key, serial_node); if (kuid_has_mapping(user_ns, key->user->uid)) break;
n = rb_next(n);
} return n;
}
/* determine if the key is possessed by this process (a test we can * skip if the key does not indicate the possessor can view it
*/ if (key->perm & KEY_POS_VIEW) {
rcu_read_lock();
skey_ref = search_cred_keyrings_rcu(&ctx);
rcu_read_unlock(); if (!IS_ERR(skey_ref)) {
key_ref_put(skey_ref);
key_ref = make_key_ref(key, 1);
}
}
/* check whether the current task is allowed to view the key */
rc = key_task_permission(key_ref, ctx.cred, KEY_NEED_VIEW); if (rc < 0) return0;
now = ktime_get_real_seconds();
rcu_read_lock();
/* come up with a suitable timeout value */
expiry = READ_ONCE(key->expiry); if (expiry == TIME64_MAX) {
memcpy(xbuf, "perm", 5);
} elseif (now >= expiry) {
memcpy(xbuf, "expd", 5);
} else {
timo = expiry - now;
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.13Bemerkung:
(vorverarbeitet am 2026-06-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.