From: Andy Lutomirski <luto@kernel.org>
To: x86@kernel.org
Cc: LKML <linux-kernel@vger.kernel.org>,
Bill Wendling <morbo@google.com>,
Nick Desaulniers <ndesaulniers@google.com>,
Greg Thelen <gthelen@google.com>,
John Sperbeck <jsperbeck@google.com>,
Andy Lutomirski <luto@kernel.org>,
stable@vger.kernel.org
Subject: [PATCH] x86/smap: Fix the smap_save() asm
Date: Tue, 15 Sep 2020 13:55:58 -0700 [thread overview]
Message-ID: <9f513eef618b6e72a088cc8b2787496f190d1c2d.1600203307.git.luto@kernel.org> (raw)
The old smap_save() code was:
pushf
pop %0
with %0 defined by an "=rm" constraint. This is fine if the
compiler picked the register option, but it was incorrect with an
%rsp-relative memory operand. With some intentional abuse, I can
get both gcc and clang to generate code along these lines:
pushfq
popq 0x8(%rsp)
mov 0x8(%rsp),%rax
which is incorrect and will not work as intended.
Fix it by removing the memory option. This issue is exacerbated by
a clang optimization bug:
https://bugs.llvm.org/show_bug.cgi?id=47530
Fixes: e74deb11931f ("x86/uaccess: Introduce user_access_{save,restore}()")
Cc: stable@vger.kernel.org
Reported-by: Bill Wendling <morbo@google.com> # I think
Signed-off-by: Andy Lutomirski <luto@kernel.org>
---
arch/x86/include/asm/smap.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/smap.h b/arch/x86/include/asm/smap.h
index 8b58d6975d5d..be6d675ae3ac 100644
--- a/arch/x86/include/asm/smap.h
+++ b/arch/x86/include/asm/smap.h
@@ -61,7 +61,7 @@ static __always_inline unsigned long smap_save(void)
ALTERNATIVE("jmp 1f", "", X86_FEATURE_SMAP)
"pushf; pop %0; " __ASM_CLAC "\n\t"
"1:"
- : "=rm" (flags) : : "memory", "cc");
+ : "=r" (flags) : : "memory", "cc");
return flags;
}
--
2.26.2
next reply other threads:[~2020-09-15 20:58 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-15 20:55 Andy Lutomirski [this message]
2020-09-15 21:24 ` [PATCH] x86/smap: Fix the smap_save() asm Nick Desaulniers
2020-09-15 21:31 ` Bill Wendling
2020-09-15 23:11 ` Andy Lutomirski
[not found] ` <7233f4cf-5b1d-0fca-0880-f1cf2e6e765b@citrix.com>
2020-09-15 23:43 ` Bill Wendling
2020-09-16 8:26 ` Borislav Petkov
[not found] ` <be498e49-b467-e04c-d833-372f7d83cb1f@citrix.com>
2020-09-17 6:04 ` Borislav Petkov
[not found] ` <ec617df229514fbaa9897683ac88dfda@AcuMS.aculab.com>
2020-09-17 11:57 ` Borislav Petkov
[not found] ` <823af5fadd464c48ade635498d07ba4e@AcuMS.aculab.com>
2020-09-17 14:39 ` Borislav Petkov
2020-09-17 16:32 ` Andy Lutomirski
2020-09-16 7:28 ` peterz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9f513eef618b6e72a088cc8b2787496f190d1c2d.1600203307.git.luto@kernel.org \
--to=luto@kernel.org \
--cc=gthelen@google.com \
--cc=jsperbeck@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=morbo@google.com \
--cc=ndesaulniers@google.com \
--cc=stable@vger.kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).