kernel_samsung_a53x/security
liqiong 86d206899c ima: fix deadlock when traversing "ima_default_rules".
commit eb0782bbdfd0d7c4786216659277c3fd585afc0e upstream.

The current IMA ruleset is identified by the variable "ima_rules"
that default to "&ima_default_rules". When loading a custom policy
for the first time, the variable is updated to "&ima_policy_rules"
instead. That update isn't RCU-safe, and deadlocks are possible.
Indeed, some functions like ima_match_policy() may loop indefinitely
when traversing "ima_default_rules" with list_for_each_entry_rcu().

When iterating over the default ruleset back to head, if the list
head is "ima_default_rules", and "ima_rules" have been updated to
"&ima_policy_rules", the loop condition (&entry->list != ima_rules)
stays always true, traversing won't terminate, causing a soft lockup
and RCU stalls.

Introduce a temporary value for "ima_rules" when iterating over
the ruleset to avoid the deadlocks.

Signed-off-by: liqiong <liqiong@nfschina.com>
Reviewed-by: THOBY Simon <Simon.THOBY@viveris.fr>
Fixes: 38d859f991f3 ("IMA: policy can now be updated multiple times")
Reported-by: kernel test robot <lkp@intel.com> (Fix sparse: incompatible types in comparison expression.)
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
Signed-off-by: GUO Zihua <guozihua@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-11-19 12:26:38 +01:00
..
apparmor lsm: make security_socket_getpeersec_stream() sockptr_t safe 2024-11-18 23:19:51 +01:00
bpf Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
integrity ima: fix deadlock when traversing "ima_default_rules". 2024-11-19 12:26:38 +01:00
keys keys: Fix overwrite of key expiration on instantiation 2024-11-19 11:32:49 +01:00
loadpin Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
lockdown Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
safesetid Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
samsung security: samsung: defex_lsm: nuke 2024-06-15 16:20:49 -03:00
sdp Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
selinux lsm: make security_socket_getpeersec_stream() sockptr_t safe 2024-11-18 23:19:51 +01:00
smack smack: Handle SMACK64TRANSMUTE in smack_inode_setsecurity() 2024-11-19 09:22:14 +01:00
tomoyo tomoyo: fix UAF write bug in tomoyo_write_control() 2024-11-18 23:18:29 +01:00
yama Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
commoncap.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
device_cgroup.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
inode.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Kconfig security: samsung: defex_lsm: nuke 2024-06-15 16:20:49 -03:00
Kconfig.hardening Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
lsm_audit.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Makefile security: samsung: defex_lsm: nuke 2024-06-15 16:20:49 -03:00
min_addr.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
security.c lsm: fix default return value of the socket_getpeersec_*() hooks 2024-11-18 23:19:51 +01:00