From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2CFE2C433EF for ; Tue, 7 Jun 2022 21:04:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378899AbiFGVEU (ORCPT ); Tue, 7 Jun 2022 17:04:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379119AbiFGVCF (ORCPT ); Tue, 7 Jun 2022 17:02:05 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2411B188E7D; Tue, 7 Jun 2022 11:46:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B3B27612F2; Tue, 7 Jun 2022 18:46:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2514C385A2; Tue, 7 Jun 2022 18:46:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654627596; bh=+X1/Aj4S764+n4uxy2PfC01XzrJFcJkGE0j/wvJKRxw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mMW2n5Lq2V352TsRIWgYfGst8R95k5VI7NjoIynsIEist+nXpr9CBM53g6XzwTqwK 4pgtrpuyLoy3Kf3P8sRa4MT2nd+7wtdENtD0VhGiziY8PnGaTSeC/rlVDcPktyXF93 tk58VTMZvlMCrMCigdJBZ3Ts/sxXLVkq72JQOaJs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexandre Ghiti , Palmer Dabbelt Subject: [PATCH 5.18 007/879] riscv: Initialize thread pointer before calling C functions Date: Tue, 7 Jun 2022 18:52:05 +0200 Message-Id: <20220607165002.885131751@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Alexandre Ghiti 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 Cc: stable@vger.kernel.org Signed-off-by: Palmer Dabbelt Signed-off-by: Greg Kroah-Hartman --- arch/riscv/kernel/head.S | 1 + 1 file changed, 1 insertion(+) --- a/arch/riscv/kernel/head.S +++ b/arch/riscv/kernel/head.S @@ -297,6 +297,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