Skip to content

Commit 607259e

Browse files
James MorrisJames Morris
authored andcommitted
Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity into ra-next
2 parents aa98b94 + 1d6d167 commit 607259e

File tree

3 files changed

+17
-21
lines changed

3 files changed

+17
-21
lines changed

security/integrity/ima/ima_fs.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -261,13 +261,8 @@ static const struct file_operations ima_ascii_measurements_ops = {
261261
static ssize_t ima_write_policy(struct file *file, const char __user *buf,
262262
size_t datalen, loff_t *ppos)
263263
{
264-
char *data = NULL;
264+
char *data;
265265
ssize_t result;
266-
int res;
267-
268-
res = mutex_lock_interruptible(&ima_write_mutex);
269-
if (res)
270-
return res;
271266

272267
if (datalen >= PAGE_SIZE)
273268
datalen = PAGE_SIZE - 1;
@@ -286,14 +281,19 @@ static ssize_t ima_write_policy(struct file *file, const char __user *buf,
286281

287282
result = -EFAULT;
288283
if (copy_from_user(data, buf, datalen))
289-
goto out;
284+
goto out_free;
290285

286+
result = mutex_lock_interruptible(&ima_write_mutex);
287+
if (result < 0)
288+
goto out_free;
291289
result = ima_parse_add_rule(data);
290+
mutex_unlock(&ima_write_mutex);
291+
292+
out_free:
293+
kfree(data);
292294
out:
293295
if (result < 0)
294296
valid_policy = 0;
295-
kfree(data);
296-
mutex_unlock(&ima_write_mutex);
297297

298298
return result;
299299
}

security/keys/key.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,7 @@ static int __key_instantiate_and_link(struct key *key,
430430

431431
/* and link it into the destination keyring */
432432
if (keyring) {
433-
if (test_bit(KEY_FLAG_KEEP, &keyring->flags))
434-
set_bit(KEY_FLAG_KEEP, &key->flags);
433+
set_bit(KEY_FLAG_KEEP, &key->flags);
435434

436435
__key_link(key, _edit);
437436
}

security/keys/keyctl.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -381,12 +381,11 @@ long keyctl_revoke_key(key_serial_t id)
381381
}
382382

383383
key = key_ref_to_ptr(key_ref);
384+
ret = 0;
384385
if (test_bit(KEY_FLAG_KEEP, &key->flags))
385-
return -EPERM;
386-
else {
386+
ret = -EPERM;
387+
else
387388
key_revoke(key);
388-
ret = 0;
389-
}
390389

391390
key_ref_put(key_ref);
392391
error:
@@ -432,12 +431,11 @@ long keyctl_invalidate_key(key_serial_t id)
432431

433432
invalidate:
434433
key = key_ref_to_ptr(key_ref);
434+
ret = 0;
435435
if (test_bit(KEY_FLAG_KEEP, &key->flags))
436436
ret = -EPERM;
437-
else {
437+
else
438438
key_invalidate(key);
439-
ret = 0;
440-
}
441439
error_put:
442440
key_ref_put(key_ref);
443441
error:
@@ -1352,12 +1350,11 @@ long keyctl_set_timeout(key_serial_t id, unsigned timeout)
13521350

13531351
okay:
13541352
key = key_ref_to_ptr(key_ref);
1353+
ret = 0;
13551354
if (test_bit(KEY_FLAG_KEEP, &key->flags))
13561355
ret = -EPERM;
1357-
else {
1356+
else
13581357
key_set_timeout(key, timeout);
1359-
ret = 0;
1360-
}
13611358
key_put(key);
13621359

13631360
error:

0 commit comments

Comments
 (0)