lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200529172505.fdjppgquujab7ayv@treble>
Date:   Fri, 29 May 2020 12:25:05 -0500
From:   Josh Poimboeuf <jpoimboe@...hat.com>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     Christoph Hellwig <hch@....de>,
        Randy Dunlap <rdunlap@...radead.org>,
        Andrew Morton <akpm@...ux-foundation.org>, broonie@...nel.org,
        linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-mm@...ck.org, linux-next@...r.kernel.org, mhocko@...e.cz,
        mm-commits@...r.kernel.org, sfr@...b.auug.org.au,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        viro@...iv.linux.org.uk, x86@...nel.org,
        Steven Rostedt <rostedt@...dmis.org>
Subject: [PATCH] x86/uaccess: Remove redundant likely/unlikely annotations

On Fri, May 29, 2020 at 06:54:19PM +0200, Peter Zijlstra wrote:
> On Fri, May 29, 2020 at 11:50:11AM -0500, Josh Poimboeuf wrote:
> > The nested likelys seem like overkill anyway -- user_access_begin() is
> > __always_inline and it already has unlikely(), which should be
> > propagated.
> > 
> > So just remove the outer likelys?
> 
> That fixes it. Ack!

If there are no objections to the patch, I can add it to my objtool-core
branch unless anybody else wants to take it.  It only affects
linux-next.

---8<---

From: Josh Poimboeuf <jpoimboe@...hat.com>
Subject: [PATCH] x86/uaccess: Remove redundant likely/unlikely annotations

Since user_access_begin() already has an unlikely() annotation for its
access_ok() check, "if (likely(user_access_begin))" results in nested
likely annotations.  When combined with CONFIG_TRACE_BRANCH_PROFILING,
GCC converges the error/success paths of the nested ifs, using a
register value to distinguish between them.

While the code is technically uaccess safe, it complicates the
branch-profiling generated code.  It also confuses objtool, because it
doesn't do register value tracking, resulting in the following warnings:

  arch/x86/lib/csum-wrappers_64.o: warning: objtool: csum_and_copy_from_user()+0x2a4: call to memset() with UACCESS enabled
  arch/x86/lib/csum-wrappers_64.o: warning: objtool: csum_and_copy_to_user()+0x243: return with UACCESS enabled

The outer likely annotations aren't actually needed anyway, since the
compiler propagates the error path coldness when it inlines
user_access_begin().

Fixes: 18372ef87665 ("x86_64: csum_..._copy_..._user(): switch to unsafe_..._user()")
Reported-by: Randy Dunlap <rdunlap@...radead.org>
Acked-by: Peter Zijlstra <peterz@...radead.org>
Signed-off-by: Josh Poimboeuf <jpoimboe@...hat.com>
---
 arch/x86/lib/csum-wrappers_64.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
index a12b8629206d..ee63d7576fd2 100644
--- a/arch/x86/lib/csum-wrappers_64.c
+++ b/arch/x86/lib/csum-wrappers_64.c
@@ -27,7 +27,7 @@ csum_and_copy_from_user(const void __user *src, void *dst,
 	might_sleep();
 	*errp = 0;
 
-	if (!likely(user_access_begin(src, len)))
+	if (!user_access_begin(src, len))
 		goto out_err;
 
 	/*
@@ -89,7 +89,7 @@ csum_and_copy_to_user(const void *src, void __user *dst,
 
 	might_sleep();
 
-	if (unlikely(!user_access_begin(dst, len))) {
+	if (!user_access_begin(dst, len)) {
 		*errp = -EFAULT;
 		return 0;
 	}
-- 
2.21.3

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