[PATCH v4 0/7] ARM: support THREAD_INFO_IN_TASK

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Keith Packard <keithpac@xxxxxxxxxx>

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

-- 
2.33.0





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux