diff options
author | James Morris <jmorris@namei.org> | 2016-01-10 05:52:17 -0500 |
---|---|---|
committer | James Morris <james.l.morris@oracle.com> | 2016-01-10 05:52:17 -0500 |
commit | 607259e17b37017e9ec0249a8b0a7d8b76b572aa (patch) | |
tree | a8772ad30dd74afef995e558e723176e54369608 | |
parent | aa98b942cbf305cf2abe5dc3aff11f579c7d7fdc (diff) | |
parent | 1d6d167c2efcfe9539d9cffb1a1be9c92e39c2c0 (diff) |
Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity into ra-next
-rw-r--r-- | security/integrity/ima/ima_fs.c | 18 | ||||
-rw-r--r-- | security/keys/key.c | 3 | ||||
-rw-r--r-- | security/keys/keyctl.c | 17 |
3 files changed, 17 insertions, 21 deletions
diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c index 3caed6de610c..f355231997b4 100644 --- a/security/integrity/ima/ima_fs.c +++ b/security/integrity/ima/ima_fs.c | |||
@@ -261,13 +261,8 @@ static const struct file_operations ima_ascii_measurements_ops = { | |||
261 | static ssize_t ima_write_policy(struct file *file, const char __user *buf, | 261 | static ssize_t ima_write_policy(struct file *file, const char __user *buf, |
262 | size_t datalen, loff_t *ppos) | 262 | size_t datalen, loff_t *ppos) |
263 | { | 263 | { |
264 | char *data = NULL; | 264 | char *data; |
265 | ssize_t result; | 265 | ssize_t result; |
266 | int res; | ||
267 | |||
268 | res = mutex_lock_interruptible(&ima_write_mutex); | ||
269 | if (res) | ||
270 | return res; | ||
271 | 266 | ||
272 | if (datalen >= PAGE_SIZE) | 267 | if (datalen >= PAGE_SIZE) |
273 | datalen = PAGE_SIZE - 1; | 268 | datalen = PAGE_SIZE - 1; |
@@ -286,14 +281,19 @@ static ssize_t ima_write_policy(struct file *file, const char __user *buf, | |||
286 | 281 | ||
287 | result = -EFAULT; | 282 | result = -EFAULT; |
288 | if (copy_from_user(data, buf, datalen)) | 283 | if (copy_from_user(data, buf, datalen)) |
289 | goto out; | 284 | goto out_free; |
290 | 285 | ||
286 | result = mutex_lock_interruptible(&ima_write_mutex); | ||
287 | if (result < 0) | ||
288 | goto out_free; | ||
291 | result = ima_parse_add_rule(data); | 289 | result = ima_parse_add_rule(data); |
290 | mutex_unlock(&ima_write_mutex); | ||
291 | |||
292 | out_free: | ||
293 | kfree(data); | ||
292 | out: | 294 | out: |
293 | if (result < 0) | 295 | if (result < 0) |
294 | valid_policy = 0; | 296 | valid_policy = 0; |
295 | kfree(data); | ||
296 | mutex_unlock(&ima_write_mutex); | ||
297 | 297 | ||
298 | return result; | 298 | return result; |
299 | } | 299 | } |
diff --git a/security/keys/key.c b/security/keys/key.c index 09ef276c4bdc..07a87311055c 100644 --- a/security/keys/key.c +++ b/security/keys/key.c | |||
@@ -430,8 +430,7 @@ static int __key_instantiate_and_link(struct key *key, | |||
430 | 430 | ||
431 | /* and link it into the destination keyring */ | 431 | /* and link it into the destination keyring */ |
432 | if (keyring) { | 432 | if (keyring) { |
433 | if (test_bit(KEY_FLAG_KEEP, &keyring->flags)) | 433 | set_bit(KEY_FLAG_KEEP, &key->flags); |
434 | set_bit(KEY_FLAG_KEEP, &key->flags); | ||
435 | 434 | ||
436 | __key_link(key, _edit); | 435 | __key_link(key, _edit); |
437 | } | 436 | } |
diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c index e83ec6b9eb9d..8f9f323f372b 100644 --- a/security/keys/keyctl.c +++ b/security/keys/keyctl.c | |||
@@ -381,12 +381,11 @@ long keyctl_revoke_key(key_serial_t id) | |||
381 | } | 381 | } |
382 | 382 | ||
383 | key = key_ref_to_ptr(key_ref); | 383 | key = key_ref_to_ptr(key_ref); |
384 | ret = 0; | ||
384 | if (test_bit(KEY_FLAG_KEEP, &key->flags)) | 385 | if (test_bit(KEY_FLAG_KEEP, &key->flags)) |
385 | return -EPERM; | 386 | ret = -EPERM; |
386 | else { | 387 | else |
387 | key_revoke(key); | 388 | key_revoke(key); |
388 | ret = 0; | ||
389 | } | ||
390 | 389 | ||
391 | key_ref_put(key_ref); | 390 | key_ref_put(key_ref); |
392 | error: | 391 | error: |
@@ -432,12 +431,11 @@ long keyctl_invalidate_key(key_serial_t id) | |||
432 | 431 | ||
433 | invalidate: | 432 | invalidate: |
434 | key = key_ref_to_ptr(key_ref); | 433 | key = key_ref_to_ptr(key_ref); |
434 | ret = 0; | ||
435 | if (test_bit(KEY_FLAG_KEEP, &key->flags)) | 435 | if (test_bit(KEY_FLAG_KEEP, &key->flags)) |
436 | ret = -EPERM; | 436 | ret = -EPERM; |
437 | else { | 437 | else |
438 | key_invalidate(key); | 438 | key_invalidate(key); |
439 | ret = 0; | ||
440 | } | ||
441 | error_put: | 439 | error_put: |
442 | key_ref_put(key_ref); | 440 | key_ref_put(key_ref); |
443 | error: | 441 | error: |
@@ -1352,12 +1350,11 @@ long keyctl_set_timeout(key_serial_t id, unsigned timeout) | |||
1352 | 1350 | ||
1353 | okay: | 1351 | okay: |
1354 | key = key_ref_to_ptr(key_ref); | 1352 | key = key_ref_to_ptr(key_ref); |
1353 | ret = 0; | ||
1355 | if (test_bit(KEY_FLAG_KEEP, &key->flags)) | 1354 | if (test_bit(KEY_FLAG_KEEP, &key->flags)) |
1356 | ret = -EPERM; | 1355 | ret = -EPERM; |
1357 | else { | 1356 | else |
1358 | key_set_timeout(key, timeout); | 1357 | key_set_timeout(key, timeout); |
1359 | ret = 0; | ||
1360 | } | ||
1361 | key_put(key); | 1358 | key_put(key); |
1362 | 1359 | ||
1363 | error: | 1360 | error: |