kexec_stack is misaligned
Nobody has claimed this yet.
- Dominant language
- No language data
- Stars
- 14
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
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@d11ed3ab3166a2bfad60681aebf3e13e1c3408a9 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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the kexec_stack declaration in a/p/kexec/core_64.c and inspect how __init_task_data expands for powerpc, including the referenced commit. Rebuild the kernel and check .build/System.map; done means kexec_stack is 16384-byte aligned without breaking the kexec path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, linux
- Domain
- operating-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100