Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kexec_stack is misaligned #472

Open
mpe opened this issue Nov 15, 2023 · 0 comments
Open

kexec_stack is misaligned #472

mpe opened this issue Nov 15, 2023 · 0 comments
Labels
bug It's a bug easy Should be easy

Comments

@mpe
Copy link
Member

mpe commented Nov 15, 2023

There is code in a/p/kexec/core_64.c:

/*
 * kexec thread structure and stack.
 *
 * We need to make sure that this is 16384-byte aligned due to the
 * way process stacks are handled.  It also must be statically allocated
 * or allocated as part of the kimage, because everything else may be
 * overwritten when we copy the kexec image.  We piggyback on the
 * "init_task" linker section here to statically allocate a stack.
 *
 * We could use a smaller stack if we don't care about anything using
 * current, but that audit has not been performed.
 */
static union thread_union kexec_stack __init_task_data =
	{ };

But since commit torvalds/linux@d11ed3a the __init_task_data macro has expanded to nothing on powerpc, because CONFIG_ARCH_TASK_STRUCT_ON_STACK is not set.

That means kexec_stack is not 16K aligned:

$ grep kexec_stack .build/System.map
c000000002a86800 b kexec_stack

In practice it probably doesn't matter, and no one has reported any breakage.

With modern kernels the only thing that's found by doing arithmetic on the stack pointer is pt_regs, via current_pt_regs(). That tends to only get used in ptrace and exec and so on, so is probably not called during the kexec sequence.

However it's still possible that bugs could be lurking due to the misaligned stack, so it should be properly aligned.

@mpe mpe added the bug It's a bug label Nov 15, 2023
@mpe mpe moved this from 🆕 New to 🔖 Ready in linuxppc backlog Nov 15, 2023
@mpe mpe added the easy Should be easy label Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug It's a bug easy Should be easy
Projects
Status: 🔖 Ready
Development

No branches or pull requests

1 participant