hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/security/keys/proc.c
....@@ -1,15 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /* procfs files for key database enumeration
23 *
34 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
45 * Written by David Howells (dhowells@redhat.com)
5
- *
6
- * This program is free software; you can redistribute it and/or
7
- * modify it under the terms of the GNU General Public License
8
- * as published by the Free Software Foundation; either version
9
- * 2 of the License, or (at your option) any later version.
106 */
117
12
-#include <linux/module.h>
138 #include <linux/init.h>
149 #include <linux/sched.h>
1510 #include <linux/fs.h>
....@@ -173,7 +168,8 @@
173168 .match_data.cmp = lookup_user_key_possessed,
174169 .match_data.raw_data = key,
175170 .match_data.lookup_type = KEYRING_SEARCH_LOOKUP_DIRECT,
176
- .flags = KEYRING_SEARCH_NO_STATE_CHECK,
171
+ .flags = (KEYRING_SEARCH_NO_STATE_CHECK |
172
+ KEYRING_SEARCH_RECURSE),
177173 };
178174
179175 key_ref = make_key_ref(key, 0);
....@@ -182,7 +178,9 @@
182178 * skip if the key does not indicate the possessor can view it
183179 */
184180 if (key->perm & KEY_POS_VIEW) {
185
- skey_ref = search_my_process_keyrings(&ctx);
181
+ rcu_read_lock();
182
+ skey_ref = search_cred_keyrings_rcu(&ctx);
183
+ rcu_read_unlock();
186184 if (!IS_ERR(skey_ref)) {
187185 key_ref_put(skey_ref);
188186 key_ref = make_key_ref(key, 1);