context, KEY_SEARCH)) 
context, KEY_SEARCH) < 0) 
key_ref_t keyring_search_aux(key_ref_t keyring_ref,			     struct task_struct *context,			     struct key_type *type,			     const void *description,			     key_match_func_t match){	struct {		struct keyring_list *keylist;		int kix;	} stack[KEYRING_SEARCH_MAX_DEPTH];	struct keyring_list *keylist;	struct timespec now;	unsigned long possessed;	struct key *keyring, *key;	key_ref_t key_ref;	long err;	int sp, kix;	keyring = key_ref_to_ptr(keyring_ref);	possessed = is_key_possessed(keyring_ref);	key_check(keyring);	/* top keyring must have search permission to begin the search */	key_ref = ERR_PTR(-EACCES);	if (!key_task_permission(keyring_ref, context, KEY_SEARCH))		goto error;	key_ref = ERR_PTR(-ENOTDIR);	if (keyring->type != &key_type_keyring)		goto error;	rcu_read_lock();	now = current_kernel_time();	err = -EAGAIN;	sp = 0;	/* start processing a new keyring */descend:	if (test_bit(KEY_FLAG_REVOKED, &keyring->flags))		goto not_this_keyring;	keylist = rcu_dereference(keyring->payload.subscriptions);	if (!keylist)		goto not_this_keyring;	/* iterate through the keys in this keyring first */	for (kix = 0; kix < keylist->nkeys; kix++) {		key = keylist->keys[kix];		/* ignore keys not of this type */		if (key->type != type)			continue;		/* skip revoked keys and expired keys */		if (test_bit(KEY_FLAG_REVOKED, &key->flags))			continue;		if (key->expiry && now.tv_sec >= key->expiry)			continue;		/* keys that don't match */		if (!match(key, description))			continue;		/* key must have search permissions */		if (!key_task_permission(make_key_ref(key, possessed),					 context, KEY_SEARCH))			continue;		/* we set a different error code if we find a negative key */		if (test_bit(KEY_FLAG_NEGATIVE, &key->flags)) {			err = -ENOKEY;			continue;		}		goto found;	}	/* search through the keyrings nested in this one */	kix = 0;ascend:	for (; kix < keylist->nkeys; kix++) {		key = keylist->keys[kix];		if (key->type != &key_type_keyring)			continue;		/* recursively search nested keyrings		 * - only search keyrings for which we have search permission		 */		if (sp >= KEYRING_SEARCH_MAX_DEPTH)			continue;		if (!key_task_permission(make_key_ref(key, possessed),					 context, KEY_SEARCH))			continue;		/* stack the current position */		stack[sp].keylist = keylist;		stack[sp].kix = kix;		sp++;		/* begin again with the new keyring */		keyring = key;		goto descend;	}	/* the keyring we're looking at was disqualified or didn't contain a	 * matching key */not_this_keyring:	if (sp > 0) {		/* resume the processing of a keyring higher up in the tree */		sp--;		keylist = stack[sp].keylist;		kix = stack[sp].kix + 1;		goto ascend;	}	key_ref = ERR_PTR(err);	goto error_2;	/* we found a viable match */found:	atomic_inc(&key->usage);	key_check(key);	key_ref = make_key_ref(key, possessed);error_2:	rcu_read_unlock();error:	return key_ref;} /* end keyring_search_aux() */
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/29db9190634067c5a328ee5fcc2890251b836b4b/keyring.c/clean/security/keys/keyring.c