proc.c (cf9ce948f47640797bd19980e1d99c6d17d0bdc3) | proc.c (4bdf0bc300314141e5475e145acb8b5ad846f00d) |
---|---|
1/* procfs files for key database enumeration 2 * 3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved. 4 * 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 --- 168 unchanged lines hidden (view full) --- 177static void proc_keys_stop(struct seq_file *p, void *v) 178 __releases(key_serial_lock) 179{ 180 spin_unlock(&key_serial_lock); 181} 182 183static int proc_keys_show(struct seq_file *m, void *v) 184{ | 1/* procfs files for key database enumeration 2 * 3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved. 4 * 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 --- 168 unchanged lines hidden (view full) --- 177static void proc_keys_stop(struct seq_file *p, void *v) 178 __releases(key_serial_lock) 179{ 180 spin_unlock(&key_serial_lock); 181} 182 183static int proc_keys_show(struct seq_file *m, void *v) 184{ |
185 const struct cred *cred = current_cred(); | |
186 struct rb_node *_p = v; 187 struct key *key = rb_entry(_p, struct key, serial_node); 188 struct timespec now; 189 unsigned long timo; 190 key_ref_t key_ref, skey_ref; 191 char xbuf[12]; 192 int rc; 193 | 185 struct rb_node *_p = v; 186 struct key *key = rb_entry(_p, struct key, serial_node); 187 struct timespec now; 188 unsigned long timo; 189 key_ref_t key_ref, skey_ref; 190 char xbuf[12]; 191 int rc; 192 |
193 struct keyring_search_context ctx = { 194 .index_key.type = key->type, 195 .index_key.description = key->description, 196 .cred = current_cred(), 197 .match = lookup_user_key_possessed, 198 .match_data = key, 199 .flags = (KEYRING_SEARCH_NO_STATE_CHECK | 200 KEYRING_SEARCH_LOOKUP_DIRECT), 201 }; 202 |
|
194 key_ref = make_key_ref(key, 0); 195 196 /* determine if the key is possessed by this process (a test we can 197 * skip if the key does not indicate the possessor can view it 198 */ 199 if (key->perm & KEY_POS_VIEW) { | 203 key_ref = make_key_ref(key, 0); 204 205 /* determine if the key is possessed by this process (a test we can 206 * skip if the key does not indicate the possessor can view it 207 */ 208 if (key->perm & KEY_POS_VIEW) { |
200 skey_ref = search_my_process_keyrings(key->type, key, 201 lookup_user_key_possessed, 202 true, cred); | 209 skey_ref = search_my_process_keyrings(&ctx); |
203 if (!IS_ERR(skey_ref)) { 204 key_ref_put(skey_ref); 205 key_ref = make_key_ref(key, 1); 206 } 207 } 208 209 /* check whether the current task is allowed to view the key (assuming 210 * non-possession) 211 * - the caller holds a spinlock, and thus the RCU read lock, making our 212 * access to __current_cred() safe 213 */ | 210 if (!IS_ERR(skey_ref)) { 211 key_ref_put(skey_ref); 212 key_ref = make_key_ref(key, 1); 213 } 214 } 215 216 /* check whether the current task is allowed to view the key (assuming 217 * non-possession) 218 * - the caller holds a spinlock, and thus the RCU read lock, making our 219 * access to __current_cred() safe 220 */ |
214 rc = key_task_permission(key_ref, cred, KEY_VIEW); | 221 rc = key_task_permission(key_ref, ctx.cred, KEY_VIEW); |
215 if (rc < 0) 216 return 0; 217 218 now = current_kernel_time(); 219 220 rcu_read_lock(); 221 222 /* come up with a suitable timeout value */ --- 131 unchanged lines hidden --- | 222 if (rc < 0) 223 return 0; 224 225 now = current_kernel_time(); 226 227 rcu_read_lock(); 228 229 /* come up with a suitable timeout value */ --- 131 unchanged lines hidden --- |