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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 A209FC2BD09 for ; Thu, 27 Jun 2024 17:02:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To: Content-Transfer-Encoding:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=O48xNz+820fdwkk5+a70a5pdjyNMgZbizAOAOcbH1kw=; b=x74y0xN40ecgreg5rKxTD4I1Cn /T2nJEqett21L9HphfXjUvqyzAh2S4yBe1DQZm4ddePzj9+h+fm4HCwy5DP+EsmyVlK6LQtEfRf89 5rkSVXfJIq2GpvIhakZ1UaU4lLe4hcE2yM0Oe38RtgkTg1tNsbmBSN71I3bNz8gX9PdEkYXAj+EgS XecZ3lxhbbE80+anHzDFf318ZEjS7YEopyL9rqkHG2AGSBqVOwWlWOUNPAzxVC0lwFNrqahlgFG7h E5mSInKUmpqEcf0+HlyWSAuSe6GZsvUF8p6w47N5RPvDjdZZ2/KCVD/z8a48sz+si1dkxmn/6f0aq ylRAglIQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMsVy-0000000B7h6-4BdJ; Thu, 27 Jun 2024 17:02:31 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sMsVq-0000000B7fa-3noV for linux-arm-kernel@lists.infradead.org; Thu, 27 Jun 2024 17:02:24 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 1BE2F61F34; Thu, 27 Jun 2024 17:02:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B29EDC2BBFC; Thu, 27 Jun 2024 17:02:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719507741; bh=SjeeyRQwE/Gd/xv/dHmc+00VP8GHf3kSuSkKYxNX2cY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=DoBUZh3SmyCAVqjkIKH98iruRgLZjNlsFfGG5ghtoGgun3ornA28W7v3tOecwcE/X ZthwgQP7wsf3WMvm2jY5bL+S7ssUDTQzsGRE1kafdVNIPSZmhuiGOlUr5EDEOXsfK+ hGj6x8lJFoHOnq7kyp2cgPOVyj1RnfZ6Euus/sxeaLrzHayNx8JFlKq8Z1VTyjVrT3 5KTWSsvlrKiC9R/qU+JDLDv+wYo6LfQZALUCEbKgZDSqmVllclAZCUoTDr+PgYTYkt FPMhvXCi8Dl57paU3l9+YfGpAJBlkis2ki25kPd0qruY8oy/fK8XJnt3F9HpwbXzb4 RhSZcRt7HcpMQ== Date: Thu, 27 Jun 2024 10:02:21 -0700 From: Kees Cook To: Jinjie Ruan Cc: Linus Walleij , linux@armlinux.org.uk, ardb@kernel.org, arnd@arndb.de, afd@ti.com, akpm@linux-foundation.org, rmk+kernel@armlinux.org.uk, eric.devolder@oracle.com, robh@kernel.org, masahiroy@kernel.org, palmer@rivosinc.com, samitolvanen@google.com, xiao.w.wang@intel.com, alexghiti@rivosinc.com, nathan@kernel.org, jan.kiszka@siemens.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org Subject: Re: [PATCH v2] ARM: Add support for STACKLEAK gcc plugin Message-ID: <202406271001.67295EE@keescook> References: <20240624023612.2134144-1-ruanjinjie@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240627_100223_035806_80D9233D X-CRM114-Status: GOOD ( 19.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Jun 27, 2024 at 03:53:14PM +0800, Jinjie Ruan wrote: > > > On 2024/6/24 15:30, Linus Walleij wrote: > > On Mon, Jun 24, 2024 at 4:33 AM Jinjie Ruan wrote: > > > >> Add the STACKLEAK gcc plugin to arm32 by adding the helper used by > >> stackleak common code: on_thread_stack(). It initialize the stack with the > >> poison value before returning from system calls which improves the kernel > >> security. Additionally, this disables the plugin in EFI stub code and > >> decompress code, which are out of scope for the protection. > >> > >> Before the test on Qemu versatilepb board: > >> # echo STACKLEAK_ERASING > /sys/kernel/debug/provoke-crash/DIRECT > >> lkdtm: Performing direct entry STACKLEAK_ERASING > >> lkdtm: XFAIL: stackleak is not supported on this arch (HAVE_ARCH_STACKLEAK=n) > >> > >> After: > >> # echo STACKLEAK_ERASING > /sys/kernel/debug/provoke-crash/DIRECT > >> lkdtm: Performing direct entry STACKLEAK_ERASING > >> lkdtm: stackleak stack usage: > >> high offset: 80 bytes > >> current: 280 bytes > >> lowest: 696 bytes > >> tracked: 696 bytes > >> untracked: 192 bytes > >> poisoned: 7220 bytes > >> low offset: 4 bytes > >> lkdtm: OK: the rest of the thread stack is properly erased > >> > >> Signed-off-by: Jinjie Ruan > >> Acked-by: Ard Biesheuvel > > > > Reviewed-by: Linus Walleij > > > > I was digging around to see if this would interfere with BPF > > trampolines, but the > > BPF code seems so generic that I assume it already takes stackleak into account. > > > Thank you very much, as Kees said, can this patch go via > rmk's patch tracker now? Probably yes (we have some reviews now). Please go ahead and add it there. -- Kees Cook