[PATCH v5 0/5] ARM: support THREAD_INFO_IN_TASK

Ard Biesheuvel ardb at kernel.org
Sun Sep 19 09:23:10 PDT 2021


On Sun, 19 Sept 2021 at 15:44, Amit Kachhap <amit.kachhap at arm.com> wrote:
>
>
>
> On 9/18/21 2:14 PM, Ard Biesheuvel wrote:
> > Placing thread_info in the kernel stack leaves it vulnerable to stack
> > overflow attacks. This short series addresses that by using the existing
> > THREAD_INFO_IN_TASK infrastructure.
> >
> > Changes since v4:
> >
> > - Pass -mtp=cp15 to the compiler to force the use of the TLS register
> >    when __builtin_thread_pointer() is used - this allows us to enable its
> >    use on Clang as well.
> >
> > - Tweak the __switch_to() changes not to affect builds that have the
> >    feature disabled (as requested by Russell), and to defer update of the
> >    TLS register to the point where the stack pointer is updated as well.
> >
> > - Tweak the #ifdef's so we avoid touching the TLS registers on builds
> >    that may target v6 systems without HWCAP_TLS.
> >
> > - Use task_cpu() in the final patch to assign thread_info->cpu, so that
> >    this series can be carried independently of the series I proposed for
> >    moving the CPU field back into thread_info [1].
> >
> > Changes since v3:
> >
> > - Leave the CPU field in thread_info, and keep it in sync at context
> >    switch time. This is by far the easiest and cleanest way to work
> >    around the fact that it is infeasible to implement
> >    raw_smp_processor_id() in terms of task_struct::cpu (for reasons of
> >    header soup).
> >
> > - Drop the VFP changes, they are no longer necessary given the previous
> >    point.
> >
> > - Drop the change to pass the CPU number to secondary_start_kernel().
> >    Given that we also need to pass the idle task pointer, which carries
> >    the CPU number, passing the CPU number directly is redundant.
> >
> > - Use the TPIDRURO register to carry 'current' while running in the
> >    kernel, and keep using TPIDRPRW for the per-CPU offset as before. This
> >    way, there is no need to make any changes to the way the per-CPU offsets
> >    are programmed. It also avoids the concurrency issues that would
> >    result from carrying the 'current' pointer in a per-CPU variable.
> >
> > - Update the per-task stack protector plugin to pull the stack canary
> >    value directly from the task struct.
> >
> > Cc: Keith Packard <keithpac at amazon.com>
> > Cc: Russell King <linux at armlinux.org.uk>
> > Cc: Kees Cook <keescook at chromium.org>
> > Cc: Arnd Bergmann <arnd at arndb.de>
> > Cc: Linus Walleij <linus.walleij at linaro.org>
>
> This series boots with both CURRENT_POINTER_IN_TPIDRURO and
> !CURRENT_POINTER_IN_TPIDRURO mode so,
>
> Tested-by: Amit Daniel Kachhap <amit.kachhap at arm.com>
>

Thanks!



More information about the linux-arm-kernel mailing list