selinux: add comments to smp_wmb() calls in status.c
PATCH 1/1 selinux: add comments to smp_wmb() calls in status.c
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.
--- security/selinux/status.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
security/selinux/status.c +5 -5
@@ -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);
Signature · 1 line
2.54.0
Paul Moore
maintainerQuoted 11 lines · On May 21, 2026 Oliwier Iwan <[email protected]> wrote:
The seqlock pattern used in
selinux_status_update_setenforce()andselinux_status_update_policyload()requires memory barriers to ensure correct ordering of the sequence counter updates relative to the data writes. Add comments to thesmp_wmb()calls to make this ordering explicit and self-documenting.Signed-off-by Oliwier Iwan <[email protected]>--- security/selinux/status.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
Thank you for submitting a patch, but I don't believe the comments are necessary.
--
paul-moore.com