summaryrefslogtreecommitdiff
path: root/security
diff options
context:
space:
mode:
authorBreno Leitao <leitao@debian.org>2024-11-21 01:57:12 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-03-13 17:20:27 +0100
commit9e6bd0a8c1aff61018453453e1f9e2012c16fba3 (patch)
tree4e91882608817711f325dbb5a35cabeca12262fb /security
parenta97228fb32e1c908208bdd2731ae2d756cea6213 (diff)
ima: kexec: silence RCU list traversal warning
[ Upstream commit 68af44a71975688b881ea524e2526bb7c7ad0e9a ] The ima_measurements list is append-only and doesn't require rcu_read_lock() protection. However, lockdep issues a warning when traversing RCU lists without the read lock: security/integrity/ima/ima_kexec.c:40 RCU-list traversed in non-reader section!! Fix this by using the variant of list_for_each_entry_rcu() with the last argument set to true. This tells the RCU subsystem that traversing this append-only list without the read lock is intentional and safe. This change silences the lockdep warning while maintaining the correct semantics for the append-only list traversal. Signed-off-by: Breno Leitao <leitao@debian.org> Signed-off-by: Mimi Zohar <zohar@linux.ibm.com> Stable-dep-of: 10d1c75ed438 ("ima: verify the previous kernel's IMA buffer lies in addressable RAM") Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'security')
-rw-r--r--security/integrity/ima/ima_kexec.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/security/integrity/ima/ima_kexec.c b/security/integrity/ima/ima_kexec.c
index 52e00332defe..9d45f4d26f73 100644
--- a/security/integrity/ima/ima_kexec.c
+++ b/security/integrity/ima/ima_kexec.c
@@ -37,7 +37,8 @@ static int ima_dump_measurement_list(unsigned long *buffer_size, void **buffer,
memset(&khdr, 0, sizeof(khdr));
khdr.version = 1;
- list_for_each_entry_rcu(qe, &ima_measurements, later) {
+ /* This is an append-only list, no need to hold the RCU read lock */
+ list_for_each_entry_rcu(qe, &ima_measurements, later, true) {
if (file.count < file.size) {
khdr.count++;
ima_measurements_show(&file, qe);