]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selinux: avoid implicit conversions regarding enforcing status
authorChristian Göttsche <cgzones@googlemail.com>
Thu, 6 Jul 2023 13:23:34 +0000 (15:23 +0200)
committerPaul Moore <paul@paul-moore.com>
Tue, 18 Jul 2023 22:29:50 +0000 (18:29 -0400)
Use the type bool as parameter type in
selinux_status_update_setenforce().  The related function
enforcing_enabled() returns the type bool, while the struct
selinux_kernel_status member enforcing uses an u32.

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
[PM: subject line tweaks]
Signed-off-by: Paul Moore <paul@paul-moore.com>
security/selinux/include/security.h
security/selinux/selinuxfs.c
security/selinux/status.c

index 08840aa0782d2b2246b65e98fe06e7722fec3853..6b8b8fc3badd70afd72474d6766798ae75ca36ec 100644 (file)
@@ -375,7 +375,7 @@ struct selinux_kernel_status {
         */
 } __packed;
 
-extern void selinux_status_update_setenforce(int enforcing);
+extern void selinux_status_update_setenforce(bool enforcing);
 extern void selinux_status_update_policyload(u32 seqno);
 extern void selinux_complete_init(void);
 extern struct path selinux_null;
index bad1f6b685fd9a62c10157b1d8def363c6432841..f79e96f0f221114517c4a07c5d60593ccda479d2 100644 (file)
@@ -138,7 +138,8 @@ static ssize_t sel_write_enforce(struct file *file, const char __user *buf,
 {
        char *page = NULL;
        ssize_t length;
-       int old_value, new_value;
+       int scan_value;
+       bool old_value, new_value;
 
        if (count >= PAGE_SIZE)
                return -ENOMEM;
@@ -152,10 +153,10 @@ static ssize_t sel_write_enforce(struct file *file, const char __user *buf,
                return PTR_ERR(page);
 
        length = -EINVAL;
-       if (sscanf(page, "%d", &new_value) != 1)
+       if (sscanf(page, "%d", &scan_value) != 1)
                goto out;
 
-       new_value = !!new_value;
+       new_value = !!scan_value;
 
        old_value = enforcing_enabled();
        if (new_value != old_value) {
index e436e4975adc2714f0de1aad8a79bed08b1436f5..dffca22ce6f747429c48cf84b3ccf4f810e1f61c 100644 (file)
@@ -76,7 +76,7 @@ struct page *selinux_kernel_status_page(void)
  *
  * It updates status of the current enforcing/permissive mode.
  */
-void selinux_status_update_setenforce(int enforcing)
+void selinux_status_update_setenforce(bool enforcing)
 {
        struct selinux_kernel_status   *status;
 
@@ -87,7 +87,7 @@ void selinux_status_update_setenforce(int enforcing)
                status->sequence++;
                smp_wmb();
 
-               status->enforcing = enforcing;
+               status->enforcing = enforcing ? 1 : 0;
 
                smp_wmb();
                status->sequence++;