Skip to content

Fix CLONE_SETTLS with clone3

Amanieu d'Antras linux-arm-kernel linux-kselftest linux-parisc linux-riscv linux-um lkml stable 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest7 patches 18 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7arm64: Move __ARCH_WANT_SYS_CLONE3 definition to uapi headersarch/arm64/include/asm/unistd.h arch/arm64/include/uapi/asm/unistd.h+1 -14 replies
2/7arm64: Implement copy_thread_tlsarch/arm64/Kconfig arch/arm64/kernel/process.c+6 -58 replies
3/7arm: Implement copy_thread_tlsarch/arm/Kconfig arch/arm/kernel/process.c+4 -31 reply
4/7parisc: Implement copy_thread_tlsarch/parisc/Kconfig arch/parisc/kernel/process.c+5 -40 replies
5/7riscv: Implement copy_thread_tlsarch/riscv/Kconfig arch/riscv/kernel/process.c+4 -30 replies
6/7xtensa: Implement copy_thread_tlsarch/xtensa/Kconfig arch/xtensa/kernel/process.c+5 -40 replies
7/7clone3: ensure copy_thread_tls is implementedkernel/fork.c+10 -03 replies

Reviews trailers per patch

4 of 7 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchChristian BraunerArnd BergmannWill DeaconRichard Weinberger
SeriesA-b A-b A-b
1/7R-b
2/7A-b A-b
3/7A-b
4/7
5/7
6/7
7/7R-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 4 reviewers.

Read the v1 thread

Cover letter [PATCH 0/7] Fix CLONE_SETTLS with clone3

The clone3 syscall is currently broken when used with CLONE_SETTLS on all architectures that don't have an implementation of copy_thread_tls. The old copy_thread function handles CLONE_SETTLS by reading the new TLS value from pt_regs containing the clone syscall parameters. Since clone3 passes the TLS value in clone_args, this results in the TLS register being initialized to a garbage value.

This patch series implements copy_thread_tls on all architectures that currently define __ARCH_WANT_SYS_CLONE3 and adds a compile-time check to ensure that any architecture that enables clone3 in the future also implements copy_thread_tls.

I have also included a minor fix for the arm64 uapi headers which caused __NR_clone3 to be missing from the exported user headers.

I have only tested this on arm64, but the copy_thread_tls implementations for the various architectures are fairly straightforward.

Amanieu d'Antras (7):
arm64: Move __ARCH_WANT_SYS_CLONE3 definition to uapi headers
arm64: Implement copy_thread_tls
arm: Implement copy_thread_tls
parisc: Implement copy_thread_tls
riscv: Implement copy_thread_tls
xtensa: Implement copy_thread_tls
clone3: ensure copy_thread_tls is implemented

 arch/arm/Kconfig                     |  1 +
 arch/arm/kernel/process.c            |  6 +++---
 arch/arm64/Kconfig                   |  1 +
 arch/arm64/include/asm/unistd.h      |  1 -
 arch/arm64/include/uapi/asm/unistd.h |  1 +
 arch/arm64/kernel/process.c          | 10 +++++-----
 arch/parisc/Kconfig                  |  1 +
 arch/parisc/kernel/process.c         |  8 ++++----
 arch/riscv/Kconfig                   |  1 +
 arch/riscv/kernel/process.c          |  6 +++---
 arch/xtensa/Kconfig                  |  1 +
 arch/xtensa/kernel/process.c         |  8 ++++----
 kernel/fork.c                        | 10 ++++++++++
 13 files changed, 35 insertions(+), 20 deletions(-)
Signature · 1 line
2.24.1