From: Oliwier Iwan <oliwieriwan@mailbox.org>
To: selinux@vger.kernel.org
Cc: paul@paul-moore.com, stephen.smalley.work@gmail.com,
omosnace@redhat.com, linux-kernel@vger.kernel.org,
Oliwier Iwan <oliwieriwan@mailbox.org>
Subject: [PATCH] selinux: add comments to smp_wmb() calls in status.c
Date: Thu, 21 May 2026 23:38:15 +0100 [thread overview]
Message-ID: <20260521223815.67902-1-oliwieriwan@mailbox.org> (raw)
The seqlock pattern used in selinux_status_update_setenforce() and
selinux_status_update_policyload() requires memory barriers to ensure
correct ordering of the sequence counter updates relative to the data
writes. Add comments to the smp_wmb() calls to make this ordering
explicit and self-documenting.
Signed-off-by: Oliwier Iwan <oliwieriwan@mailbox.org>
---
security/selinux/status.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/security/selinux/status.c b/security/selinux/status.c
index dffca22ce..52d3a40a3 100644
--- a/security/selinux/status.c
+++ b/security/selinux/status.c
@@ -46,7 +46,7 @@ struct page *selinux_kernel_status_page(void)
mutex_lock(&selinux_state.status_lock);
if (!selinux_state.status_page) {
- selinux_state.status_page = alloc_page(GFP_KERNEL|__GFP_ZERO);
+ selinux_state.status_page = alloc_page(GFP_KERNEL | __GFP_ZERO);
if (selinux_state.status_page) {
status = page_address(selinux_state.status_page);
@@ -85,11 +85,11 @@ void selinux_status_update_setenforce(bool enforcing)
status = page_address(selinux_state.status_page);
status->sequence++;
- smp_wmb();
+ smp_wmb(); /* ensure sequence increment visible before data update */
status->enforcing = enforcing ? 1 : 0;
- smp_wmb();
+ smp_wmb(); /* ensure data update visible before sequence increment */
status->sequence++;
}
mutex_unlock(&selinux_state.status_lock);
@@ -110,12 +110,12 @@ void selinux_status_update_policyload(u32 seqno)
status = page_address(selinux_state.status_page);
status->sequence++;
- smp_wmb();
+ smp_wmb(); /* ensure sequence increment visible before data update */
status->policyload = seqno;
status->deny_unknown = !security_get_allow_unknown();
- smp_wmb();
+ smp_wmb(); /* ensure data update visible before sequence update */
status->sequence++;
}
mutex_unlock(&selinux_state.status_lock);
--
2.54.0
next reply other threads:[~2026-05-21 22:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-21 22:38 Oliwier Iwan [this message]
2026-05-28 0:05 ` Paul Moore
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=20260521223815.67902-1-oliwieriwan@mailbox.org \
--to=oliwieriwan@mailbox.org \
--cc=linux-kernel@vger.kernel.org \
--cc=omosnace@redhat.com \
--cc=paul@paul-moore.com \
--cc=selinux@vger.kernel.org \
--cc=stephen.smalley.work@gmail.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
all inboxes | Powered by JetHome®