Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2155502iof; Tue, 7 Jun 2022 21:36:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFEoUs3E3OulvDgIhwfv/GzsRrWJ2i+wBdabNg4iPPDAAkuQbQKY+a5nAuUJkexNbrz4kP X-Received: by 2002:a17:90b:4d11:b0:1e8:436b:a9cc with SMTP id mw17-20020a17090b4d1100b001e8436ba9ccmr25591392pjb.40.1654663007920; Tue, 07 Jun 2022 21:36:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654663007; cv=none; d=google.com; s=arc-20160816; b=BBqe5COcQZK0zjyGEFzTKNlKPKLU6/uP6txox/SyMH8NDQfuaV15H555oMj36FAfx4 Z+Wt/25nE8zMlIz6Ne5XauHSVOoWEonQwf2lX9TYquFl5/BnHozy+Ms9XW8u5wUR4Svj VvS5qR/wuCcNSCCXB4Gm7lhrkmFmuq3Utctgn70lU57mCUm12NDpLZACPWGOyCoN/40O 7VmlLRftmA+G+TE8l/sh/nmC/8MJAJ04dE52bVjhhxVCxgZ8NCQCMVlVd9vj48LFVvWK uJhsakBjsZ9lSDeJY0hW2P+KuEZC35Tc0CXQinj6GKubIlFwjoz5ZTZc6LtQB3uuEc06 t4fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=DzEoXXj/52RD5vXo3bAkkGwnwIxhDS80659M9imj5w0=; b=y1wQF9mG9OFGl9aV/7Mz9lmi/kMqemVw2DyAWisd9WVdbCL6tBTL4eWG11/8P0ZopO QCwiFvq5moCRWuc7Ye9/DrBr8/L7fzoPjwRtexgM6TqXC1se75z2wYccCADznzYTPXB8 TWvO3/bnBqa69Va6BoEhMorah7R0J8M6Xz7fCdmizAnxGYDGxnBw8lH0/Yq2e7z0biHm 9aUThd3UBY6DdXTdEzI2XylrkAS6Vpm9xYkurL9P+9JRSdSfpXll4Gnt6cl13v2OmQPV 09DBL8N2wfWL6eTWYmwMO91SSTrflTlAf6CRClOlyr6iErC6VrxkbcCxuQLFyVhFzR5Y wJyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mMW2n5Lq; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id y14-20020a63ad4e000000b003fb23692294si29675777pgo.218.2022.06.07.21.36.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:36:47 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mMW2n5Lq; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CD5C34397D0; Tue, 7 Jun 2022 21:09:24 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383299AbiFGWBj (ORCPT + 99 others); Tue, 7 Jun 2022 18:01:39 -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 X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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