From: Ard Biesheuvel <ardb+git@google.com>
To: linux-kernel@vger.kernel.org
Cc: llvm@lists.linux.dev, keescook@chromium.org,
linux-hardening@vger.kernel.org, nathan@kernel.org,
Ard Biesheuvel <ardb@kernel.org>,
Josh Poimboeuf <jpoimboe@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Jan Beulich <jbeulich@suse.com>,
"Jose E. Marchesi" <jemarch@gnu.org>,
Kees Cook <kees@kernel.org>
Subject: [PATCH v2 5/5] crypto: x86/crc32c - Tweak jump table to validate objtool logic
Date: Thu, 10 Oct 2024 14:28:07 +0200 [thread overview]
Message-ID: <20241010122801.1321976-12-ardb+git@google.com> (raw)
In-Reply-To: <20241010122801.1321976-7-ardb+git@google.com>
From: Ard Biesheuvel <ardb@kernel.org>
Tweak the jump table so
- the address is taken far way from its use
- its offset from the start of .rodata is != 0x0
- its type is STT_OBJECT and its size is set to the size of the actual
table
- the indirect jump is annotated with a R_X86_64_NONE relocation
pointing to the jump table
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
arch/x86/crypto/crc32c-pcl-intel-asm_64.S | 39 +++++++++++---------
1 file changed, 22 insertions(+), 17 deletions(-)
diff --git a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
index 45b005935194..ba1cca66875b 100644
--- a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
+++ b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
@@ -93,10 +93,13 @@ SYM_FUNC_START(crc_pcl)
#define crc1 %r9
#define crc2 %r10
+ pushq %rbp
pushq %rbx
pushq %rdi
pushq %rsi
+ leaq jump_table(%rip), %rbp
+
## Move crc_init for Linux to a different
mov crc_init_arg, crc_init
@@ -168,9 +171,9 @@ SYM_FUNC_START(crc_pcl)
xor crc2, crc2
## branch into array
- leaq jump_table(%rip), %bufp
- movslq (%bufp,%rax,4), len
- addq len, %bufp
+ movslq (%rbp,%rax,4), %bufp
+ addq %rbp, %bufp
+ .reloc ., R_X86_64_NONE, jump_table
JMP_NOSPEC bufp
################################################################
@@ -310,24 +313,11 @@ LABEL less_than_ %j # less_than_j: Length should be in
popq %rsi
popq %rdi
popq %rbx
+ popq %rbp
RET
SYM_FUNC_END(crc_pcl)
.section .rodata, "a", @progbits
- ################################################################
- ## jump table Table is 129 entries x 2 bytes each
- ################################################################
-.align 4
-jump_table:
- i=0
-.rept 129
-.altmacro
-JMPTBL_ENTRY %i
-.noaltmacro
- i=i+1
-.endr
-
-
################################################################
## PCLMULQDQ tables
## Table is 128 entries x 2 words (8 bytes) each
@@ -462,3 +452,18 @@ K_table:
.long 0x45cddf4e, 0xe0ac139e
.long 0xacfa3103, 0x6c23e841
.long 0xa51b6135, 0x170076fa
+
+ ################################################################
+ ## jump table Table is 129 entries x 2 bytes each
+ ################################################################
+.align 4
+jump_table:
+ i=0
+.rept 129
+.altmacro
+JMPTBL_ENTRY %i
+.noaltmacro
+ i=i+1
+.endr
+.size jump_table, . - jump_table
+.type jump_table, @object
--
2.47.0.rc0.187.ge670bccf7e-goog
next prev parent reply other threads:[~2024-10-10 12:28 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-10 12:28 [PATCH v2 0/5] Improve objtool jump table handling Ard Biesheuvel
2024-10-10 12:28 ` [PATCH v2 1/5] objtool: Deal with relative jump tables correctly Ard Biesheuvel
2024-10-10 13:26 ` Peter Zijlstra
2024-10-10 13:59 ` Ard Biesheuvel
2024-10-10 14:07 ` Peter Zijlstra
2024-10-10 15:32 ` Josh Poimboeuf
2024-10-10 12:28 ` [PATCH v2 2/5] objtool: Allow arch code to discover jump table size Ard Biesheuvel
2024-10-10 19:52 ` Josh Poimboeuf
2024-10-11 16:50 ` Ard Biesheuvel
2024-10-10 12:28 ` [PATCH v2 3/5] objtool: Add support for annotated jump tables Ard Biesheuvel
2024-10-10 20:12 ` Josh Poimboeuf
2024-10-10 20:15 ` Josh Poimboeuf
2024-10-11 6:29 ` Ard Biesheuvel
2024-10-11 15:56 ` Josh Poimboeuf
2024-10-10 12:28 ` [PATCH v2 4/5] crypto: x86/crc32c - Use idiomatic relative jump table Ard Biesheuvel
2024-10-10 12:28 ` Ard Biesheuvel [this message]
2024-10-10 20:34 ` [PATCH v2 5/5] crypto: x86/crc32c - Tweak jump table to validate objtool logic Josh Poimboeuf
2024-10-11 6:32 ` Ard Biesheuvel
2024-10-11 16:04 ` Josh Poimboeuf
2024-10-11 16:22 ` Ard Biesheuvel
2024-10-10 17:50 ` [PATCH v2 0/5] Improve objtool jump table handling Ard Biesheuvel
2024-10-10 20:36 ` Josh Poimboeuf
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=20241010122801.1321976-12-ardb+git@google.com \
--to=ardb+git@google.com \
--cc=ardb@kernel.org \
--cc=jbeulich@suse.com \
--cc=jemarch@gnu.org \
--cc=jpoimboe@kernel.org \
--cc=kees@kernel.org \
--cc=keescook@chromium.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=nathan@kernel.org \
--cc=peterz@infradead.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