ret = -EACCES;  if (!key_task_permission(key_ref, context, perm)) 
ret = key_task_permission(key_ref, context, perm); if (ret < 0) 
key_ref_t lookup_user_key(struct task_struct *context, key_serial_t id,			  int create, int partial, key_perm_t perm){	key_ref_t key_ref, skey_ref;	struct key *key;	int ret;	if (!context)		context = current;	key_ref = ERR_PTR(-ENOKEY);	switch (id) {	case KEY_SPEC_THREAD_KEYRING:		if (!context->thread_keyring) {			if (!create)				goto error;			ret = install_thread_keyring(context);			if (ret < 0) {				key = ERR_PTR(ret);				goto error;			}		}		key = context->thread_keyring;		atomic_inc(&key->usage);		key_ref = make_key_ref(key, 1);		break;	case KEY_SPEC_PROCESS_KEYRING:		if (!context->signal->process_keyring) {			if (!create)				goto error;			ret = install_process_keyring(context);			if (ret < 0) {				key = ERR_PTR(ret);				goto error;			}		}		key = context->signal->process_keyring;		atomic_inc(&key->usage);		key_ref = make_key_ref(key, 1);		break;	case KEY_SPEC_SESSION_KEYRING:		if (!context->signal->session_keyring) {			/* always install a session keyring upon access if one			 * doesn't exist yet */			ret = install_session_keyring(				context, context->user->session_keyring);			if (ret < 0)				goto error;		}		rcu_read_lock();		key = rcu_dereference(context->signal->session_keyring);		atomic_inc(&key->usage);		rcu_read_unlock();		key_ref = make_key_ref(key, 1);		break;	case KEY_SPEC_USER_KEYRING:		key = context->user->uid_keyring;		atomic_inc(&key->usage);		key_ref = make_key_ref(key, 1);		break;	case KEY_SPEC_USER_SESSION_KEYRING:		key = context->user->session_keyring;		atomic_inc(&key->usage);		key_ref = make_key_ref(key, 1);		break;	case KEY_SPEC_GROUP_KEYRING:		/* group keyrings are not yet supported */		key = ERR_PTR(-EINVAL);		goto error;	default:		key_ref = ERR_PTR(-EINVAL);		if (id < 1)			goto error;		key = key_lookup(id);		if (IS_ERR(key)) {			key_ref = ERR_PTR(PTR_ERR(key));			goto error;		}		key_ref = make_key_ref(key, 0);		/* check to see if we possess the key */		skey_ref = search_process_keyrings(key->type, key,						   lookup_user_key_possessed,						   current);		if (!IS_ERR(skey_ref)) {			key_put(key);			key_ref = skey_ref;		}		break;	}	/* check the status */	if (perm) {		ret = key_validate(key);		if (ret < 0)			goto invalid_key;	}	ret = -EIO;	if (!partial && !test_bit(KEY_FLAG_INSTANTIATED, &key->flags))		goto invalid_key;	/* check the permissions */	ret = -EACCES;	if (!key_task_permission(key_ref, context, perm))		goto invalid_key;error:	return key_ref;invalid_key:	key_ref_put(key_ref);	key_ref = ERR_PTR(ret);	goto error;} /* end lookup_user_key() */
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/29db9190634067c5a328ee5fcc2890251b836b4b/process_keys.c/buggy/security/keys/process_keys.c