Skip to content

Commit 1a35914

Browse files
committed
Merge tag 'integrity-v6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity
Pull integrity subsystem updates from Mimi Zohar: - With commit 099f26f ("integrity: machine keyring CA configuration") certificates may be loaded onto the IMA keyring, directly or indirectly signed by keys on either the "builtin" or the "machine" keyrings. With the ability for the system/machine owner to sign the IMA policy itself without needing to recompile the kernel, update the IMA architecture specific policy rules to require the IMA policy itself be signed. [ As commit 099f26f was upstreamed in linux-6.4, updating the IMA architecture specific policy now to require signed IMA policies may break userspace expectations. ] - IMA only checked the file data hash was not on the system blacklist keyring for files with an appended signature (e.g. kernel modules, Power kernel image). Check all file data hashes regardless of how it was signed - Code cleanup, and a kernel-doc update * tag 'integrity-v6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity: kexec_lock: Replace kexec_mutex() by kexec_lock() in two comments ima: require signed IMA policy when UEFI secure boot is enabled integrity: Always reference the blacklist keyring with appraisal ima: Remove deprecated IMA_TRUSTED_KEYRING Kconfig
2 parents 1086eea + 55e2b69 commit 1a35914

File tree

8 files changed

+24
-38
lines changed

8 files changed

+24
-38
lines changed

Documentation/ABI/testing/ima_policy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ Description:
5757
stored in security.ima xattr. Requires
5858
specifying "digest_type=verity" first.)
5959

60-
appraise_flag:= [check_blacklist]
61-
Currently, blacklist check is only for files signed with appended
62-
signature.
60+
appraise_flag:= [check_blacklist] (deprecated)
61+
Setting the check_blacklist flag is no longer necessary.
62+
All appraisal functions set it by default.
6363
digest_type:= verity
6464
Require fs-verity's file digest instead of the
6565
regular IMA file hash.

arch/powerpc/kernel/ima_arch.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ bool arch_ima_get_secureboot(void)
2323
* is not enabled.
2424
*/
2525
static const char *const secure_rules[] = {
26-
"appraise func=KEXEC_KERNEL_CHECK appraise_flag=check_blacklist appraise_type=imasig|modsig",
26+
"appraise func=KEXEC_KERNEL_CHECK appraise_type=imasig|modsig",
2727
#ifndef CONFIG_MODULE_SIG
28-
"appraise func=MODULE_CHECK appraise_flag=check_blacklist appraise_type=imasig|modsig",
28+
"appraise func=MODULE_CHECK appraise_type=imasig|modsig",
2929
#endif
3030
NULL
3131
};
@@ -49,9 +49,9 @@ static const char *const trusted_rules[] = {
4949
static const char *const secure_and_trusted_rules[] = {
5050
"measure func=KEXEC_KERNEL_CHECK template=ima-modsig",
5151
"measure func=MODULE_CHECK template=ima-modsig",
52-
"appraise func=KEXEC_KERNEL_CHECK appraise_flag=check_blacklist appraise_type=imasig|modsig",
52+
"appraise func=KEXEC_KERNEL_CHECK appraise_type=imasig|modsig",
5353
#ifndef CONFIG_MODULE_SIG
54-
"appraise func=MODULE_CHECK appraise_flag=check_blacklist appraise_type=imasig|modsig",
54+
"appraise func=MODULE_CHECK appraise_type=imasig|modsig",
5555
#endif
5656
NULL
5757
};

kernel/kexec_file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ int kexec_locate_mem_hole(struct kexec_buf *kbuf)
624624
* kexec_add_buffer - place a buffer in a kexec segment
625625
* @kbuf: Buffer contents and memory parameters.
626626
*
627-
* This function assumes that kexec_mutex is held.
627+
* This function assumes that kexec_lock is held.
628628
* On successful return, @kbuf->mem will have the physical address of
629629
* the buffer in memory.
630630
*

security/integrity/ima/Kconfig

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -248,18 +248,6 @@ config IMA_APPRAISE_MODSIG
248248
The modsig keyword can be used in the IMA policy to allow a hook
249249
to accept such signatures.
250250

251-
config IMA_TRUSTED_KEYRING
252-
bool "Require all keys on the .ima keyring be signed (deprecated)"
253-
depends on IMA_APPRAISE && SYSTEM_TRUSTED_KEYRING
254-
depends on INTEGRITY_ASYMMETRIC_KEYS
255-
select INTEGRITY_TRUSTED_KEYRING
256-
default y
257-
help
258-
This option requires that all keys added to the .ima
259-
keyring be signed by a key on the system trusted keyring.
260-
261-
This option is deprecated in favor of INTEGRITY_TRUSTED_KEYRING
262-
263251
config IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY
264252
bool "Permit keys validly signed by a built-in or secondary CA cert (EXPERIMENTAL)"
265253
depends on SYSTEM_TRUSTED_KEYRING

security/integrity/ima/ima_appraise.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -458,11 +458,13 @@ int ima_check_blacklist(struct integrity_iint_cache *iint,
458458
ima_get_modsig_digest(modsig, &hash_algo, &digest, &digestsize);
459459

460460
rc = is_binary_blacklisted(digest, digestsize);
461-
if ((rc == -EPERM) && (iint->flags & IMA_MEASURE))
462-
process_buffer_measurement(&nop_mnt_idmap, NULL, digest, digestsize,
463-
"blacklisted-hash", NONE,
464-
pcr, NULL, false, NULL, 0);
465-
}
461+
} else if (iint->flags & IMA_DIGSIG_REQUIRED && iint->ima_hash)
462+
rc = is_binary_blacklisted(iint->ima_hash->digest, iint->ima_hash->length);
463+
464+
if ((rc == -EPERM) && (iint->flags & IMA_MEASURE))
465+
process_buffer_measurement(&nop_mnt_idmap, NULL, digest, digestsize,
466+
"blacklisted-hash", NONE,
467+
pcr, NULL, false, NULL, 0);
466468

