Skip to contentSkip to conversation

selinux: various sparse fixes

PATCH Superseded Paul Moore 1 participant 2 messages Jan 27, 2022 SELinux security module

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Paul Moore

author maintainer
#0 lore raw

PATCH 1/1 selinux: various sparse fixes

When running the SELinux code through sparse, there are a handful of warnings. This patch resolves some of these warnings by casting away the "__rcu" attribute in a few core kernel function calls.

% make W=1 C=1 security/selinux/

---
 security/selinux/hooks.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
security/selinux/hooks.c +4 -3
index c057896e7dcd..da04f3435268 100644
@@ -2534,7 +2534,7 @@ static void selinux_bprm_committed_creds(struct linux_binprm *bprm)
 	if (rc) {
 		clear_itimer();
 
-		spin_lock_irq(&current->sighand->siglock);
+		spin_lock_irq((__force spinlock_t *)&current->sighand->siglock);
 		if (!fatal_signal_pending(current)) {
 			flush_sigqueue(&current->pending);
 			flush_sigqueue(&current->signal->shared_pending);
@@ -2542,13 +2542,14 @@ static void selinux_bprm_committed_creds(struct linux_binprm *bprm)
 			sigemptyset(&current->blocked);
 			recalc_sigpending();
 		}
-		spin_unlock_irq(&current->sighand->siglock);
+		spin_unlock_irq((__force spinlock_t *)&current->sighand->siglock);
 	}
 
 	/* Wake up the parent if it is waiting so that it can recheck
 	 * wait permission to the new task SID. */
 	read_lock(&tasklist_lock);
-	__wake_up_parent(current, current->real_parent);
+	__wake_up_parent(current,
+			 (__force struct task_struct *)current->real_parent);
 	read_unlock(&tasklist_lock);
 }
 
author maintainer
#1 lore raw
Quoted 11 lines · Paul Moore

When running the SELinux code through sparse, there are a handful of warnings. This patch resolves some of these warnings by casting away the "__rcu" attribute in a few core kernel function calls.

% make W=1 C=1 security/selinux/

---
 security/selinux/hooks.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Self NACK as this is likely also a good candidate for the unrcu macro treatment that Ondrej suggested.

Quoted 29 lines
security/selinux/hooks.c +4 -3
index c057896e7dcd..da04f3435268 100644
@@ -2534,7 +2534,7 @@ static void selinux_bprm_committed_creds(struct linux_binprm *bprm)
        if (rc) {
                clear_itimer();
 
-               spin_lock_irq(&current->sighand->siglock);
+               spin_lock_irq((__force spinlock_t *)&current->sighand->siglock);
                if (!fatal_signal_pending(current)) {
                        flush_sigqueue(&current->pending);
                        flush_sigqueue(&current->signal->shared_pending);
@@ -2542,13 +2542,14 @@ static void selinux_bprm_committed_creds(struct linux_binprm *bprm)
                        sigemptyset(&current->blocked);
                        recalc_sigpending();
                }
-               spin_unlock_irq(&current->sighand->siglock);
+               spin_unlock_irq((__force spinlock_t *)&current->sighand->siglock);
        }
 
        /* Wake up the parent if it is waiting so that it can recheck
         * wait permission to the new task SID. */
        read_lock(&tasklist_lock);
-       __wake_up_parent(current, current->real_parent);
+       __wake_up_parent(current,
+                        (__force struct task_struct *)current->real_parent);
        read_unlock(&tasklist_lock);
 }
Signature · 1 line
paul-moore.com