aboutsummaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-01-23 11:59:49 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-01-23 11:59:49 -0500
commit7908b3ef6809e49c77d914342dfaa4b946476d7a (patch)
tree44af103c5457b4c2286400158dcfc18846a7c4f0 /security
parentdcd6c92267155e70a94b3927bce681ce74b80d1f (diff)
parentacbbb76a26648dfae6fed0989879e40d75692bfc (diff)
Merge git://git.samba.org/sfrench/cifs-2.6
* git://git.samba.org/sfrench/cifs-2.6: CIFS: Rename *UCS* functions to *UTF16* [CIFS] ACL and FSCACHE support no longer EXPERIMENTAL [CIFS] Fix build break with multiuser patch when LANMAN disabled cifs: warn about impending deprecation of legacy MultiuserMount code cifs: fetch credentials out of keyring for non-krb5 auth multiuser mounts cifs: sanitize username handling keys: add a "logon" key type cifs: lower default wsize when unix extensions are not used cifs: better instrumentation for coalesce_t2 cifs: integer overflow in parse_dacl() cifs: Fix sparse warning when calling cifs_strtoUCS CIFS: Add descriptions to the brlock cache functions
Diffstat (limited to 'security')
-rw-r--r--security/keys/internal.h1
-rw-r--r--security/keys/key.c1
-rw-r--r--security/keys/user_defined.c37
3 files changed, 39 insertions, 0 deletions
diff --git a/security/keys/internal.h b/security/keys/internal.h
index c7a7caec4830..65647f825584 100644
--- a/security/keys/internal.h
+++ b/security/keys/internal.h
@@ -33,6 +33,7 @@
33 33
34extern struct key_type key_type_dead; 34extern struct key_type key_type_dead;
35extern struct key_type key_type_user; 35extern struct key_type key_type_user;
36extern struct key_type key_type_logon;
36 37
37/*****************************************************************************/ 38/*****************************************************************************/
38/* 39/*
diff --git a/security/keys/key.c b/security/keys/key.c
index 4f64c7267afb..7ada8019be1f 100644
--- a/security/keys/key.c
+++ b/security/keys/key.c
@@ -999,6 +999,7 @@ void __init key_init(void)
999 list_add_tail(&key_type_keyring.link, &key_types_list); 999 list_add_tail(&key_type_keyring.link, &key_types_list);
1000 list_add_tail(&key_type_dead.link, &key_types_list); 1000 list_add_tail(&key_type_dead.link, &key_types_list);
1001 list_add_tail(&key_type_user.link, &key_types_list); 1001 list_add_tail(&key_type_user.link, &key_types_list);
1002 list_add_tail(&key_type_logon.link, &key_types_list);
1002 1003
1003 /* record the root user tracking */ 1004 /* record the root user tracking */
1004 rb_link_node(&root_key_user.node, 1005 rb_link_node(&root_key_user.node,
diff --git a/security/keys/user_defined.c b/security/keys/user_defined.c
index 2aee3c5a3b99..c7660a25a3e4 100644
--- a/security/keys/user_defined.c
+++ b/security/keys/user_defined.c
@@ -18,6 +18,8 @@
18#include <asm/uaccess.h> 18#include <asm/uaccess.h>
19#include "internal.h" 19#include "internal.h"
20 20
21static int logon_vet_description(const char *desc);
22
21/* 23/*
22 * user defined keys take an arbitrary string as the description and an 24 * user defined keys take an arbitrary string as the description and an
23 * arbitrary blob of data as the payload 25 * arbitrary blob of data as the payload
@@ -36,6 +38,24 @@ struct key_type key_type_user = {
36EXPORT_SYMBOL_GPL(key_type_user); 38EXPORT_SYMBOL_GPL(key_type_user);
37 39
38/* 40/*
41 * This key type is essentially the same as key_type_user, but it does
42 * not define a .read op. This is suitable for storing username and
43 * password pairs in the keyring that you do not want to be readable
44 * from userspace.
45 */
46struct key_type key_type_logon = {
47 .name = "logon",
48 .instantiate = user_instantiate,
49 .update = user_update,
50 .match = user_match,
51 .revoke = user_revoke,
52 .destroy = user_destroy,
53 .describe = user_describe,
54 .vet_description = logon_vet_description,
55};
56EXPORT_SYMBOL_GPL(key_type_logon);
57
58/*
39 * instantiate a user defined key 59 * instantiate a user defined key
40 */ 60 */
41int user_instantiate(struct key *key, const void *data, size_t datalen) 61int user_instantiate(struct key *key, const void *data, size_t datalen)
@@ -189,3 +209,20 @@ long user_read(const struct key *key, char __user *buffer, size_t buflen)
189} 209}
190 210
191EXPORT_SYMBOL_GPL(user_read); 211EXPORT_SYMBOL_GPL(user_read);
212
213/* Vet the description for a "logon" key */
214static int logon_vet_description(const char *desc)
215{
216 char *p;
217
218 /* require a "qualified" description string */
219 p = strchr(desc, ':');
220 if (!p)
221 return -EINVAL;
222
223 /* also reject description with ':' as first char */
224 if (p == desc)
225 return -EINVAL;
226
227 return 0;
228}