All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Lutomirski <luto@amacapital.net>
To: Denys Vlasenko <vda.linux@googlemail.com>
Cc: Borislav Petkov <bp@alien8.de>, X86 ML <x86@kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Andrey Wagin <avagin@gmail.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Denys Vlasenko <dvlasenk@redhat.com>,
	Oleg Nesterov <oleg@redhat.com>, Ingo Molnar <mingo@redhat.com>,
	LKML <linux-kernel@vger.kernel.org>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Alexei Starovoitov <ast@plumgrid.com>,
	Kees Cook <keescook@chromium.org>, Will Drewry <wad@chromium.org>
Subject: Re: [PATCH 2/3 v3] x86: entry_64.S: always allocate complete "struct pt_regs"
Date: Thu, 26 Feb 2015 07:14:52 -0800	[thread overview]
Message-ID: <CALCETrWhOcfECEy+c2CcKnQ+gVh3yjB7ydMv-WkR9wcFTjpzog@mail.gmail.com> (raw)
In-Reply-To: <CAK1hOcN2jjfjNArnD8Uw68GCgHCXui59M3HETYE5YaR_Apxa4A@mail.gmail.com>

On Feb 26, 2015 1:55 AM, "Denys Vlasenko" <vda.linux@googlemail.com> wrote:
>
> On Wed, Feb 25, 2015 at 10:59 PM, Andy Lutomirski <luto@amacapital.net> wrote:
> > On Wed, Feb 25, 2015 at 1:28 PM, Denys Vlasenko <dvlasenk@redhat.com> wrote:
> >> On 02/25/2015 09:10 PM, Andy Lutomirski wrote:
> >> This part?
> >>
> >>         .macro FORK_LIKE func
> >>  ENTRY(stub_\func)
> >>         CFI_STARTPROC
> >> -       popq    %r11                    /* save return address */
> >> -       PARTIAL_FRAME 0
> >> -       SAVE_REST
> >> -       pushq   %r11                    /* put it back on stack */
> >> +       DEFAULT_FRAME 0, 8              /* offset 8: return address */
> >> +       SAVE_EXTRA_REGS 8
> >>         FIXUP_TOP_OF_STACK %r11, 8
> >> -       DEFAULT_FRAME 0 8               /* offset 8: return address */
> >>         call sys_\func
> >>         RESTORE_TOP_OF_STACK %r11, 8
> >> -       ret $REST_SKIP          /* pop extended registers */
> >> +       ret
> >>         CFI_ENDPROC
> >>  END(stub_\func)
> >>         .endm
> >>
> >>         FORK_LIKE  clone
> >>         FORK_LIKE  fork
> >>         FORK_LIKE  vfork
> >>
> >> But the old code (SAVE_REST thing) was also saving registers here.
> >> It had to jump through hoops (pop return address, SAVE_REST,
> >> push return address) to do that.
> >> After the patch, "SAVE_EXTRA_REGS 8" does the same, just without
> >> pop/push pair.
> >>
> >> I just don't see what's wrong with it. Can you elaborate?
> >
> > SAVE_REST pushed the regs onto the stack, whereas SAVE_EXTRA_REGS just
> > writes them in place.  It's possible for this to be called when the
> > regs have already been saved.
>
> If that would be the case - that is, if SAVE_REST was saving extra copy
> of registers on stack, then FIXUP_TOP_OF_STACK %r11, 8 would be working
> on wrong locations. The "8" there says "we have full pt_regs on stack,
> plus extra 8 bytes (the return address)". Your conjecture would mean
> that in fact there would be more bytes on stack, and FIXUP_TOP_OF_STACK
> would corrupt iret stack. Evidently, since old code was not crashing,
> this wasn't happening. SAVE_REST was really creating the "tail" of pt_regs

Ugh, you're right.

The FIXUP_TOP_OF_STACK indeed looks duplicated, bit t that's less
harmful and was already the case.

