Skip to contentSkip to conversation

seccomp: remove unnecessary unlikely()

PATCH In review Igor Stoppa 3 participants 7 messages Sep 5, 2018 – Sep 6, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 seccomp: remove unnecessary unlikely()

WARN_ON() already contains an unlikely(), so it's not necessary to wrap it into another.

Cc linux-security-module at vger.kernel.org
Cc linux-kernel at vger.kernel.org
---
 kernel/seccomp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/seccomp.c +2 -2
index fd023ac24e10..5a2a9af4663e 100644
@@ -195,7 +195,7 @@ static u32 seccomp_run_filters(const struct seccomp_data *sd,
 			READ_ONCE(current->seccomp.filter);
 
 	/* Ensure unexpected behavior doesn't result in failing open. */
-	if (unlikely(WARN_ON(f == NULL)))
+	if (WARN_ON(f == NULL))
 		return SECCOMP_RET_KILL_PROCESS;
 
 	if (!sd) {
@@ -297,7 +297,7 @@ static inline pid_t seccomp_can_sync_threads(void)
 		/* Return the first thread that cannot be synchronized. */
 		failed = task_pid_vnr(thread);
 		/* If the pid cannot be resolved, then return -ESRCH */
-		if (unlikely(WARN_ON(failed == 0)))
+		if (WARN_ON(failed == 0))
 			failed = -ESRCH;
 		return failed;
 	}
Signature · 1 line
2.17.1
#1 lore raw
Quoted 5 lines · Igor Stoppa

WARN_ON() already contains an unlikely(), so it's not necessary to wrap it into another.

Should I take this, or is it part of your series going somewhere else?

-Kees

Quoted 31 lines
Cc linux-security-module at vger.kernel.org
Cc linux-kernel at vger.kernel.org
---
 kernel/seccomp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/seccomp.c +2 -3
index fd023ac24e10..5a2a9af4663e 100644
@@ -195,7 +195,7 @@ static u32 seccomp_run_filters(const struct seccomp_data *sd,
                        READ_ONCE(current->seccomp.filter);
 
        /* Ensure unexpected behavior doesn't result in failing open. */
-       if (unlikely(WARN_ON(f == NULL)))
+       if (WARN_ON(f == NULL))
                return SECCOMP_RET_KILL_PROCESS;
 
        if (!sd) {
@@ -297,7 +297,7 @@ static inline pid_t seccomp_can_sync_threads(void)
                /* Return the first thread that cannot be synchronized. */
                failed = task_pid_vnr(thread);
                /* If the pid cannot be resolved, then return -ESRCH */
-               if (unlikely(WARN_ON(failed == 0)))
+               if (WARN_ON(failed == 0))
                        failed = -ESRCH;
                return failed;
        }
--

2.17.1

Signature · 2 lines
Kees Cook
Pixel Security
#2 lore raw
Quoted 1 line · Kees Cook

Should I take this, or is it part of your series going somewhere else?

It turned out it doesn't really work to have a generic series against 20 trees :-/

I'm submitting them individually to each subsystem. So this one is just for security.

--
thanks, igor

#3 lore raw
Quoted 9 lines · Igor Stoppa
Quoted 1 line · Kees Cook

Should I take this, or is it part of your series going somewhere else?

It turned out it doesn't really work to have a generic series against 20 trees :-/

I know that pain very well!

Quoted 2 lines

I'm submitting them individually to each subsystem. So this one is just for security.

Sounds good.

James, can you take this directly, or would you prefer a pull request from me?

-Kees

Signature · 2 lines
Kees Cook
Pixel Security
maintainer
#4 lore raw
Quoted 11 lines · Kees Cook
Quoted 9 lines · Igor Stoppa
Quoted 1 line · Kees Cook

Should I take this, or is it part of your series going somewhere else?

It turned out it doesn't really work to have a generic series against 20 trees :-/

Quoted 8 lines

I know that pain very well!

Quoted 2 lines

I'm submitting them individually to each subsystem. So this one is just for security.

Sounds good.

James, can you take this directly, or would you prefer a pull request from me?

I'll take it with your ack.

Signature · 2 lines
James Morris
<[email protected]>
Acked-by
#5 lore raw
Quoted 15 lines · James Morris
Quoted 13 lines · Kees Cook
Quoted 9 lines · Igor Stoppa
Quoted 1 line · Kees Cook

Should I take this, or is it part of your series going somewhere else?

It turned out it doesn't really work to have a generic series against 20 trees :-/

I know that pain very well!

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

I'm submitting them individually to each subsystem. So this one is just for security.

Sounds good.

James, can you take this directly, or would you prefer a pull request from me?

I'll take it with your ack.

Already included! :) (This was a v2, split from a separate series, so Igor already included my Ack from the other thread.)

But, for completeness:

-Kees

Signature · 2 lines
Kees Cook
Pixel Security
maintainer
#6 lore raw
In reply to Igor Stoppa
Quoted 7 lines · Igor Stoppa

WARN_ON() already contains an unlikely(), so it's not necessary to wrap it into another.

Cc linux-security-module at vger.kernel.org
Cc linux-kernel at vger.kernel.org

Applied to
git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security.git next-general

and next-testing.

Thanks!

Signature · 2 lines
James Morris
<[email protected]>