diff options
author | David Howells <dhowells@redhat.com> | 2008-04-29 04:01:24 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-29 11:06:16 -0400 |
commit | 4a38e122e2cc6294779021ff4ccc784a3997059e (patch) | |
tree | 84b401b44e0550b04f831d98a91eacfd7cffb51d /security/keys/request_key_auth.c | |
parent | dceba9944181b1fd5993417b5c8fa0e3dda38f8d (diff) |
keys: allow the callout data to be passed as a blob rather than a string
Allow the callout data to be passed as a blob rather than a string for
internal kernel services that call any request_key_*() interface other than
request_key(). request_key() itself still takes a NUL-terminated string.
The functions that change are:
request_key_with_auxdata()
request_key_async()
request_key_async_with_auxdata()
Signed-off-by: David Howells <dhowells@redhat.com>
Cc: Paul Moore <paul.moore@hp.com>
Cc: Chris Wright <chrisw@sous-sol.org>
Cc: Stephen Smalley <sds@tycho.nsa.gov>
Cc: James Morris <jmorris@namei.org>
Cc: Kevin Coffman <kwc@citi.umich.edu>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'security/keys/request_key_auth.c')
-rw-r--r-- | security/keys/request_key_auth.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/security/keys/request_key_auth.c b/security/keys/request_key_auth.c index e42b5252486f..c615d473ce7c 100644 --- a/security/keys/request_key_auth.c +++ b/security/keys/request_key_auth.c | |||
@@ -61,7 +61,7 @@ static void request_key_auth_describe(const struct key *key, | |||
61 | 61 | ||
62 | seq_puts(m, "key:"); | 62 | seq_puts(m, "key:"); |
63 | seq_puts(m, key->description); | 63 | seq_puts(m, key->description); |
64 | seq_printf(m, " pid:%d ci:%zu", rka->pid, strlen(rka->callout_info)); | 64 | seq_printf(m, " pid:%d ci:%zu", rka->pid, rka->callout_len); |
65 | 65 | ||
66 | } /* end request_key_auth_describe() */ | 66 | } /* end request_key_auth_describe() */ |
67 | 67 | ||
@@ -77,7 +77,7 @@ static long request_key_auth_read(const struct key *key, | |||
77 | size_t datalen; | 77 | size_t datalen; |
78 | long ret; | 78 | long ret; |
79 | 79 | ||
80 | datalen = strlen(rka->callout_info); | 80 | datalen = rka->callout_len; |
81 | ret = datalen; | 81 | ret = datalen; |
82 | 82 | ||
83 | /* we can return the data as is */ | 83 | /* we can return the data as is */ |
@@ -137,7 +137,8 @@ static void request_key_auth_destroy(struct key *key) | |||
137 | * create an authorisation token for /sbin/request-key or whoever to gain | 137 | * create an authorisation token for /sbin/request-key or whoever to gain |
138 | * access to the caller's security data | 138 | * access to the caller's security data |
139 | */ | 139 | */ |
140 | struct key *request_key_auth_new(struct key *target, const char *callout_info) | 140 | struct key *request_key_auth_new(struct key *target, const void *callout_info, |
141 | size_t callout_len) | ||
141 | { | 142 | { |
142 | struct request_key_auth *rka, *irka; | 143 | struct request_key_auth *rka, *irka; |
143 | struct key *authkey = NULL; | 144 | struct key *authkey = NULL; |
@@ -152,7 +153,7 @@ struct key *request_key_auth_new(struct key *target, const char *callout_info) | |||
152 | kleave(" = -ENOMEM"); | 153 | kleave(" = -ENOMEM"); |
153 | return ERR_PTR(-ENOMEM); | 154 | return ERR_PTR(-ENOMEM); |
154 | } | 155 | } |
155 | rka->callout_info = kmalloc(strlen(callout_info) + 1, GFP_KERNEL); | 156 | rka->callout_info = kmalloc(callout_len, GFP_KERNEL); |
156 | if (!rka->callout_info) { | 157 | if (!rka->callout_info) { |
157 | kleave(" = -ENOMEM"); | 158 | kleave(" = -ENOMEM"); |
158 | kfree(rka); | 159 | kfree(rka); |
@@ -186,7 +187,8 @@ struct key *request_key_auth_new(struct key *target, const char *callout_info) | |||
186 | } | 187 | } |
187 | 188 | ||
188 | rka->target_key = key_get(target); | 189 | rka->target_key = key_get(target); |
189 | strcpy(rka->callout_info, callout_info); | 190 | memcpy(rka->callout_info, callout_info, callout_len); |
191 | rka->callout_len = callout_len; | ||
190 | 192 | ||
191 | /* allocate the auth key */ | 193 | /* allocate the auth key */ |
192 | sprintf(desc, "%x", target->serial); | 194 | sprintf(desc, "%x", target->serial); |