--Andy
.
>
> In addition to my previous tests, I ran my home machine with
> patched kernel. Unfortunately, it works for me :(
>
> Will try on yet another machine.
>
> --
> vda

  parent reply	other threads:[~2015-02-26 15:15 UTC|newest]

Thread overview: 130+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-12 21:54 [PATCH 1/3 v3] x86: entry_64.S: fix wrong symbolic constant usage: R11->ARGOFFSET Denys Vlasenko
2015-02-12 21:54 ` [PATCH 2/3 v3] x86: entry_64.S: always allocate complete "struct pt_regs" Denys Vlasenko
2015-02-18 20:22   ` Andy Lutomirski
2015-02-25 12:37   ` Andrey Wagin
2015-02-25 13:55     ` Denys Vlasenko
2015-02-25 14:48       ` Sabrina Dubroca
2015-02-25 16:52     ` Denys Vlasenko
2015-02-25 18:42     ` Denys Vlasenko
2015-02-25 19:59       ` Andrey Wagin
2015-02-25 20:10         ` Andy Lutomirski
2015-02-25 21:28           ` Denys Vlasenko
2015-02-25 21:59             ` Andy Lutomirski
2015-02-25 22:40               ` Sabrina Dubroca
2015-02-25 23:34                 ` Sabrina Dubroca
2015-02-26  1:12                   ` Denys Vlasenko
2015-02-26  5:18                     ` Andrew Morton
2015-02-26  6:25                       ` Stephen Rothwell
2015-02-26  9:55               ` Denys Vlasenko
2015-02-26 12:11                 ` Denys Vlasenko
2015-02-26 13:54                   ` Denys Vlasenko
2015-02-26 14:26                     ` Sabrina Dubroca
2015-02-26 15:14                 ` Andy Lutomirski [this message]
2015-02-12 21:54 ` [PATCH 3/3 v3] x86: entry_64.S: fix comments. No code changes Denys Vlasenko
2015-02-18 20:25   ` Andy Lutomirski
2015-02-18 20:00 ` [PATCH 1/3 v3] x86: entry_64.S: fix wrong symbolic constant usage: R11->ARGOFFSET Andy Lutomirski
  -- strict thread matches above, loose matches on Subject: below --
2015-02-26 22:40 [PATCH 00/16] x86/asm changes for 4.1 for review Andy Lutomirski
2015-02-26 22:40 ` [PATCH 01/16] x86: open-code register save/restore in trace_hardirqs thunks Andy Lutomirski
2015-03-04 22:52   ` [tip:x86/asm] x86/asm/64: Open-code register save/ restore in trace_hardirqs*() thunks tip-bot for Denys Vlasenko
2015-02-26 22:40 ` [PATCH 02/16] x86: introduce push/pop macros which generate CFI_REL_OFFSET and CFI_RESTORE Andy Lutomirski
2015-03-04 22:52   ` [tip:x86/asm] x86/asm: Introduce push/ pop " tip-bot for Denys Vlasenko
2015-02-26 22:40 ` [PATCH 03/16] x86: entry_64.S: fix wrong symbolic constant usage: R11->ARGOFFSET Andy Lutomirski
2015-03-04 22:53   ` [tip:x86/asm] x86/asm/entry/64: Fix incorrect " tip-bot for Denys Vlasenko
2015-02-26 22:40 ` [PATCH 04/16] x86: entry_64.S: always allocate complete "struct pt_regs" Andy Lutomirski
2015-03-04 22:53   ` [tip:x86/asm] x86/asm/entry/64: Always allocate a complete " struct pt_regs" on the kernel stack tip-bot for Denys Vlasenko
2015-03-21 22:51     ` Brian Gerst
2015-03-22 14:15       ` Denys Vlasenko
2015-02-26 22:40 ` [PATCH 05/16] x86: entry_64.S: fix comments. No code changes Andy Lutomirski
2015-03-04 22:53   ` [tip:x86/asm] x86/asm/entry/64: Fix comments tip-bot for Denys Vlasenko
2015-02-26 22:40 ` [PATCH 06/16] x86: code shrink in paranoid_exit Andy Lutomirski
2015-03-04 22:53   ` [tip:x86/asm] x86/asm/entry/64: Shrink code in 'paranoid_exit' tip-bot for Denys Vlasenko
2015-02-26 22:40 ` [PATCH 07/16] x86: mass removal of ARGOFFSET. No code changes Andy Lutomirski
2015-03-04 22:54   ` [tip:x86/asm] x86/asm/entry: Do mass removal of 'ARGOFFSET' tip-bot for Denys Vlasenko
2015-02-26 22:40 ` [PATCH 08/16] x86, entry: Remove int_check_syscall_exit_work Andy Lutomirski
2015-03-04 22:54   ` [tip:x86/asm] x86/asm/entry/64: Remove ' int_check_syscall_exit_work' tip-bot for Andy Lutomirski
2015-02-26 22:40 ` [PATCH 09/16] x86: add comments about various syscall instructions, no code changes Andy Lutomirski
2015-03-04 22:54   ` [tip:x86/asm] x86/asm/entry: Add comments about various syscall instructions tip-bot for Denys Vlasenko
2015-02-26 22:40 ` [PATCH 10/16] x86: entry_64.S: move save_paranoid and ret_from_fork closer to their users Andy Lutomirski
2015-03-04 22:55   ` [tip:x86/asm] x86/asm/entry/64: Move 'save_paranoid' and ' ret_from_fork' " tip-bot for Denys Vlasenko
2015-02-26 22:40 ` [PATCH 11/16] x86: entry_64.S: rename save_paranoid to paranoid_entry, no code changes Andy Lutomirski
2015-03-04 22:55   ` [tip:x86/asm] x86/asm/entry/64: Clean up and document various entry code details tip-bot for Denys Vlasenko
2015-02-26 22:40 ` [PATCH 12/16] x86: ia32entry.S: fold IA32_ARG_FIXUP macro into its callers Andy Lutomirski
2015-03-04 22:55   ` [tip:x86/asm] x86/asm/entry/64/compat: Fold the " tip-bot for Denys Vlasenko
2015-02-26 22:40 ` [PATCH 13/16] x86: entry_64.S: use more understandable constants Andy Lutomirski
2015-03-04 22:56   ` [tip:x86/asm] x86/asm/entry/64: Use more readable constants tip-bot for Denys Vlasenko
2015-02-26 22:40 ` [PATCH 14/16] x86: ia32entry.S: use more understandable constant Andy Lutomirski
2015-03-04 22:56   ` [tip:x86/asm] x86/asm/entry/64/compat: Use more readable constant tip-bot for Denys Vlasenko
2015-02-26 22:40 ` [PATCH 15/16] x86: entry.S: simplify optimistic SYSRET Andy Lutomirski
2015-03-04 21:40   ` Ingo Molnar
2015-03-04 22:56   ` [tip:x86/asm] x86/asm/entry/64: Simplify " tip-bot for Denys Vlasenko
2015-02-26 22:40 ` [PATCH 16/16] x86_64, entry: Remove a bogus ret_from_fork optimization Andy Lutomirski
2015-03-04 22:57   ` [tip:x86/asm] x86/asm/entry/64: Remove a bogus 'ret_from_fork' optimization tip-bot for Andy Lutomirski
2015-03-05 11:49   ` [tip:x86/urgent] " tip-bot for Andy Lutomirski
2015-03-04 21:50 ` [PATCH 00/16] x86/asm changes for 4.1 for review Ingo Molnar
2015-03-04 21:55   ` Andy Lutomirski
2015-01-14 21:48 [PATCH 01/11] x86: entry_64.S: always allocate complete "struct pt_regs" Denys Vlasenko
2015-01-14 21:48 ` [PATCH 02/11] x86: code shrink in paranoid_exit Denys Vlasenko
2015-02-11 20:36   ` Andy Lutomirski
2015-02-11 21:01     ` H. Peter Anvin
2015-02-11 21:13     ` Denys Vlasenko
2015-02-11 22:09       ` Andy Lutomirski
2015-02-18 23:26   ` Andy Lutomirski
2015-01-14 21:48 ` [PATCH 03/11] x86: mass removal of ARGOFFSET Denys Vlasenko
2015-02-21  0:31   ` Andy Lutomirski
2015-02-23 14:31     ` Denys Vlasenko
2015-02-23 16:06       ` Andy Lutomirski
2015-01-14 21:48 ` [PATCH 04/11] x86: rename some macros and labels, no code changes Denys Vlasenko
2015-01-14 21:48 ` [PATCH 05/11] x86: add comments about various syscall instructions, " Denys Vlasenko
2015-01-14 21:48 ` [PATCH 06/11] x86: entry_64.S: move save_paranoid and ret_from_fork closer to their users Denys Vlasenko
2015-01-14 21:48 ` [PATCH 07/11] x86: entry_64.S: rename save_paranoid to paranoid_entry, no code changes Denys Vlasenko
2015-02-11 20:39   ` Andy Lutomirski
2015-01-14 21:48 ` [PATCH 08/11] x86: entry_64.S: fold test_in_nmi macro into its only user Denys Vlasenko
2015-02-11 20:40   ` Andy Lutomirski
2015-02-12  2:17     ` Steven Rostedt
2015-01-14 21:48 ` [PATCH 09/11] x86: get rid of KERNEL_STACK_OFFSET Denys Vlasenko
2015-01-14 21:48 ` [PATCH 10/11] x86: ia32entry.S: fold IA32_ARG_FIXUP macro into its callers Denys Vlasenko
2015-01-14 21:48 ` [PATCH 11/11] x86: entry_64.S: use more understandable constants Denys Vlasenko
2015-01-14 22:17 ` [PATCH 01/11] x86: entry_64.S: always allocate complete "struct pt_regs" Denys Vlasenko
2015-01-14 22:29   ` Andy Lutomirski
2015-01-14 22:41     ` Borislav Petkov
2015-01-14 22:50       ` Denys Vlasenko
2015-02-11 20:30 ` Andy Lutomirski
2015-02-11 21:55   ` Denys Vlasenko
2015-02-11 22:03     ` Andy Lutomirski
2015-01-11 23:07 [PATCH] x86: introduce push/pop macros which generate CFI_REL_OFFSET and CFI_RESTORE Denys Vlasenko
2015-01-12  0:38 ` Andy Lutomirski
2015-01-12  6:23   ` Denys Vlasenko
2015-01-12 19:23 ` Borislav Petkov
2015-01-12 19:25   ` Andy Lutomirski
2015-01-12 19:37     ` Borislav Petkov
2015-01-12 19:46       ` Andy Lutomirski
2015-01-12 20:11         ` Borislav Petkov
2015-01-12 20:14           ` Andy Lutomirski
2015-01-12 20:22             ` H. Peter Anvin
2015-01-12 20:26               ` Andy Lutomirski
2015-01-12 21:03                 ` Borislav Petkov
2015-01-13 12:07                 ` Denys Vlasenko
2015-01-12 20:32             ` Borislav Petkov
2015-02-11 20:24 ` Andy Lutomirski
2015-01-10 22:00 [PATCH 0/4 v2] x86: entry.S cleanup Denys Vlasenko
2015-01-10 22:00 ` [PATCH 1/4] x86: entry_64.S: delete unused code Denys Vlasenko
2015-01-10 22:12   ` Andy Lutomirski
2015-01-10 22:00 ` [PATCH 2/4] x86: ia32entry.S: fix wrong symbolic constant usage: R11->ARGOFFSET Denys Vlasenko
2015-01-10 22:13   ` Andy Lutomirski
2015-01-10 22:27     ` Linus Torvalds
2015-01-10 22:35       ` Borislav Petkov
2015-01-10 22:41         ` Linus Torvalds
2015-01-10 22:45           ` Borislav Petkov
2015-01-10 22:37       ` Linus Torvalds
2015-01-10 23:27       ` Andy Lutomirski
2015-01-13 22:11   ` Andy Lutomirski
2015-01-10 22:00 ` [PATCH 3/4] x86: open-code register save/restore in trace_hardirqs thunks Denys Vlasenko
2015-01-10 22:07   ` Linus Torvalds
2015-01-10 22:35     ` Denys Vlasenko
2015-01-10 22:41       ` Borislav Petkov
2015-01-11  3:33         ` Denys Vlasenko
2015-01-11 10:54           ` Borislav Petkov
2015-01-11 23:06             ` Denys Vlasenko
2015-02-11  2:38   ` Andy Lutomirski
2015-01-10 22:00 ` [PATCH 4/4] x86: entry_64.S: fold SAVE_ARGS_IRQ macro into its sole user Denys Vlasenko
2015-01-13 22:26   ` Andy Lutomirski

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=CALCETrWhOcfECEy+c2CcKnQ+gVh3yjB7ydMv-WkR9wcFTjpzog@mail.gmail.com \
    --to=luto@amacapital.net \
    --cc=ast@plumgrid.com \
    --cc=avagin@gmail.com \
    --cc=bp@alien8.de \
    --cc=dvlasenk@redhat.com \
    --cc=fweisbec@gmail.com \
    --cc=hpa@zytor.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=oleg@redhat.com \
    --cc=torvalds@linux-foundation.org \
    --cc=vda.linux@googlemail.com \
    --cc=wad@chromium.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.