467469
return rc;
468470
}

security/integrity/ima/ima_efi.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ static const char * const sb_arch_rules[] = {
5757
"measure func=KEXEC_KERNEL_CHECK",
5858
#if !IS_ENABLED(CONFIG_MODULE_SIG)
5959
"appraise func=MODULE_CHECK appraise_type=imasig",
60+
#endif
61+
#if IS_ENABLED(CONFIG_INTEGRITY_MACHINE_KEYRING) && IS_ENABLED(CONFIG_IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY)
62+
"appraise func=POLICY_CHECK appraise_type=imasig",
6063
#endif
6164
"measure func=MODULE_CHECK",
6265
NULL

security/integrity/ima/ima_kexec.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ static int ima_dump_measurement_list(unsigned long *buffer_size, void **buffer,
7777
* Called during kexec_file_load so that IMA can add a segment to the kexec
7878
* image for the measurement list for the next kernel.
7979
*
80-
* This function assumes that kexec_mutex is held.
80+
* This function assumes that kexec_lock is held.
8181
*/
8282
void ima_add_kexec_buffer(struct kimage *image)
8383
{

security/integrity/ima/ima_policy.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,7 +1280,7 @@ static bool ima_validate_rule(struct ima_rule_entry *entry)
12801280
IMA_FSNAME | IMA_GID | IMA_EGID |
12811281
IMA_FGROUP | IMA_DIGSIG_REQUIRED |
12821282
IMA_PERMIT_DIRECTIO | IMA_VALIDATE_ALGOS |
1283-
IMA_VERITY_REQUIRED))
1283+
IMA_CHECK_BLACKLIST | IMA_VERITY_REQUIRED))
12841284
return false;
12851285

12861286
break;
@@ -1355,7 +1355,7 @@ static bool ima_validate_rule(struct ima_rule_entry *entry)
13551355

13561356
/* Ensure that combinations of flags are compatible with each other */
13571357
if (entry->flags & IMA_CHECK_BLACKLIST &&
1358-
!(entry->flags & IMA_MODSIG_ALLOWED))
1358+
!(entry->flags & IMA_DIGSIG_REQUIRED))
13591359
return false;
13601360

13611361
/*
@@ -1803,11 +1803,11 @@ static int ima_parse_rule(char *rule, struct ima_rule_entry *entry)
18031803
if (entry->flags & IMA_VERITY_REQUIRED)
18041804
result = -EINVAL;
18051805
else
1806-
entry->flags |= IMA_DIGSIG_REQUIRED;
1806+
entry->flags |= IMA_DIGSIG_REQUIRED | IMA_CHECK_BLACKLIST;
18071807
} else if (strcmp(args[0].from, "sigv3") == 0) {
18081808
/* Only fsverity supports sigv3 for now */
18091809
if (entry->flags & IMA_VERITY_REQUIRED)
1810-
entry->flags |= IMA_DIGSIG_REQUIRED;
1810+
entry->flags |= IMA_DIGSIG_REQUIRED | IMA_CHECK_BLACKLIST;
18111811
else
18121812
result = -EINVAL;
18131813
} else if (IS_ENABLED(CONFIG_IMA_APPRAISE_MODSIG) &&
@@ -1816,18 +1816,13 @@ static int ima_parse_rule(char *rule, struct ima_rule_entry *entry)
18161816
result = -EINVAL;
18171817
else
18181818
entry->flags |= IMA_DIGSIG_REQUIRED |
1819-
IMA_MODSIG_ALLOWED;
1819+
IMA_MODSIG_ALLOWED | IMA_CHECK_BLACKLIST;
18201820
} else {
18211821
result = -EINVAL;
18221822
}
18231823
break;
18241824
case Opt_appraise_flag:
18251825
ima_log_string(ab, "appraise_flag", args[0].from);
1826-
if (IS_ENABLED(CONFIG_IMA_APPRAISE_MODSIG) &&
1827-
strstr(args[0].from, "blacklist"))
1828-
entry->flags |= IMA_CHECK_BLACKLIST;
1829-
else
1830-
result = -EINVAL;
18311826
break;
18321827
case Opt_appraise_algos:
18331828
ima_log_string(ab, "appraise_algos", args[0].from);
@@ -2271,8 +2266,6 @@ int ima_policy_show(struct seq_file *m, void *v)
22712266
}
22722267
if (entry->flags & IMA_VERITY_REQUIRED)
22732268
seq_puts(m, "digest_type=verity ");
2274-
if (entry->flags & IMA_CHECK_BLACKLIST)
2275-
seq_puts(m, "appraise_flag=check_blacklist ");
22762269
if (entry->flags & IMA_PERMIT_DIRECTIO)
22772270
seq_puts(m, "permit_directio ");
22782271
rcu_read_unlock();

0 commit comments

Comments
 (0)