Skip to content

ARM: support THREAD_INFO_IN_TASK

Keith Packard bpf kvm linux-arch linux-devicetree linux-mm lkml netdev virtualization 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest7 patches 1 replyIn review
  2. v17 patches 6 repliesSuperseded

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7ARM: Pass cpu number to secondary_start_kernelarch/arm/include/asm/smp.h arch/arm/kernel/head-nommu.S arch/arm/kernel/head.S +2 more+13 -120 replies
2/7ARM: Pass task to secondary_start_kernelarch/arm/include/asm/smp.h arch/arm/kernel/head-nommu.S arch/arm/kernel/head.S +1 more+9 -40 replies
3/7ARM: Use smp_processor_id() in vfp_pm_suspend instead of ti->cpuarch/arm/vfp/vfpmodule.c+3 -30 replies
4/7Make sure task_struct is available for raw_smp_processor_idarch/arm/mm/proc-v7-bugs.c drivers/vhost/vhost.c drivers/vhost/vhost.h +9 more+12 -11 reply
5/7ARM: Stop using TPIDRPRW to hold per_cpu_offsetarch/arm/include/asm/percpu.h arch/arm/kernel/setup.c arch/arm/kernel/smp.c+0 -410 replies
6/7ARM: Use TPIDRPRW for currentarch/arm/Kconfig arch/arm/include/asm/assembler.h arch/arm/include/asm/current.h +3 more+72 -00 replies
7/7ARM: Move thread_info into task_struct (v7 only)arch/arm/Kconfig arch/arm/include/asm/assembler.h arch/arm/include/asm/smp.h +4 more+37 -10 replies

Reviews trailers per patch

1 of 7 patches has a Reviewed-by or Acked-by.

PatchArd Biesheuvel
1/7R-b
2/7
3/7
4/7
5/7
6/7
7/7

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH v4 0/7] 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.

This is the fourth version of this series, in this version the changes are restricted to hardware which provides the TPIDRPRW register. This register is repurposed from holding the per_cpu_offset value to holding the 'current' value as that allows fetching this value atomically so that it can be used in a preemptable context.

The series is broken into seven pieces:

1) Change the secondary_start_kernel API to receive the cpu number. This avoids needing to be able to find this value independently in future patches.

2) Change the secondary_start_kernel API to also receive the 'task' value. Passing the value to this function also avoids needing to be able to discover it independently.

3) A cleanup which avoids assuming that THREAD_INFO_IN_TASK is not set.

4) Patches across the kernel which ensure that linux/sched.h has been included whenever raw_smp_processor_id() is used.

5) Disable the optimization storing per_cpu_offset in TPIDRPRW. This leaves the register free to hold 'current' instead.

6) Use TPIDRPRW for 'current'. This is enabled for either CPU_V6K or CPU_V7, but not if CPU_V6 is also enabled.

7) Enable THREAD_INFO_IN_TASK whenever TPIDRPRW is used to hold 'current'.

Keith Packard (7):
ARM: Pass cpu number to secondary_start_kernel
ARM: Pass task to secondary_start_kernel
ARM: Use smp_processor_id() in vfp_pm_suspend instead of ti->cpu Make sure task_struct is available for raw_smp_processor_id
ARM: Stop using TPIDRPRW to hold per_cpu_offset
ARM: Use TPIDRPRW for current
ARM: Move thread_info into task_struct (v7 only)

 arch/arm/Kconfig                   |  5 +++
 arch/arm/include/asm/assembler.h   | 12 +++++++
 arch/arm/include/asm/current.h     | 54 ++++++++++++++++++++++++++++++
 arch/arm/include/asm/percpu.h      | 31 -----------------
 arch/arm/include/asm/smp.h         |  8 ++++-
 arch/arm/include/asm/thread_info.h | 12 ++++++-
 arch/arm/kernel/asm-offsets.c      |  4 +++
 arch/arm/kernel/entry-armv.S       |  8 +++++
 arch/arm/kernel/head-nommu.S       |  2 ++
 arch/arm/kernel/head.S             |  2 ++
 arch/arm/kernel/setup.c            | 14 +-------
 arch/arm/kernel/smp.c              | 16 +++++----
 arch/arm/mm/proc-v7-bugs.c         |  1 +
 arch/arm/vfp/vfpmodule.c           | 15 +++++++--
 drivers/vhost/vhost.c              |  1 +
 drivers/vhost/vhost.h              |  1 +
 include/asm-generic/irq_regs.h     |  1 +
 include/linux/of_address.h         |  1 +
 include/linux/random.h             |  1 +
 include/linux/topology.h           |  1 +
 init/calibrate.c                   |  1 +
 kernel/bpf/bpf_lru_list.h          |  1 +
 kernel/bpf/percpu_freelist.h       |  1 +
 kernel/sched/cpuacct.c             |  2 +-
 lib/irq_regs.c                     |  1 +
 25 files changed, 140 insertions(+), 56 deletions(-)
 create mode 100644 arch/arm/include/asm/current.h
Signature · 1 line
2.33.0