| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* procfs files for key database enumeration |
|---|
| 2 | 3 | * |
|---|
| 3 | 4 | * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved. |
|---|
| 4 | 5 | * 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. |
|---|
| 10 | 6 | */ |
|---|
| 11 | 7 | |
|---|
| 12 | | -#include <linux/module.h> |
|---|
| 13 | 8 | #include <linux/init.h> |
|---|
| 14 | 9 | #include <linux/sched.h> |
|---|
| 15 | 10 | #include <linux/fs.h> |
|---|
| .. | .. |
|---|
| 173 | 168 | .match_data.cmp = lookup_user_key_possessed, |
|---|
| 174 | 169 | .match_data.raw_data = key, |
|---|
| 175 | 170 | .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), |
|---|
| 177 | 173 | }; |
|---|
| 178 | 174 | |
|---|
| 179 | 175 | key_ref = make_key_ref(key, 0); |
|---|
| .. | .. |
|---|
| 182 | 178 | * skip if the key does not indicate the possessor can view it |
|---|
| 183 | 179 | */ |
|---|
| 184 | 180 | 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(); |
|---|
| 186 | 184 | if (!IS_ERR(skey_ref)) { |
|---|
| 187 | 185 | key_ref_put(skey_ref); |
|---|
| 188 | 186 | key_ref = make_key_ref(key, 1); |
|---|