dbc4a9b
From: David Howells <dhowells@redhat.com>
dbc4a9b
Date: Tue, 16 Sep 2014 17:29:03 +0100
dbc4a9b
Subject: [PATCH] KEYS: Reinstate EPERM for a key type name beginning with a
dbc4a9b
 '.'
dbc4a9b
dbc4a9b
Reinstate the generation of EPERM for a key type name beginning with a '.' in
dbc4a9b
a userspace call.  Types whose name begins with a '.' are internal only.
dbc4a9b
dbc4a9b
The test was removed by:
dbc4a9b
dbc4a9b
	commit a4e3b8d79a5c6d40f4a9703abf7fe3abcc6c3b8d
dbc4a9b
	Author: Mimi Zohar <zohar@linux.vnet.ibm.com>
dbc4a9b
	Date:   Thu May 22 14:02:23 2014 -0400
dbc4a9b
	Subject: KEYS: special dot prefixed keyring name bug fix
dbc4a9b
dbc4a9b
I think we want to keep the restriction on type name so that userspace can't
dbc4a9b
add keys of a special internal type.
dbc4a9b
dbc4a9b
Note that removal of the test causes several of the tests in the keyutils
dbc4a9b
testsuite to fail.
dbc4a9b
dbc4a9b
Signed-off-by: David Howells <dhowells@redhat.com>
dbc4a9b
Acked-by: Vivek Goyal <vgoyal@redhat.com>
dbc4a9b
cc: Mimi Zohar <zohar@linux.vnet.ibm.com>
dbc4a9b
---
dbc4a9b
 security/keys/keyctl.c | 2 ++
dbc4a9b
 1 file changed, 2 insertions(+)
dbc4a9b
dbc4a9b
diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
dbc4a9b
index e26f860e5f2e..eff88a5f5d40 100644
dbc4a9b
--- a/security/keys/keyctl.c
dbc4a9b
+++ b/security/keys/keyctl.c
dbc4a9b
@@ -37,6 +37,8 @@ static int key_get_type_from_user(char *type,
dbc4a9b
 		return ret;
dbc4a9b
 	if (ret == 0 || ret >= len)
dbc4a9b
 		return -EINVAL;
dbc4a9b
+	if (type[0] == '.')
dbc4a9b
+		return -EPERM;
dbc4a9b
 	type[len - 1] = '\0';
dbc4a9b
 	return 0;
dbc4a9b
 }
dbc4a9b
-- 
dbc4a9b
1.9.3
dbc4a9b