Skip to contentSkip to conversation

x86/speculation, objtool: Annotate indirect calls/jumps for objtool on 32bit

PATCH Applied Andy Whitcroft 5 participants 7 messages Mar 14, 2018

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

PATCH 1/1 x86/speculation, objtool: Annotate indirect calls/jumps for objtool on 32bit

In 9e0e3c5130e9 ("x86/speculation, objtool: Annotate indirect calls/jumps for objtool") we added annotations for CALL_NOSPEC/JMP_NOSPEC on x86 64bit. We did not annotate the 32bit path. Annotate it similarly.

---
 arch/x86/include/asm/nospec-branch.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

While reviewing indirect calls in our builds I noted that the i386 retpoline CALL_NOSPEC is not annotated safe even though its amd64 equivalent is. I cannot see any reason this is not also inherantly safe. Peter was there a reason that you did not annotate this one too? Anyhow, on the assumption this was just missed, this patch annotates it.

-apw

arch/x86/include/asm/nospec-branch.h +4 -1
index d0dabeae0505..07886162bdf8 100644
@@ -183,7 +183,10 @@
  * otherwise we'll run out of registers. We don't care about CET
  * here, anyway.
  */
-# define CALL_NOSPEC ALTERNATIVE("call *%[thunk_target]\n",	\
+# define CALL_NOSPEC 						\
+	ALTERNATIVE(						\
+	ANNOTATE_RETPOLINE_SAFE					\
+	"call *%[thunk_target]\n",				\
 	"       jmp    904f;\n"					\
 	"       .align 16\n"					\
 	"901:	call   903f;\n"					\
Signature · 1 line
2.15.1
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Andy Whitcroft

In 9e0e3c5130e9 ("x86/speculation, objtool: Annotate indirect calls/jumps for objtool") we added annotations for CALL_NOSPEC/JMP_NOSPEC on x86 64bit. We did not annotate the 32bit path. Annotate it similarly.

---
 arch/x86/include/asm/nospec-branch.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Quoted 6 lines

While reviewing indirect calls in our builds I noted that the i386 retpoline CALL_NOSPEC is not annotated safe even though its amd64 equivalent is. I cannot see any reason this is not also inherantly safe. Peter was there a reason that you did not annotate this one too? Anyhow, on the assumption this was just missed, this patch annotates it.

Yeah, just an oversight aided by the fact that I (obviously) never build 32bit kernels.

Quoted 6 lines
arch/x86/include/asm/nospec-branch.h +0 -0
index d0dabeae0505..07886162bdf8 100644
@@ -183,7 +183,10 @@
  * otherwise we'll run out of registers. We don't care about CET

arch/x86/include/asm/nospec-branch.h line 192

Quoted 10 lines
arch/x86/include/asm/nospec-branch.h +4 -1
  * here, anyway.
  */
-# define CALL_NOSPEC ALTERNATIVE("call *%[thunk_target]\n",	\
+# define CALL_NOSPEC 						\
+	ALTERNATIVE(						\
+	ANNOTATE_RETPOLINE_SAFE					\
+	"call *%[thunk_target]\n",				\
 	"       jmp    904f;\n"					\
 	"       .align 16\n"					\
 	"901:	call   903f;\n"					\
Applied
#2 lore raw
Quoted 30 lines · Peter Zijlstra
Quoted 9 lines · Andy Whitcroft

In 9e0e3c5130e9 ("x86/speculation, objtool: Annotate indirect calls/jumps for objtool") we added annotations for CALL_NOSPEC/JMP_NOSPEC on x86 64bit. We did not annotate the 32bit path. Annotate it similarly.

---
 arch/x86/include/asm/nospec-branch.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Quoted 6 lines

While reviewing indirect calls in our builds I noted that the i386 retpoline CALL_NOSPEC is not annotated safe even though its amd64 equivalent is. I cannot see any reason this is not also inherantly safe. Peter was there a reason that you did not annotate this one too? Anyhow, on the assumption this was just missed, this patch annotates it.

Yeah, just an oversight aided by the fact that I (obviously) never build 32bit kernels.

Quoted 10 lines
arch/x86/include/asm/nospec-branch.h +1 -1
index d0dabeae0505..07886162bdf8 100644
@@ -183,7 +183,10 @@
  * otherwise we'll run out of registers. We don't care about CET
  * here, anyway.
  */
-# define CALL_NOSPEC ALTERNATIVE("call *%[thunk_target]\n",	\
+# define CALL_NOSPEC 						\
Quoted 8 lines

arch/x86/include/asm/nospec-branch.h line 192

Quoted 6 lines
arch/x86/include/asm/nospec-branch.h +3 -0
+	ALTERNATIVE(						\
+	ANNOTATE_RETPOLINE_SAFE					\
+	"call *%[thunk_target]\n",				\
 	"       jmp    904f;\n"					\
 	"       .align 16\n"					\
 	"901:	call   903f;\n"					\

Applied, thanks guys!

Ingo

#3 lore raw

[tip:x86/pti] x86/speculation, objtool: Annotate indirect calls/jumps for objtool on 32-bit kernels

In reply to Andy Whitcroft
x86/speculation, objtool: Annotate indirect calls/jumps for objtool on 32-bit kernels
Commit-ID:  a14bff131108faf50cc0cf864589fd71ee216c96
Gitweb:     https://git.kernel.org/tip/a14bff131108faf50cc0cf864589fd71ee216c96
Author:     Andy Whitcroft <[email protected]>
AuthorDate: Wed, 14 Mar 2018 11:24:27 +0000
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 14 Mar 2018 13:24:31 +0100

x86/speculation, objtool: Annotate indirect calls/jumps for objtool on 32-bit kernels

In the following commit:

9e0e3c5130e9 ("x86/speculation, objtool: Annotate indirect calls/jumps for objtool")

... we added annotations for CALL_NOSPEC/JMP_NOSPEC on 64-bit x86 kernels, but we did not annotate the 32-bit path.

Annotate it similarly.

Cc Andy Lutomirski <[email protected]>
Cc Arjan van de Ven <[email protected]>
Cc Borislav Petkov <[email protected]>
Cc Dan Williams <[email protected]>
Cc Dave Hansen <[email protected]>
Cc David Woodhouse <[email protected]>
Cc David Woodhouse <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Josh Poimboeuf <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Thomas Gleixner <[email protected]>
---
 arch/x86/include/asm/nospec-branch.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
arch/x86/include/asm/nospec-branch.h +4 -1
index b7063cfa19f9..b3996d60f981 100644
@@ -183,7 +183,10 @@
  * otherwise we'll run out of registers. We don't care about CET
  * here, anyway.
  */
-# define CALL_NOSPEC ALTERNATIVE("call *%[thunk_target]\n",	\
+# define CALL_NOSPEC						\
+	ALTERNATIVE(						\
+	ANNOTATE_RETPOLINE_SAFE					\
+	"call *%[thunk_target]\n",				\
 	"       jmp    904f;\n"					\
 	"       .align 16\n"					\
 	"901:	call   903f;\n"					\
#4 lore raw

Re: [tip:x86/pti] x86/speculation, objtool: Annotate indirect calls/jumps for objtool on 32-bit kernels

Quoted 9 lines · tip-bot for Andy Whitcroft
Commit-ID:  a14bff131108faf50cc0cf864589fd71ee216c96
Gitweb:     https://git.kernel.org/tip/a14bff131108faf50cc0cf864589fd71ee216c96
Author:     Andy Whitcroft <[email protected]>
AuthorDate: Wed, 14 Mar 2018 11:24:27 +0000
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 14 Mar 2018 13:24:31 +0100

x86/speculation, objtool: Annotate indirect calls/jumps for objtool on 32-bit kernels

Quoted 8 lines

In the following commit:

9e0e3c5130e9 ("x86/speculation, objtool: Annotate indirect calls/jumps for objtool")

... we added annotations for CALL_NOSPEC/JMP_NOSPEC on 64-bit x86 kernels, but we did not annotate the 32-bit path.

Annotate it similarly.

This patch has no effect because objtool only supports 64-bit kernels.

Signature · 1 line
Josh
#5 lore raw

Re: [tip:x86/pti] x86/speculation, objtool: Annotate indirect calls/jumps for objtool on 32-bit kernels

Quoted 12 lines · Josh Poimboeuf
Quoted 11 lines · tip-bot for Andy Whitcroft
Commit-ID:  a14bff131108faf50cc0cf864589fd71ee216c96
Gitweb:     https://git.kernel.org/tip/a14bff131108faf50cc0cf864589fd71ee216c96
Author:     Andy Whitcroft <[email protected]>
AuthorDate: Wed, 14 Mar 2018 11:24:27 +0000
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 14 Mar 2018 13:24:31 +0100

x86/speculation, objtool: Annotate indirect calls/jumps for objtool on 32-bit kernels

In the following commit:

Quoted 8 lines
Quoted 6 lines

9e0e3c5130e9 ("x86/speculation, objtool: Annotate indirect calls/jumps for objtool")

... we added annotations for CALL_NOSPEC/JMP_NOSPEC on 64-bit x86 kernels, but we did not annotate the 32-bit path.

Annotate it similarly.

This patch has no effect because objtool only supports 64-bit kernels.

Yeah, indeed - but it's still a good change for completeness, right?

Thanks,

Ingo

#6 lore raw

Re: [tip:x86/pti] x86/speculation, objtool: Annotate indirect calls/jumps for objtool on 32-bit kernels

Quoted 17 lines · Ingo Molnar
Quoted 14 lines · Josh Poimboeuf
Quoted 13 lines · tip-bot for Andy Whitcroft
Commit-ID:  a14bff131108faf50cc0cf864589fd71ee216c96
Gitweb:     https://git.kernel.org/tip/a14bff131108faf50cc0cf864589fd71ee216c96
Author:     Andy Whitcroft <[email protected]>
AuthorDate: Wed, 14 Mar 2018 11:24:27 +0000
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 14 Mar 2018 13:24:31 +0100

x86/speculation, objtool: Annotate indirect calls/jumps for objtool on 32-bit kernels

In the following commit:

9e0e3c5130e9 ("x86/speculation, objtool: Annotate indirect calls/jumps for objtool")

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

... we added annotations for CALL_NOSPEC/JMP_NOSPEC on 64-bit x86 kernels, but we did not annotate the 32-bit path.

Annotate it similarly.

This patch has no effect because objtool only supports 64-bit kernels.

Yeah, indeed - but it's still a good change for completeness, right?

Yeah, it's fine. Objtool won't use it, but I suppose it makes the code less surprising and more consistent for humans.

Signature · 1 line
Josh