From: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
To: Ivan Kokshaysky <ink@unseen.parts>,
Richard Henderson <richard.henderson@linaro.org>,
Matt Turner <mattst88@gmail.com>,
Oleg Nesterov <oleg@redhat.com>,
Al Viro <viro@zeniv.linux.org.uk>, Arnd Bergmann <arnd@arndb.de>,
"Paul E. McKenney" <paulmck@kernel.org>
Cc: "Maciej W. Rozycki" <macro@orcam.me.uk>,
Magnus Lindholm <linmag7@gmail.com>,
linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH v2 0/4] alpha: stack fixes
Date: Sat, 01 Feb 2025 10:46:43 +0100 [thread overview]
Message-ID: <6cb712c1c338d3ce5313e05a054ea9de21025ff0.camel@physik.fu-berlin.de> (raw)
In-Reply-To: <20250131104129.11052-1-ink@unseen.parts>
Hi Ivan,
On Fri, 2025-01-31 at 11:41 +0100, Ivan Kokshaysky wrote:
> This series fixes oopses on Alpha/SMP observed since kernel v6.9. [1]
> Thanks to Magnus Lindholm for identifying that remarkably longstanding
> bug.
>
> The problem is that GCC expects 16-byte alignment of the incoming stack
> since early 2004, as Maciej found out [2]:
> Having actually dug speculatively I can see that the psABI was changed in
> GCC 3.5 with commit e5e10fb4a350 ("re PR target/14539 (128-bit long double
> improperly aligned)") back in Mar 2004, when the stack pointer alignment
> was increased from 8 bytes to 16 bytes, and arch/alpha/kernel/entry.S has
> various suspicious stack pointer adjustments, starting with SP_OFF which
> is not a whole multiple of 16.
>
> Also, as Magnus noted, "ALPHA Calling Standard" [3] required the same:
> D.3.1 Stack Alignment
> This standard requires that stacks be octaword aligned at the time a
> new procedure is invoked.
>
> However:
> - the "normal" kernel stack is always misaligned by 8 bytes, thanks to
> the odd number of 64-bit words in 'struct pt_regs', which is the very
> first thing pushed onto the kernel thread stack;
> - syscall, fault, interrupt etc. handlers may, or may not, receive aligned
> stack depending on numerous factors.
>
> Somehow we got away with it until recently, when we ended up with
> a stack corruption in kernel/smp.c:smp_call_function_single() due to
> its use of 32-byte aligned local data and the compiler doing clever
> things allocating it on the stack.
>
> Patches 1-2 are preparatory; 3 - the main fix; 4 - fixes remaining
> special cases.
>
> Ivan.
>
> [1] https://lore.kernel.org/rcu/CA+=Fv5R9NG+1SHU9QV9hjmavycHKpnNyerQ=Ei90G98ukRcRJA@mail.gmail.com/#r
> [2] https://lore.kernel.org/rcu/alpine.DEB.2.21.2501130248010.18889@angie.orcam.me.uk/
> [3] https://bitsavers.org/pdf/dec/alpha/Alpha_Calling_Standard_Rev_2.0_19900427.pdf
> ---
> Changes in v2:
> - patch #1: provide empty 'struct pt_regs' to fix compile failure in libbpf,
> reported by John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>;
> update comment and commit message accordingly;
> - cc'ed <stable@vger.kernel.org> as older kernels ought to be fixed as well.
> ---
> Ivan Kokshaysky (4):
> alpha/uapi: do not expose kernel-only stack frame structures
> alpha: replace hardcoded stack offsets with autogenerated ones
> alpha: make stack 16-byte aligned (most cases)
> alpha: align stack for page fault and user unaligned trap handlers
>
> arch/alpha/include/asm/ptrace.h | 64 ++++++++++++++++++++++++++-
> arch/alpha/include/uapi/asm/ptrace.h | 65 ++--------------------------
> arch/alpha/kernel/asm-offsets.c | 4 ++
> arch/alpha/kernel/entry.S | 24 +++++-----
> arch/alpha/kernel/traps.c | 2 +-
> arch/alpha/mm/fault.c | 4 +-
> 6 files changed, 83 insertions(+), 80 deletions(-)
Thanks, I'm testing the v2 series of the patches now.
Adrian
--
.''`. John Paul Adrian Glaubitz
: :' : Debian Developer
`. `' Physicist
`- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
next prev parent reply other threads:[~2025-02-01 9:46 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-31 10:41 Ivan Kokshaysky
2025-01-31 10:41 ` [PATCH v2 1/4] alpha/uapi: do not expose kernel-only stack frame structures Ivan Kokshaysky
2025-02-02 17:39 ` Maciej W. Rozycki
2025-02-03 17:13 ` Ivan Kokshaysky
2025-02-04 13:42 ` Maciej W. Rozycki
2025-02-03 11:01 ` John Paul Adrian Glaubitz
2025-01-31 10:41 ` [PATCH v2 2/4] alpha: replace hardcoded stack offsets with autogenerated ones Ivan Kokshaysky
2025-02-02 17:40 ` Maciej W. Rozycki
2025-01-31 10:41 ` [PATCH v2 3/4] alpha: make stack 16-byte aligned (most cases) Ivan Kokshaysky
2025-02-02 17:41 ` Maciej W. Rozycki
2025-01-31 10:41 ` [PATCH v2 4/4] alpha: align stack for page fault and user unaligned trap handlers Ivan Kokshaysky
2025-02-02 17:41 ` Maciej W. Rozycki
2025-02-01 9:46 ` John Paul Adrian Glaubitz [this message]
2025-02-01 23:12 ` [PATCH v2 0/4] alpha: stack fixes Michael Cree
2025-02-02 9:43 ` Magnus Lindholm
2025-02-02 18:13 ` Michael Cree
2025-02-03 11:05 ` John Paul Adrian Glaubitz
2025-02-02 17:37 ` Maciej W. Rozycki
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=6cb712c1c338d3ce5313e05a054ea9de21025ff0.camel@physik.fu-berlin.de \
--to=glaubitz@physik.fu-berlin.de \
--cc=arnd@arndb.de \
--cc=ink@unseen.parts \
--cc=linmag7@gmail.com \
--cc=linux-alpha@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=macro@orcam.me.uk \
--cc=mattst88@gmail.com \
--cc=oleg@redhat.com \
--cc=paulmck@kernel.org \
--cc=richard.henderson@linaro.org \
--cc=stable@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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
all inboxes | Powered by JetHome®