]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
riscv: Initialize thread pointer before calling C functions
authorAlexandre Ghiti <alexandre.ghiti@canonical.com>
Mon, 6 Dec 2021 10:46:56 +0000 (11:46 +0100)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 10 Aug 2022 07:23:30 +0000 (09:23 +0200)
BugLink: https://bugs.launchpad.net/bugs/1981864
commit 35d33c76d68dfacc330a8eb477b51cc647c5a847 upstream.

Because of the stack canary feature that reads from the current task
structure the stack canary value, the thread pointer register "tp" must
be set before calling any C function from head.S: by chance, setup_vm
and all the functions that it calls does not seem to be part of the
functions where the canary check is done, but in the following commits,
some functions will.

Fixes: f2c9699f65557a31 ("riscv: Add STACKPROTECTOR supported")
Signed-off-by: Alexandre Ghiti <alexandre.ghiti@canonical.com>
Cc: stable@vger.kernel.org
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
arch/riscv/kernel/head.S

index 52c5ff9804c55a59138e49af9d7be9318586af1f..4c3c7592b6fc8a482e2af88986bc294463ab9a78 100644 (file)
@@ -301,6 +301,7 @@ clear_bss_done:
        REG_S a0, (a2)
 
        /* Initialize page tables and relocate to virtual addresses */
+       la tp, init_task
        la sp, init_thread_union + THREAD_SIZE
        XIP_FIXUP_OFFSET sp
 #ifdef CONFIG_BUILTIN_DTB