From: Mikulas Patocka <mpatocka@redhat.com>
To: Benjamin Marzinski <bmarzins@redhat.com>
Cc: Mike Snitzer <snitzer@kernel.org>,
dm-devel@lists.linux.dev, linux-integrity@vger.kernel.org,
Mimi Zohar <zohar@linux.ibm.com>,
Roberto Sassu <roberto.sassu@huawei.com>,
Dmitry Kasatkin <dmitry.kasatkin@gmail.com>
Subject: Re: [PATCH 05/10] dm-ima: Fix UAF errors and measuring incorrect context
Date: Mon, 27 Apr 2026 21:42:37 +0200 (CEST) [thread overview]
Message-ID: <a137657f-64e7-6796-33db-51b200b87fa5@redhat.com> (raw)
In-Reply-To: <75a6b1cf-9f0d-8fc2-57d5-f6dee4913c65@redhat.com>
On Mon, 27 Apr 2026, Mikulas Patocka wrote:
> Hi
>
>
> On Mon, 13 Apr 2026, Benjamin Marzinski wrote:
>
> > + smp_mb__before_atomic();
> > + atomic_inc(&ima->measure_idx);
> > + wake_up_all(&ima->ima_wq);
>
> There should be smp_mb__after_atomic() after atomic_inc() and before
> wake_up_all(). Otherwise, the increment of atomic_inc could be moved
> inside the wait queue spinlock in wake_up_all and executed after the wait
> queue is checked for being empty.
>
> Generally, the atomic variables and barriers are very hard to get right,
> this is not performance-critical code that would justify the
> complications, so I suggest to use a normal spinlock instead.
>
> You can use something like:
> spin_lock_irq(&ima->ima_wq.lock);
> ima->measure_idx++;
> wake_up_all_locked(&ima->ima_wq);
> spin_unlock_irq(&ima->ima_wq.lock);
>
> --- this would be obviously safe and easy to verify.
>
> Mikulas
BTW. you can see "&ic->endio_wait.lock" in drivers/md/dm-integrity.c for
an example, how to use this pattern.
Mikulas
next prev parent reply other threads:[~2026-04-27 19:42 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-14 0:22 [RFC PATCH 00/10] Fix dm-ima bugs Benjamin Marzinski
2026-04-14 0:22 ` [PATCH 01/10] dm-ima: remove dm_ima_reset_data() Benjamin Marzinski
2026-04-14 0:22 ` [PATCH 02/10] dm-ima: remove broken last_target_measured logic Benjamin Marzinski
2026-04-14 0:22 ` [PATCH 03/10] dm-ima: Remove status_flags from dm_ima_measure_on_table_load() Benjamin Marzinski
2026-04-14 0:22 ` [PATCH 04/10] dm-ima: don't copy the active table to the inactive table Benjamin Marzinski
2026-04-14 0:22 ` [PATCH 05/10] dm-ima: Fix UAF errors and measuring incorrect context Benjamin Marzinski
2026-04-27 19:33 ` Mikulas Patocka
2026-04-27 19:42 ` Mikulas Patocka [this message]
2026-04-14 0:22 ` [PATCH 06/10] dm-ima: remove new_map from dm_ima_measure_on_device_clear Benjamin Marzinski
2026-04-14 0:22 ` [PATCH 07/10] dm-ima: Fix issues with dm_ima_measure_on_device_rename Benjamin Marzinski
2026-04-14 0:22 ` [PATCH 08/10] dm-ima: Handle race between rename and table swap Benjamin Marzinski
2026-04-14 0:22 ` [PATCH 09/10] dm-ima: Fail more gracefully in dm_ima_measure_on_* Benjamin Marzinski
2026-04-14 0:22 ` [PATCH 10/10] dm-ima: use active table's size if available Benjamin Marzinski
2026-04-14 17:12 ` [RFC PATCH 00/10] Fix dm-ima bugs Mike Snitzer
2026-04-14 18:35 ` Benjamin Marzinski
2026-04-15 2:06 ` Mimi Zohar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a137657f-64e7-6796-33db-51b200b87fa5@redhat.com \
--to=mpatocka@redhat.com \
--cc=bmarzins@redhat.com \
--cc=dm-devel@lists.linux.dev \
--cc=dmitry.kasatkin@gmail.com \
--cc=linux-integrity@vger.kernel.org \
--cc=roberto.sassu@huawei.com \
--cc=snitzer@kernel.org \
--cc=zohar@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox