diff mbox series

selinux: various sparse fixes

Message ID 164330287653.95708.5024040003451330147.stgit@olly (mailing list archive)
State Superseded
Delegated to: Paul Moore
Headers show
Series selinux: various sparse fixes | expand

Commit Message

Paul Moore Jan. 27, 2022, 5:01 p.m. UTC
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/

Signed-off-by: Paul Moore <paul@paul-moore.com>
---
 security/selinux/hooks.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Paul Moore Jan. 27, 2022, 5:48 p.m. UTC | #1
On Thu, Jan 27, 2022 at 12:01 PM Paul Moore <paul@paul-moore.com> wrote:
>
> 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/
>
> Signed-off-by: Paul Moore <paul@paul-moore.com>
> ---
>  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.

> diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
> index c057896e7dcd..da04f3435268 100644
> --- a/security/selinux/hooks.c
> +++ b/security/selinux/hooks.c
> @@ -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);
>  }
diff mbox series

Patch

diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index c057896e7dcd..da04f3435268 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -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);
 }