Skip to contentSkip to conversation

KEYS: Propagate error code instead of returning -EINVAL

PATCH In review Dan Carpenter 3 participants 3 messages Jun 3, 2010 – Jun 6, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KEYS: Propagate error code instead of returning -EINVAL

This is from a Smatch check I'm writing.

strncpy_from_user() returns -EFAULT on error so the first change just silences a warning but doesn't change how the code works.

The other change is a bug fix because install_thread_keyring_to_cred() can return a variety of errors such as -EINVAL, -EEXIST, -ENOMEM or -EKEYREVOKED.

security/keys/keyctl.c +2 -2
index 13074b4..6261745 100644
@@ -33,7 +33,7 @@ static int key_get_type_from_user(char *type,
 	ret = strncpy_from_user(type, _type, len);
 
 	if (ret < 0)
-		return -EFAULT;
+		return ret;
 
 	if (ret = 0 || ret >= len)
 		return -EINVAL;
@@ -1080,7 +1080,7 @@ set:
 	return old_setting;
 error:
 	abort_creds(new);
-	return -EINVAL;
+	return ret;
 
 } /* end keyctl_set_reqkey_keyring() */
 
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Dan Carpenter

This is from a Smatch check I'm writing.

strncpy_from_user() returns -EFAULT on error so the first change just silences a warning but doesn't change how the code works.

The other change is a bug fix because install_thread_keyring_to_cred() can return a variety of errors such as -EINVAL, -EEXIST, -ENOMEM or -EKEYREVOKED.

maintainer
#2 lore raw

Re: [patch] KEYS: Propagate error code instead of returning

In reply to Dan Carpenter
Quoted 10 lines · Dan Carpenter

This is from a Smatch check I'm writing.

strncpy_from_user() returns -EFAULT on error so the first change just silences a warning but doesn't change how the code works.

The other change is a bug fix because install_thread_keyring_to_cred() can return a variety of errors such as -EINVAL, -EEXIST, -ENOMEM or -EKEYREVOKED.

Applied to
git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6#next

Signature · 2 lines
James Morris
<[email protected]>