From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from canpmsgout05.his.huawei.com (canpmsgout05.his.huawei.com [113.46.200.220]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD06C2D12ED; Thu, 9 Jul 2026 01:20:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.220 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783560053; cv=none; b=BGctwNvnS1NgyKESyV7AOtR+DtNAHjG19uvZe+ZksUURyqVcbWzFmmyRZimZMLT41raf6GJGYmOtJ0SZhHS9YU2NqkMZ8aky969KUHOuxCjWAxDdYxj1x1qKunGd3EGYppCn8m8TOD1E3JfyYYCnh0nOBcWneg9zZj5b8xGp63U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783560053; c=relaxed/simple; bh=dhih/9EEi8tfr4hv87Z/XybbjRVbueEGTIRSuWNroIk=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=QIiqejaH/H9+kjNy3QmBvSaXcl6QeWw24zRmkYPhlVk5SbccBkEcMMDx+yRchGwBuFps281HYrj8v0nxKQ0viOb+J5cH99aNmSPdLVC8LzKqR9WYXF7oEIcKRlowEFiMt/R752yzI7mnLv7JLe/xX5WlJxlThWFKOp/lM859kO4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b=GMOyW0Y9; arc=none smtp.client-ip=113.46.200.220 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.b="GMOyW0Y9" 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 Precedence: bulk X-Mailing-List: linux-csky@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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-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))) { >