Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1237431

Re: [PATCH v13 13/23] x86/asm/crypto: Create stack frames in aesni-intel_asm.S

From Josh Poimboeuf <jpoimboe@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH v13 13/23] x86/asm/crypto: Create stack frames in aesni-intel_asm.S
Date 2015-10-01 15:40 +0200
Message-ID <qeMfw-5PR-17@gated-at.bofh.it> (permalink)
References <qbxZn-1c3-5@gated-at.bofh.it> <qby96-1o7-67@gated-at.bofh.it> <qeFxn-3Zt-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu, Oct 01, 2015 at 08:10:26AM +0200, minipli@ld-linux.so wrote:
> 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

Ah, right.  The 32-bit ABI passes arguments on the stack instead of via
registers.

For now, I'm inclined to just make FRAME_BEGIN and FRAME_END do nothing
on 32-bit.  We're only doing stack validation on x86_64 and I don't know
if anybody cares about frame pointers on 32-bit at this point.

-- 
Josh
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v13 00/23] Compile-time stack metadata validation Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 17:50 +0200
  [PATCH v13 20/23] x86/asm/efi: Create a stack frame in efi_call() Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 17:50 +0200
  [PATCH v13 22/23] x86/uaccess: Add stack frame output operand in get_user inline asm Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 17:50 +0200
  [PATCH v13 21/23] x86/asm/power: Create stack frames in hibernate_asm_64.S Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 17:50 +0200
  [PATCH v13 01/23] tools: Fix formatting of the "make -C tools" help message Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 17:50 +0200
  [PATCH v13 06/23] x86/stacktool: Add ignore macros Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 18:00 +0200
  [PATCH v13 18/23] x86/asm/acpi: Create a stack frame in do_suspend_lowlevel() Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 18:00 +0200
  [PATCH v13 05/23] x86/stacktool: Add file and directory ignores Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 18:00 +0200
  [PATCH v13 17/23] x86/asm/entry: Create stack frames in thunk functions Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 18:00 +0200
  [PATCH v13 10/23] x86/amd: Set ELF function type for vide() Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 18:00 +0200
  [PATCH v13 08/23] x86/paravirt: Add stack frame dependency to PVOP inline asm calls Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 18:00 +0200
  [PATCH v13 16/23] x86/asm/crypto: Create stack frames in clmul_ghash_mul/update() Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 18:00 +0200
  [PATCH v13 13/23] x86/asm/crypto: Create stack frames in aesni-intel_asm.S Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 18:00 +0200
    Re: [PATCH v13 13/23] x86/asm/crypto: Create stack frames in  aesni-intel_asm.S minipli@ld-linux.so - 2015-10-01 08:30 +0200
      Re: [PATCH v13 13/23] x86/asm/crypto: Create stack frames in  aesni-intel_asm.S Josh Poimboeuf <jpoimboe@redhat.com> - 2015-10-01 15:40 +0200
        Re: [PATCH v13 13/23] x86/asm/crypto: Create stack frames in  aesni-intel_asm.S Mathias Krause <minipli@ld-linux.so> - 2015-10-01 19:40 +0200
          Re: [PATCH v13 13/23] x86/asm/crypto: Create stack frames in  aesni-intel_asm.S Josh Poimboeuf <jpoimboe@redhat.com> - 2015-10-01 20:00 +0200
  [PATCH v13 09/23] x86/paravirt: Create a stack frame in PV_CALLEE_SAVE_REGS_THUNK Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 18:00 +0200
  [PATCH v13 14/23] x86/asm/crypto: Move .Lbswap_mask data to .rodata section Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 18:00 +0200
  [PATCH v13 15/23] x86/asm/crypto: Move jump_table to .rodata section Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 18:00 +0200
  [PATCH v13 12/23] x86/xen: Add xen_cpuid() and xen_setup_gdt() to stacktool whitelists Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 18:10 +0200
  [PATCH v13 02/23] x86/asm: Frame pointer macro cleanup Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 18:10 +0200
  [PATCH v13 07/23] x86/xen: Add stack frame dependency to hypercall inline asm calls Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 18:10 +0200
  [PATCH v13 11/23] x86/reboot: Add ljmp instructions to stacktool whitelist Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 18:10 +0200
  [PATCH v13 03/23] x86/asm: Add C versions of frame pointer macros Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-22 18:10 +0200
  Re: [PATCH v13 04/23] x86/stacktool: Compile-time stack metadata  validation Jiri Slaby <jslaby@suse.cz> - 2015-09-23 13:40 +0200
    Re: [PATCH v13 04/23] x86/stacktool: Compile-time stack metadata  validation Jiri Slaby <jslaby@suse.cz> - 2015-09-23 13:50 +0200
      Re: [PATCH v13.1 04/23] x86/stacktool: Compile-time stack metadata  validation Chris J Arges <chris.j.arges@canonical.com> - 2015-10-01 17:00 +0200
        Re: [PATCH v13.1 04/23] x86/stacktool: Compile-time stack metadata  validation Josh Poimboeuf <jpoimboe@redhat.com> - 2015-10-01 17:30 +0200
          Re: [PATCH v13.1 04/23] x86/stacktool: Compile-time stack metadata  validation Chris J Arges <chris.j.arges@canonical.com> - 2015-10-01 17:40 +0200
  Re: [PATCH v13 00/23] Compile-time stack metadata validation Josh Poimboeuf <jpoimboe@redhat.com> - 2015-09-28 15:50 +0200

csiph-web