keyring.c (ccc3e6d9c9aea07a0b60b2b0bfc5b05a704b66d5) keyring.c (e57e8669f2ab8350d30f771dd2fdd5377f183db2)
1/* Keyring handling
2 *
3 * Copyright (C) 2004-2005, 2008 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

--- 517 unchanged lines hidden (view full) ---

526 * Search the given keyring only (no recursion).
527 *
528 * The caller must guarantee that the keyring is a keyring and that the
529 * permission is granted to search the keyring as no check is made here.
530 *
531 * RCU is used to make it unnecessary to lock the keyring key list here.
532 *
533 * Returns a pointer to the found key with usage count incremented if
1/* Keyring handling
2 *
3 * Copyright (C) 2004-2005, 2008 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

--- 517 unchanged lines hidden (view full) ---

526 * Search the given keyring only (no recursion).
527 *
528 * The caller must guarantee that the keyring is a keyring and that the
529 * permission is granted to search the keyring as no check is made here.
530 *
531 * RCU is used to make it unnecessary to lock the keyring key list here.
532 *
533 * Returns a pointer to the found key with usage count incremented if
534 * successful and returns -ENOKEY if not found. Revoked keys and keys not
535 * providing the requested permission are skipped over.
534 * successful and returns -ENOKEY if not found. Revoked and invalidated keys
535 * are skipped over.
536 *
537 * If successful, the possession indicator is propagated from the keyring ref
538 * to the returned key reference.
539 */
540key_ref_t __keyring_search_one(key_ref_t keyring_ref,
536 *
537 * If successful, the possession indicator is propagated from the keyring ref
538 * to the returned key reference.
539 */
540key_ref_t __keyring_search_one(key_ref_t keyring_ref,
541 const struct keyring_index_key *index_key,
542 key_perm_t perm)
541 const struct keyring_index_key *index_key)
543{
544 struct keyring_list *klist;
545 struct key *keyring, *key;
546 bool possessed;
547 int nkeys, loop;
548
549 keyring = key_ref_to_ptr(keyring_ref);
550 possessed = is_key_possessed(keyring_ref);

--- 4 unchanged lines hidden (view full) ---

555 if (klist) {
556 nkeys = klist->nkeys;
557 smp_rmb();
558 for (loop = 0; loop < nkeys ; loop++) {
559 key = rcu_dereference(klist->keys[loop]);
560 if (key->type == index_key->type &&
561 (!key->type->match ||
562 key->type->match(key, index_key->description)) &&
542{
543 struct keyring_list *klist;
544 struct key *keyring, *key;
545 bool possessed;
546 int nkeys, loop;
547
548 keyring = key_ref_to_ptr(keyring_ref);
549 possessed = is_key_possessed(keyring_ref);

--- 4 unchanged lines hidden (view full) ---

554 if (klist) {
555 nkeys = klist->nkeys;
556 smp_rmb();
557 for (loop = 0; loop < nkeys ; loop++) {
558 key = rcu_dereference(klist->keys[loop]);
559 if (key->type == index_key->type &&
560 (!key->type->match ||
561 key->type->match(key, index_key->description)) &&
563 key_permission(make_key_ref(key, possessed),
564 perm) == 0 &&
565 !(key->flags & ((1 << KEY_FLAG_INVALIDATED) |
566 (1 << KEY_FLAG_REVOKED)))
567 )
568 goto found;
569 }
570 }
571
572 rcu_read_unlock();

--- 709 unchanged lines hidden ---
562 !(key->flags & ((1 << KEY_FLAG_INVALIDATED) |
563 (1 << KEY_FLAG_REVOKED)))
564 )
565 goto found;
566 }
567 }
568
569 rcu_read_unlock();

--- 709 unchanged lines hidden ---