Ubuntu-focal-kernel/security
GUO Zihua 5d6945a4f9 ima: remove the IMA_TEMPLATE Kconfig option
BugLink: https://bugs.launchpad.net/bugs/1988225

[ Upstream commit 891163adf180bc369b2f11c9dfce6d2758d2a5bd ]

The original 'ima' measurement list template contains a hash, defined
as 20 bytes, and a null terminated pathname, limited to 255
characters.  Other measurement list templates permit both larger hashes
and longer pathnames.  When the "ima" template is configured as the
default, a new measurement list template (ima_template=) must be
specified before specifying a larger hash algorithm (ima_hash=) on the
boot command line.

To avoid this boot command line ordering issue, remove the legacy "ima"
template configuration option, allowing it to still be specified on the
boot command line.

The root cause of this issue is that during the processing of ima_hash,
we would try to check whether the hash algorithm is compatible with the
template. If the template is not set at the moment we do the check, we
check the algorithm against the configured default template. If the
default template is "ima", then we reject any hash algorithm other than
sha1 and md5.

For example, if the compiled default template is "ima", and the default
algorithm is sha1 (which is the current default). In the cmdline, we put
in "ima_hash=sha256 ima_template=ima-ng". The expected behavior would be
that ima starts with ima-ng as the template and sha256 as the hash
algorithm. However, during the processing of "ima_hash=",
"ima_template=" has not been processed yet, and hash_setup would check
the configured hash algorithm against the compiled default: ima, and
reject sha256. So at the end, the hash algorithm that is actually used
will be sha1.

With template "ima" removed from the configured default, we ensure that
the default tempalte would at least be "ima-ng" which allows for
basically any hash algorithm.

This change would not break the algorithm compatibility checks for IMA.

Fixes: 4286587dcc ("ima: add Kconfig default measurement list template")
Signed-off-by: GUO Zihua <guozihua@huawei.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
2022-09-16 10:59:56 +02:00
..
apparmor apparmor: fix error check 2022-01-13 18:42:35 +01:00
integrity ima: remove the IMA_TEMPLATE Kconfig option 2022-09-16 10:59:56 +02:00
keys KEYS: fix length validation in keyctl_pkey_params_get_2() 2022-05-20 15:18:16 +02:00
loadpin
lockdown UBUNTU: SAUCE: debug: Lock down kgdb 2022-05-21 11:27:20 -03:00
safesetid
selinux selinux: use correct type for context length 2022-05-20 15:19:17 +02:00
smack Fix incorrect type in assignment of ipv6 port for audit 2022-05-20 15:19:18 +02:00
tomoyo TOMOYO: fix __setup handlers return values 2022-05-20 15:18:57 +02:00
yama
Kconfig fortify: Explicitly disable Clang support 2022-01-13 18:42:48 +01:00
Kconfig.hardening
Makefile
commoncap.c security: commoncap: fix -Wstringop-overread warning 2021-05-19 10:59:48 +02:00
device_cgroup.c
inode.c
lsm_audit.c dump_common_audit_data(): fix racy accesses to ->d_name 2021-02-19 16:44:53 +01:00
min_addr.c
security.c LSM: general protection fault in legacy_parse_param 2022-05-20 15:19:16 +02:00