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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A50E7C43458 for ; Thu, 9 Jul 2026 01:20:51 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4gwcbj62X1z3c9w; Thu, 09 Jul 2026 11:20:49 +1000 (AEST) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=113.46.200.220 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1783560049; cv=none; b=AqcV0s8Q0TiFBPnJqGj0xdlzvc5OQmNMf9PdBsPZf8Q06sJSf9W/wI0G1q6N04DRBDAXDQFzPtBoQIjTs5fwXlOZ4F6a+vwLa9hLbEUA7v5jKOmOwBd2qB+SETQk5yLBrDRng7GTQ/B2b1LiPiQn6HWjsLhzJPbkki2nIvmzmq7UWtr1smsDB5VsxDllCIkDnfwn8oQ33WACInK/RzyhPmggeSUErjpQnrAhds2IkRhhHtOaAfDgeujo3vqVsof55hWl46MfFJ3gk4W+lcjpySTK8hwvv+rpkm63JYxBqAqY+RpeMnSOB7kQo1dQJ42ISribyfPVS/pPkAFIvTh0zA== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1783560049; c=relaxed/relaxed; bh=logP0BkDzgfpBgfCtRyUdHGD12mFR8OHhUuGpKFX0fc=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=mkTd0K57cMe68eutdKzu+MgDcBWYtz8bVQxDRlWW4COfJOis+ZfmmMNexrEBvX1UBXUZNq9b1pqVb5jWRxO86mpXYx/0reuWYU0c+f1yIEmz5ijMwGfRYD+cf2WlZg8FA43uA8Ta9kD9LbLPjI1IXAUjuAeVOHEkATOKcRHpAvyR50m6SV8VYhzhEa9hxCdn4MRuyGbxEwF/byk8j3EZD+16jAWGQQTCa25Z7aYF11gIxoMBDAWFmHsS2NigPFv4ZKJbNV1/X08mktjoK0BBUpTcBVL5W4b97M0FlUM7oMY2AtF+wsG6MLpVY7eyJMy4SB6JqldY83J3yX+xJdKibg== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; dkim=pass (1024-bit key; unprotected) header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256 header.s=dkim header.b=GMOyW0Y9; dkim-atps=neutral; spf=pass (client-ip=113.46.200.220; helo=canpmsgout05.his.huawei.com; envelope-from=ruanjinjie@huawei.com; receiver=lists.ozlabs.org) smtp.mailfrom=huawei.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256 header.s=dkim header.b=GMOyW0Y9; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=huawei.com (client-ip=113.46.200.220; helo=canpmsgout05.his.huawei.com; envelope-from=ruanjinjie@huawei.com; receiver=lists.ozlabs.org) Received: from canpmsgout05.his.huawei.com (canpmsgout05.his.huawei.com [113.46.200.220]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4gwcbf6btNz3c9q for ; Thu, 09 Jul 2026 11:20:44 +1000 (AEST) dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=logP0BkDzgfpBgfCtRyUdHGD12mFR8OHhUuGpKFX0fc=; b=GMOyW0Y9dGCUAfbHEgIpOCSfEMuETD0KYr6Ue7/qDl7GpDg/5Sjsm1Gv0Y0IEx9z9hjuQn/BR 2nzEy6HW2PEJaQkULjJJTrYZaOyXfj3rMgSC0E2TaG7iEt98R+lOK6nifZTfaMx5zXfaT45lgQf b9N52qi/4XIOax4YomANpFo= Received: from mail.maildlp.com (unknown [172.19.162.144]) by canpmsgout05.his.huawei.com (SkyGuard) with ESMTPS id 4gwcPT5Nbtz12LJx; Thu, 9 Jul 2026 09:11:57 +0800 (CST) Received: from dggpemf500011.china.huawei.com (unknown [7.185.36.131]) by mail.maildlp.com (Postfix) with ESMTPS id 930AB40538; Thu, 9 Jul 2026 09:20:36 +0800 (CST) Received: from [10.67.109.254] (10.67.109.254) by dggpemf500011.china.huawei.com (7.185.36.131) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Thu, 9 Jul 2026 09:20:33 +0800 Message-ID: <59017dbf-ad6a-4087-963c-5f0807326821@huawei.com> Date: Thu, 9 Jul 2026 09:20:32 +0800 X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [patch 01/18] powerpc: Move stack randomization after syscall_enter_from_user_mode() To: Thomas Gleixner , LKML CC: Peter Zijlstra , Michael Ellerman , Shrikanth Hegde , , Kees Cook , Huacai Chen , , Paul Walmsley , Palmer Dabbelt , , Sven Schnelle , , , Mark Rutland , Andy Lutomirski , Oleg Nesterov , Richard Henderson , Russell King , Catalin Marinas , Guo Ren , Geert Uytterhoeven , Thomas Bogendoerfer , Helge Deller , Yoshinori Sato , Richard Weinberger , Chris Zankel , , , , , , , , , Arnd Bergmann , Vineet Gupta , Will Deacon , Brian Cain , Michal Simek , Dinh Nguyen , "David S. Miller" , Andreas Larsson , , , , , , =?UTF-8?Q?Michal_Such=C3=A1nek?= , Jonathan Corbet , References: <20260707181957.433213175@kernel.org> <20260707190253.718191130@kernel.org> From: Jinjie Ruan In-Reply-To: <20260707190253.718191130@kernel.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.109.254] X-ClientProxiedBy: kwepems200001.china.huawei.com (7.221.188.67) To dggpemf500011.china.huawei.com (7.185.36.131) On 7/8/2026 3:05 AM, Thomas Gleixner wrote: > add_random_kstack_offset() is invoked before syscall_enter_from_user_mode() > establishes state. That's wrong because add_random_kstack_offset() calls > into instrumentable code. > > Move it after syscall_enter_from_user_mode() to ensure that state is > correctly established. > > Signed-off-by: Thomas Gleixner > Cc: Michael Ellerman > Cc: Shrikanth Hegde > Cc: linuxppc-dev@lists.ozlabs.org > --- > arch/powerpc/kernel/syscall.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > --- a/arch/powerpc/kernel/syscall.c > +++ b/arch/powerpc/kernel/syscall.c > @@ -19,8 +19,8 @@ notrace long system_call_exception(struc > long ret; > syscall_fn f; > > - add_random_kstack_offset(); > r0 = syscall_enter_from_user_mode(regs, r0); > + add_random_kstack_offset(); Reviewed-by: Jinjie Ruan > > if (unlikely(r0 >= NR_syscalls)) { > if (unlikely(trap_is_unsupported_scv(regs))) { >