Skip to content

ARM: support THREAD_INFO_IN_TASK

Ard Biesheuvel linux-arm-kernel 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v5 Latest5 patches 10 repliesIn review
  2. v45 patches 14 repliesSuperseded

Changes in v5 from the cover letter

- 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].

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5gcc-plugins: arm-ssp: Prepare for THREAD_INFO_IN_TASK supportarch/arm/Kconfig arch/arm/Makefile arch/arm/include/asm/stackprotector.h +4 more+8 -391 reply
2/5ARM: smp: Pass task to secondary_start_kernelarch/arm/include/asm/smp.h arch/arm/kernel/head-nommu.S arch/arm/kernel/head.S +1 more+12 -51 reply
3/5ARM: smp: Free up the TLS register while running in the kernelarch/arm/include/asm/tls.h arch/arm/kernel/entry-header.S+15 -31 reply
4/5ARM: smp: Store current pointer in TPIDRURO register if availablearch/arm/Kconfig arch/arm/Makefile arch/arm/include/asm/assembler.h +9 more+105 -22 replies
5/5ARM: smp: Enable THREAD_INFO_IN_TASKarch/arm/Kconfig arch/arm/include/asm/assembler.h arch/arm/include/asm/switch_to.h +4 more+35 -23 replies

Reviews trailers per patch

All 5 patches have a Reviewed-by or Acked-by.

PatchKees CookLinus WalleijAmit Daniel Kachhap
SeriesT-b
1/5R-b R-b
2/5R-b
3/5R-b
4/5R-b
5/5R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v5 thread

Cover letter [PATCH v5 0/5] ARM: support THREAD_INFO_IN_TASK

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 <[email protected]>
Cc Russell King <[email protected]>
Cc Kees Cook <[email protected]>
Cc Arnd Bergmann <[email protected]>
Cc Linus Walleij <[email protected]>

[0] https://lore.kernel.org/all/[email protected]/
[1] https://lore.kernel.org/all/[email protected]/

Ard Biesheuvel (4):
gcc-plugins: arm-ssp: Prepare for THREAD_INFO_IN_TASK support
ARM: smp: Free up the TLS register while running in the kernel
ARM: smp: Store current pointer in TPIDRURO register if available
ARM: smp: Enable THREAD_INFO_IN_TASK

Keith Packard (1):
ARM: smp: Pass task to secondary_start_kernel

 arch/arm/Kconfig                              |  8 +++-
 arch/arm/Makefile                             |  9 ++--
 arch/arm/include/asm/assembler.h              | 29 ++++++++++++
 arch/arm/include/asm/current.h                | 50 ++++++++++++++++++++
 arch/arm/include/asm/smp.h                    |  3 +-
 arch/arm/include/asm/stackprotector.h         |  2 -
 arch/arm/include/asm/switch_to.h              | 16 +++++++
 arch/arm/include/asm/thread_info.h            | 15 ++++--
 arch/arm/include/asm/tls.h                    | 10 ++--
 arch/arm/kernel/asm-offsets.c                 |  6 +--
 arch/arm/kernel/entry-armv.S                  |  5 ++
 arch/arm/kernel/entry-common.S                |  1 +
 arch/arm/kernel/entry-header.S                |  8 ++++
 arch/arm/kernel/head-common.S                 |  5 ++
 arch/arm/kernel/head-nommu.S                  |  1 +
 arch/arm/kernel/head.S                        |  5 +-
 arch/arm/kernel/process.c                     |  8 ++--
 arch/arm/kernel/smp.c                         | 13 ++++-
 arch/arm/mm/proc-macros.S                     |  3 +-
 scripts/gcc-plugins/arm_ssp_per_task_plugin.c | 27 +++--------
 20 files changed, 174 insertions(+), 50 deletions(-)
 create mode 100644 arch/arm/include/asm/current.h
Signature · 7 lines
2.30.2


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel