From a4832a91b1f1525792c7c5c1edc0043b25a6e9fa Mon Sep 17 00:00:00 2001 From: Siddhesh Poyarekar Date: Tue, 18 Jul 2023 11:56:18 -0400 Subject: [PATCH] Build correctly with IBT and Shadow Stack (#1289) Add .gnu.property notes to indicate support for IBT and shadow stacks when libsodium is built with it. There's no stack switching code in here, so this should not need any other codegen changes. --- .../curve25519/sandy2x/sandy2x.S | 18 ++++++++++++++++++ .../salsa20/xmm6/salsa20_xmm6-asm.S | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/libsodium/crypto_scalarmult/curve25519/sandy2x/sandy2x.S b/src/libsodium/crypto_scalarmult/curve25519/sandy2x/sandy2x.S index 585804fb..eb4fe671 100644 --- a/src/libsodium/crypto_scalarmult/curve25519/sandy2x/sandy2x.S +++ b/src/libsodium/crypto_scalarmult/curve25519/sandy2x/sandy2x.S @@ -10,6 +10,24 @@ #include "ladder.S" #if defined(__linux__) && defined(__ELF__) +#if defined(__CET__) +.section .note.gnu.property,"a" +.p2align 3 +.long 1f - 0f +.long 4f - 1f +.long 5 +0: +.string "GNU" +1: +.p2align 3 +.long 0xc0000002 +.long 3f - 2f +2: +.long __CET__ +3: +.p2align 3 +4: +#endif .section .note.GNU-stack,"",%progbits #endif diff --git a/src/libsodium/crypto_stream/salsa20/xmm6/salsa20_xmm6-asm.S b/src/libsodium/crypto_stream/salsa20/xmm6/salsa20_xmm6-asm.S index 51ac26ab..2244ac2d 100644 --- a/src/libsodium/crypto_stream/salsa20/xmm6/salsa20_xmm6-asm.S +++ b/src/libsodium/crypto_stream/salsa20/xmm6/salsa20_xmm6-asm.S @@ -961,5 +961,23 @@ jmp ._bytesbetween1and255 #endif #if defined(__linux__) && defined(__ELF__) +#if defined(__CET__) +.section .note.gnu.property,"a" +.p2align 3 +.long 1f - 0f +.long 4f - 1f +.long 5 +0: +.string "GNU" +1: +.p2align 3 +.long 0xc0000002 +.long 3f - 2f +2: +.long __CET__ +3: +.p2align 3 +4: +#endif .section .note.GNU-stack,"",%progbits #endif