* [PATCH v2] ima: kexec: silence RCU list traversal warning
@ 2024-11-21 9:57 Breno Leitao
2025-01-16 11:23 ` Breno Leitao
0 siblings, 1 reply; 3+ messages in thread
From: Breno Leitao @ 2024-11-21 9:57 UTC (permalink / raw)
To: Mimi Zohar, Roberto Sassu, Dmitry Kasatkin, Eric Snowberg,
Paul Moore, James Morris, Serge E. Hallyn, Eric W. Biederman,
Andrew Morton
Cc: Mimi Zohar, linux-integrity, linux-security-module, linux-kernel,
kernel-team, Breno Leitao
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>
---
Changes in v2:
- Do not hold the RCU read lock, but, annotate list_for_each_entry_rcu()
that is OK to traverse the list without the RCU read lock.
- Link to v1: https://lore.kernel.org/r/20241104-ima_rcu-v1-1-5157460c5907@debian.org
---
security/integrity/ima/ima_kexec.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/security/integrity/ima/ima_kexec.c b/security/integrity/ima/ima_kexec.c
index 52e00332defed39774c9e23e045f1377cfa30d0c..9d45f4d26f731658a79b94b9f95f4dcc4dcb6325 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);
---
base-commit: ac24e26aa08fe026804f678599f805eb13374a5d
change-id: 20241104-ima_rcu-ee83da87d050
Best regards,
--
Breno Leitao <leitao@debian.org>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] ima: kexec: silence RCU list traversal warning
2024-11-21 9:57 [PATCH v2] ima: kexec: silence RCU list traversal warning Breno Leitao
@ 2025-01-16 11:23 ` Breno Leitao
2025-01-17 23:37 ` Mimi Zohar
0 siblings, 1 reply; 3+ messages in thread
From: Breno Leitao @ 2025-01-16 11:23 UTC (permalink / raw)
To: Mimi Zohar, Roberto Sassu, Dmitry Kasatkin, Eric Snowberg,
Paul Moore, James Morris, Serge E. Hallyn, Eric W. Biederman,
Andrew Morton
Cc: Mimi Zohar, linux-integrity, linux-security-module, linux-kernel,
kernel-team
Hello Mimi,
On Thu, Nov 21, 2024 at 01:57:12AM -0800, Breno Leitao wrote:
> 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!!
What are the next steps in regarding this issue? I am still seeing this
problem on Linus' tree.
Thanks
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] ima: kexec: silence RCU list traversal warning
2025-01-16 11:23 ` Breno Leitao
@ 2025-01-17 23:37 ` Mimi Zohar
0 siblings, 0 replies; 3+ messages in thread
From: Mimi Zohar @ 2025-01-17 23:37 UTC (permalink / raw)
To: Breno Leitao, Roberto Sassu, Dmitry Kasatkin, Eric Snowberg,
Paul Moore, James Morris, Serge E. Hallyn, Eric W. Biederman,
Andrew Morton
Cc: Mimi Zohar, linux-integrity, linux-security-module, linux-kernel,
kernel-team
On Thu, 2025-01-16 at 03:23 -0800, Breno Leitao wrote:
> Hello Mimi,
>
> On Thu, Nov 21, 2024 at 01:57:12AM -0800, Breno Leitao wrote:
> > 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!!
>
> What are the next steps in regarding this issue? I am still seeing this
> problem on Linus' tree.
It's included in the v6.14 pull request, which I just sent.
thanks,
Mimi
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-01-17 23:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-21 9:57 [PATCH v2] ima: kexec: silence RCU list traversal warning Breno Leitao
2025-01-16 11:23 ` Breno Leitao
2025-01-17 23:37 ` Mimi Zohar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).