aboutsummaryrefslogtreecommitdiffstats
path: root/security/keys/request_key_auth.c
diff options
context:
space:
mode:
Diffstat (limited to 'security/keys/request_key_auth.c')
-rw-r--r--security/keys/request_key_auth.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/security/keys/request_key_auth.c b/security/keys/request_key_auth.c
index e42b5252486f..bd237b0a6331 100644
--- a/security/keys/request_key_auth.c
+++ b/security/keys/request_key_auth.c
@@ -15,6 +15,7 @@
15#include <linux/sched.h> 15#include <linux/sched.h>
16#include <linux/err.h> 16#include <linux/err.h>
17#include <linux/seq_file.h> 17#include <linux/seq_file.h>
18#include <linux/slab.h>
18#include <asm/uaccess.h> 19#include <asm/uaccess.h>
19#include "internal.h" 20#include "internal.h"
20 21
@@ -61,7 +62,7 @@ static void request_key_auth_describe(const struct key *key,
61 62
62 seq_puts(m, "key:"); 63 seq_puts(m, "key:");
63 seq_puts(m, key->description); 64 seq_puts(m, key->description);
64 seq_printf(m, " pid:%d ci:%zu", rka->pid, strlen(rka->callout_info)); 65 seq_printf(m, " pid:%d ci:%zu", rka->pid, rka->callout_len);
65 66
66} /* end request_key_auth_describe() */ 67} /* end request_key_auth_describe() */
67 68
@@ -77,7 +78,7 @@ static long request_key_auth_read(const struct key *key,
77 size_t datalen; 78 size_t datalen;
78 long ret; 79 long ret;
79 80
80 datalen = strlen(rka->callout_info); 81 datalen = rka->callout_len;
81 ret = datalen; 82 ret = datalen;
82 83
83 /* we can return the data as is */ 84 /* we can return the data as is */
@@ -137,7 +138,8 @@ static void request_key_auth_destroy(struct key *key)
137 * create an authorisation token for /sbin/request-key or whoever to gain 138 * create an authorisation token for /sbin/request-key or whoever to gain
138 * access to the caller's security data 139 * access to the caller's security data
139 */ 140 */
140struct key *request_key_auth_new(struct key *target, const char *callout_info) 141struct key *request_key_auth_new(struct key *target, const void *callout_info,
142 size_t callout_len)
141{ 143{
142 struct request_key_auth *rka, *irka; 144 struct request_key_auth *rka, *irka;
143 struct key *authkey = NULL; 145 struct key *authkey = NULL;
@@ -152,7 +154,7 @@ struct key *request_key_auth_new(struct key *target, const char *callout_info)
152 kleave(" = -ENOMEM"); 154 kleave(" = -ENOMEM");
153 return ERR_PTR(-ENOMEM); 155 return ERR_PTR(-ENOMEM);
154 } 156 }
155 rka->callout_info = kmalloc(strlen(callout_info) + 1, GFP_KERNEL); 157 rka->callout_info = kmalloc(callout_len, GFP_KERNEL);
156 if (!rka->callout_info) { 158 if (!rka->callout_info) {
157 kleave(" = -ENOMEM"); 159 kleave(" = -ENOMEM");
158 kfree(rka); 160 kfree(rka);
@@ -186,7 +188,8 @@ struct key *request_key_auth_new(struct key *target, const char *callout_info)
186 } 188 }
187 189
188 rka->target_key = key_get(target); 190 rka->target_key = key_get(target);
189 strcpy(rka->callout_info, callout_info); 191 memcpy(rka->callout_info, callout_info, callout_len);
192 rka->callout_len = callout_len;
190 193
191 /* allocate the auth key */ 194 /* allocate the auth key */
192 sprintf(desc, "%x", target->serial); 195 sprintf(desc, "%x", target->serial);