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.c12
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 */
140struct key *request_key_auth_new(struct key *target, const char *callout_info) 140struct 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);