From: minipli@ld-linux.so
To: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, linux-kernel@vger.kernel.org,
live-patching@vger.kernel.org, Michal Marek <mmarek@suse.cz>,
Peter Zijlstra <peterz@infradead.org>,
Andy Lutomirski <luto@kernel.org>, Borislav Petkov <bp@alien8.de>,
Linus Torvalds <torvalds@linux-foundation.org>,
Andi Kleen <andi@firstfloor.org>, Pedro Alves <palves@redhat.com>,
Namhyung Kim <namhyung@gmail.com>,
Bernd Petrovitsch <bernd@petrovitsch.priv.at>,
Chris J Arges <chris.j.arges@canonical.com>,
Andrew Morton <akpm@linux-foundation.org>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>
Subject: Re: [PATCH v13 13/23] x86/asm/crypto: Create stack frames in aesni-intel_asm.S
Date: Thu, 1 Oct 2015 08:10:26 +0200 [thread overview]
Message-ID: <20151001061026.GA20908@ld-linux.so> (raw)
In-Reply-To: <f6c891b667979be5440a9c354b7f56a61d1a4f84.1442935712.git.jpoimboe@redhat.com>
On Tue, Sep 22, 2015 at 10:47:04AM -0500, Josh Poimboeuf wrote:
> aesni-intel_asm.S has several callable non-leaf functions which don't
> honor CONFIG_FRAME_POINTER, which can result in bad stack traces.
>
> Create stack frames for them when CONFIG_FRAME_POINTER is enabled.
>
> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
> Cc: Herbert Xu <herbert@gondor.apana.org.au>
> Cc: David S. Miller <davem@davemloft.net>
> ---
> arch/x86/crypto/aesni-intel_asm.S | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
> diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
> index 6bd2c6c..289ef12 100644
> --- a/arch/x86/crypto/aesni-intel_asm.S
> +++ b/arch/x86/crypto/aesni-intel_asm.S
> @@ -31,6 +31,7 @@
>
> #include <linux/linkage.h>
> #include <asm/inst.h>
> +#include <asm/frame.h>
>
> /*
> * The following macros are used to move an (un)aligned 16 byte value to/from
> @@ -1800,6 +1801,7 @@ ENDPROC(_key_expansion_256b)
> * unsigned int key_len)
> */
> ENTRY(aesni_set_key)
> + FRAME_BEGIN
> #ifndef __x86_64__
> pushl KEYP
> movl 8(%esp), KEYP # ctx
This will break 32 bit builds using the aesni-intel.ko module. You need
to adjust the esp-based offsets for the non-x86_64 case, as FRAME_BEGIN
may do another push.
How about adding a FRAME_OFFSET() macro to <asm/frame.h> to wrap the
offsets?:
#ifdef CONFIG_FRAME_POINTER
# define FRAME_OFFSET(x) ((x) + (BITS_PER_LONG / 8))
#else
# define FRAME_OFFSET(x) (x)
#endif
And using them like this:
movl FRAME_OFFSET(8)(%esp), KEYP # ctx
> @@ -1905,6 +1907,7 @@ ENTRY(aesni_set_key)
> #ifndef __x86_64__
> popl KEYP
> #endif
> + FRAME_END
> ret
> ENDPROC(aesni_set_key)
>
> @@ -1912,6 +1915,7 @@ ENDPROC(aesni_set_key)
> * void aesni_enc(struct crypto_aes_ctx *ctx, u8 *dst, const u8 *src)
> */
> ENTRY(aesni_enc)
> + FRAME_BEGIN
> #ifndef __x86_64__
> pushl KEYP
> pushl KLEN
> @@ -1927,6 +1931,7 @@ ENTRY(aesni_enc)
> popl KLEN
> popl KEYP
> #endif
> + FRAME_END
> ret
> ENDPROC(aesni_enc)
Here, too..
>
> @@ -2101,6 +2106,7 @@ ENDPROC(_aesni_enc4)
> * void aesni_dec (struct crypto_aes_ctx *ctx, u8 *dst, const u8 *src)
> */
> ENTRY(aesni_dec)
> + FRAME_BEGIN
> #ifndef __x86_64__
> pushl KEYP
> pushl KLEN
> @@ -2117,6 +2123,7 @@ ENTRY(aesni_dec)
> popl KLEN
> popl KEYP
> #endif
> + FRAME_END
> ret
> ENDPROC(aesni_dec)
Dito.
>
> @@ -2292,6 +2299,7 @@ ENDPROC(_aesni_dec4)
> * size_t len)
> */
> ENTRY(aesni_ecb_enc)
> + FRAME_BEGIN
> #ifndef __x86_64__
> pushl LEN
> pushl KEYP
> @@ -2342,6 +2350,7 @@ ENTRY(aesni_ecb_enc)
> popl KEYP
> popl LEN
> #endif
> + FRAME_END
> ret
> ENDPROC(aesni_ecb_enc)
Dito.
>
> @@ -2350,6 +2359,7 @@ ENDPROC(aesni_ecb_enc)
> * size_t len);
> */
> ENTRY(aesni_ecb_dec)
> + FRAME_BEGIN
> #ifndef __x86_64__
> pushl LEN
> pushl KEYP
> @@ -2401,6 +2411,7 @@ ENTRY(aesni_ecb_dec)
> popl KEYP
> popl LEN
> #endif
> + FRAME_END
> ret
> ENDPROC(aesni_ecb_dec)
Dito.
>
> @@ -2409,6 +2420,7 @@ ENDPROC(aesni_ecb_dec)
> * size_t len, u8 *iv)
> */
> ENTRY(aesni_cbc_enc)
> + FRAME_BEGIN
> #ifndef __x86_64__
> pushl IVP
> pushl LEN
> @@ -2443,6 +2455,7 @@ ENTRY(aesni_cbc_enc)
> popl LEN
> popl IVP
> #endif
> + FRAME_END
> ret
> ENDPROC(aesni_cbc_enc)
Dito.
>
> @@ -2451,6 +2464,7 @@ ENDPROC(aesni_cbc_enc)
> * size_t len, u8 *iv)
> */
> ENTRY(aesni_cbc_dec)
> + FRAME_BEGIN
> #ifndef __x86_64__
> pushl IVP
> pushl LEN
> @@ -2534,6 +2548,7 @@ ENTRY(aesni_cbc_dec)
> popl LEN
> popl IVP
> #endif
> + FRAME_END
> ret
> ENDPROC(aesni_cbc_dec)
Dito.
>
> @@ -2598,6 +2613,7 @@ ENDPROC(_aesni_inc)
> * size_t len, u8 *iv)
> */
> ENTRY(aesni_ctr_enc)
> + FRAME_BEGIN
> cmp $16, LEN
> jb .Lctr_enc_just_ret
> mov 480(KEYP), KLEN
> @@ -2651,6 +2667,7 @@ ENTRY(aesni_ctr_enc)
> .Lctr_enc_ret:
> movups IV, (IVP)
> .Lctr_enc_just_ret:
> + FRAME_END
> ret
> ENDPROC(aesni_ctr_enc)
>
> @@ -2677,6 +2694,7 @@ ENDPROC(aesni_ctr_enc)
> * bool enc, u8 *iv)
> */
> ENTRY(aesni_xts_crypt8)
> + FRAME_BEGIN
> cmpb $0, %cl
> movl $0, %ecx
> movl $240, %r10d
> @@ -2777,6 +2795,7 @@ ENTRY(aesni_xts_crypt8)
> pxor INC, STATE4
> movdqu STATE4, 0x70(OUTP)
>
> + FRAME_END
> ret
> ENDPROC(aesni_xts_crypt8)
>
Regards,
Mathias
next prev parent reply other threads:[~2015-10-01 6:20 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-22 15:46 [PATCH v13 00/23] Compile-time stack metadata validation Josh Poimboeuf
2015-09-22 15:46 ` [PATCH v13 01/23] tools: Fix formatting of the "make -C tools" help message Josh Poimboeuf
2015-09-22 15:46 ` [PATCH v13 02/23] x86/asm: Frame pointer macro cleanup Josh Poimboeuf
2015-09-22 15:46 ` [PATCH v13 03/23] x86/asm: Add C versions of frame pointer macros Josh Poimboeuf
2015-09-22 15:46 ` [PATCH v13 04/23] x86/stacktool: Compile-time stack metadata validation Josh Poimboeuf
2015-09-23 11:38 ` Jiri Slaby
2015-09-23 11:40 ` Jiri Slaby
2015-09-23 12:42 ` [PATCH v13.1 " Josh Poimboeuf
2015-10-01 14:50 ` Chris J Arges
2015-10-01 15:25 ` Josh Poimboeuf
2015-10-01 15:38 ` Chris J Arges
2015-09-22 15:46 ` [PATCH v13 05/23] x86/stacktool: Add file and directory ignores Josh Poimboeuf
2015-09-22 15:46 ` [PATCH v13 06/23] x86/stacktool: Add ignore macros Josh Poimboeuf
2015-09-22 15:46 ` [PATCH v13 07/23] x86/xen: Add stack frame dependency to hypercall inline asm calls Josh Poimboeuf
2015-09-22 15:46 ` [PATCH v13 08/23] x86/paravirt: Add stack frame dependency to PVOP " Josh Poimboeuf
2015-09-22 15:47 ` [PATCH v13 09/23] x86/paravirt: Create a stack frame in PV_CALLEE_SAVE_REGS_THUNK Josh Poimboeuf
2015-09-22 15:47 ` [PATCH v13 10/23] x86/amd: Set ELF function type for vide() Josh Poimboeuf
2015-09-22 15:47 ` [PATCH v13 11/23] x86/reboot: Add ljmp instructions to stacktool whitelist Josh Poimboeuf
2015-09-22 15:47 ` [PATCH v13 12/23] x86/xen: Add xen_cpuid() and xen_setup_gdt() to stacktool whitelists Josh Poimboeuf
2015-09-22 15:47 ` [PATCH v13 13/23] x86/asm/crypto: Create stack frames in aesni-intel_asm.S Josh Poimboeuf
2015-10-01 6:10 ` minipli [this message]
2015-10-01 13:29 ` Josh Poimboeuf
2015-10-01 17:36 ` Mathias Krause
2015-10-01 17:51 ` Josh Poimboeuf
2015-09-22 15:47 ` [PATCH v13 14/23] x86/asm/crypto: Move .Lbswap_mask data to .rodata section Josh Poimboeuf
2015-09-22 15:47 ` [PATCH v13 15/23] x86/asm/crypto: Move jump_table " Josh Poimboeuf
2015-09-22 15:47 ` [PATCH v13 16/23] x86/asm/crypto: Create stack frames in clmul_ghash_mul/update() Josh Poimboeuf
2015-09-22 15:47 ` [PATCH v13 17/23] x86/asm/entry: Create stack frames in thunk functions Josh Poimboeuf
2015-09-22 15:47 ` [PATCH v13 18/23] x86/asm/acpi: Create a stack frame in do_suspend_lowlevel() Josh Poimboeuf
2015-09-22 15:47 ` [PATCH v13 19/23] x86/asm: Create stack frames in rwsem functions Josh Poimboeuf
2015-09-22 15:47 ` [PATCH v13 20/23] x86/asm/efi: Create a stack frame in efi_call() Josh Poimboeuf
2015-09-22 15:47 ` [PATCH v13 21/23] x86/asm/power: Create stack frames in hibernate_asm_64.S Josh Poimboeuf
2015-09-22 15:47 ` [PATCH v13 22/23] x86/uaccess: Add stack frame output operand in get_user inline asm Josh Poimboeuf
2015-09-22 15:47 ` [PATCH v13 23/23] x86/stacktool: Ignore head_$(BITS) files Josh Poimboeuf
2015-09-28 13:45 ` [PATCH v13 00/23] Compile-time stack metadata validation Josh Poimboeuf
2015-10-12 7:41 ` Ingo Molnar
2015-10-12 14:23 ` Josh Poimboeuf
2015-11-11 18:14 ` 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=20151001061026.GA20908@ld-linux.so \
--to=minipli@ld-linux.so \
--cc=akpm@linux-foundation.org \
--cc=andi@firstfloor.org \
--cc=bernd@petrovitsch.priv.at \
--cc=bp@alien8.de \
--cc=chris.j.arges@canonical.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=hpa@zytor.com \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=mmarek@suse.cz \
--cc=namhyung@gmail.com \
--cc=palves@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.