perm = KEY_POS_VIEW | KEY_POS_SEARCH | KEY_POS_LINK; perm |= KEY_USR_VIEW | KEY_USR_SEARCH | KEY_USR_LINK; 
perm = KEY_POS_VIEW | KEY_POS_SEARCH | KEY_POS_LINK | KEY_POS_SETATTR; perm |= KEY_USR_VIEW | KEY_USR_SEARCH | KEY_USR_LINK | KEY_USR_SETATTR; 
key_ref_t key_create_or_update(key_ref_t keyring_ref,			       const char *type,			       const char *description,			       const void *payload,			       size_t plen,			       int not_in_quota){	struct key_type *ktype;	struct key *keyring, *key = NULL;	key_perm_t perm;	key_ref_t key_ref;	int ret;	/* look up the key type to see if it's one of the registered kernel	 * types */	ktype = key_type_lookup(type);	if (IS_ERR(ktype)) {		key_ref = ERR_PTR(-ENODEV);		goto error;	}	key_ref = ERR_PTR(-EINVAL);	if (!ktype->match || !ktype->instantiate)		goto error_2;	keyring = key_ref_to_ptr(keyring_ref);	key_check(keyring);	down_write(&keyring->sem);	/* if we're going to allocate a new key, we're going to have	 * to modify the keyring */	key_ref = ERR_PTR(-EACCES);	if (!key_permission(keyring_ref, KEY_WRITE))		goto error_3;	/* search for an existing key of the same type and description in the	 * destination keyring	 */	key_ref = __keyring_search_one(keyring_ref, ktype, description, 0);	if (!IS_ERR(key_ref))		goto found_matching_key;	/* decide on the permissions we want */	perm = KEY_POS_VIEW | KEY_POS_SEARCH | KEY_POS_LINK;	perm |= KEY_USR_VIEW | KEY_USR_SEARCH | KEY_USR_LINK;	if (ktype->read)		perm |= KEY_POS_READ | KEY_USR_READ;	if (ktype == &key_type_keyring || ktype->update)		perm |= KEY_USR_WRITE;	/* allocate a new key */	key = key_alloc(ktype, description, current->fsuid, current->fsgid,			perm, not_in_quota);	if (IS_ERR(key)) {		key_ref = ERR_PTR(PTR_ERR(key));		goto error_3;	}	/* instantiate it and link it into the target keyring */	ret = __key_instantiate_and_link(key, payload, plen, keyring, NULL);	if (ret < 0) {		key_put(key);		key_ref = ERR_PTR(ret);		goto error_3;	}	key_ref = make_key_ref(key, is_key_possessed(keyring_ref)); error_3:	up_write(&keyring->sem); error_2:	key_type_put(ktype); error:	return key_ref; found_matching_key:	/* we found a matching key, so we're going to try to update it	 * - we can drop the locks first as we have the key pinned	 */	up_write(&keyring->sem);	key_type_put(ktype);	key_ref = __key_update(key_ref, payload, plen);	goto error;} /* end key_create_or_update() */
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/29db9190634067c5a328ee5fcc2890251b836b4b/key.c/clean/security/keys/key.c