[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210908190605.419064-1-keithpac@amazon.com>
Date: Wed, 8 Sep 2021 12:05:58 -0700
From: Keith Packard <keithpac@...zon.com>
To: linux-kernel@...r.kernel.org
Cc: Abbott Liu <liuwenliang@...wei.com>,
Alexei Starovoitov <ast@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Andrii Nakryiko <andrii@...nel.org>,
Anshuman Khandual <anshuman.khandual@....com>,
Ard Biesheuvel <ardb@...nel.org>,
Arnd Bergmann <arnd@...db.de>, Ben Segall <bsegall@...gle.com>,
Bjorn Andersson <bjorn.andersson@...aro.org>,
bpf@...r.kernel.org, Christoph Lameter <cl@...ux.com>,
Daniel Borkmann <daniel@...earbox.net>,
Daniel Bristot de Oliveira <bristot@...hat.com>,
Dennis Zhou <dennis@...nel.org>, devicetree@...r.kernel.org,
Dietmar Eggemann <dietmar.eggemann@....com>,
Florian Fainelli <f.fainelli@...il.com>,
Frank Rowand <frowand.list@...il.com>,
Geert Uytterhoeven <geert+renesas@...der.be>,
Ingo Molnar <mingo@...hat.com>,
Jason Wang <jasowang@...hat.com>, Jens Axboe <axboe@...nel.dk>,
Joe Perches <joe@...ches.com>,
John Fastabend <john.fastabend@...il.com>,
Juri Lelli <juri.lelli@...hat.com>,
Keith Packard <keithpac@...zon.com>,
KP Singh <kpsingh@...nel.org>, kvm@...r.kernel.org,
Linus Walleij <linus.walleij@...aro.org>,
linux-arch@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-mm@...ck.org, Manivannan Sadhasivam <mani@...nel.org>,
Marc Zyngier <maz@...nel.org>, Martin KaFai Lau <kafai@...com>,
Mel Gorman <mgorman@...e.de>,
Michael Ellerman <mpe@...erman.id.au>,
"Michael S. Tsirkin" <mst@...hat.com>,
Miguel Ojeda <ojeda@...nel.org>,
Mike Rapoport <rppt@...nel.org>, netdev@...r.kernel.org,
Nick Desaulniers <ndesaulniers@...gle.com>,
Nick Desaulniers <ndesaulniers@...ogle.com>,
Nicolas Pitre <nico@...xnic.net>,
Peter Zijlstra <peterz@...radead.org>,
Rob Herring <robh+dt@...nel.org>,
Russell King <linux@...linux.org.uk>,
Song Liu <songliubraving@...com>,
Srikar Dronamraju <srikar@...ux.vnet.ibm.com>,
Steven Rostedt <rostedt@...dmis.org>,
Tejun Heo <tj@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>,
Uwe Kleine-König
<u.kleine-koenig@...gutronix.de>,
Valentin Schneider <valentin.schneider@....com>,
Vincent Guittot <vincent.guittot@...aro.org>,
virtualization@...ts.linux-foundation.org,
"Wolfram Sang (Renesas)" <wsa+renesas@...g-engineering.com>,
YiFei Zhu <yifeifz2@...inois.edu>, Yonghong Song <yhs@...com>
Subject: [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'.
Signed-off-by: Keith Packard <keithpac@...zon.com>
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
Powered by blists - more mailing lists