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 X-Spam-Level: X-Spam-Status: No, score=-20.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7791DC433E0 for ; Fri, 19 Mar 2021 12:51:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1D1A464E60 for ; Fri, 19 Mar 2021 12:51:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1D1A464E60 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=alien8.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 92B9F6B006E; Fri, 19 Mar 2021 08:51:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 900C96B0071; Fri, 19 Mar 2021 08:51:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 753A38D0001; Fri, 19 Mar 2021 08:51:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0168.hostedemail.com [216.40.44.168]) by kanga.kvack.org (Postfix) with ESMTP id 596EB6B006E for ; Fri, 19 Mar 2021 08:51:38 -0400 (EDT) Received: from smtpin38.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 20C5E82499A8 for ; Fri, 19 Mar 2021 12:51:38 +0000 (UTC) X-FDA: 77936610276.38.427E406 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by imf24.hostedemail.com (Postfix) with ESMTP id 6233DA0009DE for ; Fri, 19 Mar 2021 12:51:37 +0000 (UTC) Received: from zn.tnic (p200300ec2f091e000ec907ca620adac2.dip0.t-ipconnect.de [IPv6:2003:ec:2f09:1e00:ec9:7ca:620a:dac2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 556D11EC0324; Fri, 19 Mar 2021 13:51:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1616158295; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=Lk9msQ8lwSfedjnHkZUcL3GSRq6GlT11mzhXgP9EbMo=; b=F+67ambvthhfUAsYvwdThId59yMF1DvrzPxZKes7jJ03u7skgNXENIosppMKtRqB7BOhvF UZcVbO/t+Nvl9O1JIj4KXTyXNfmsamotMr6mBKDZbhKQpT+cJCgceO3zKAdI2EOrhIOL64 0FbpUMUhser7r1WhrE7NuAcKnv2/L4Y= Date: Fri, 19 Mar 2021 13:51:29 +0100 From: Borislav Petkov To: Yu-cheng Yu Cc: x86@kernel.org, "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Arnd Bergmann , Andy Lutomirski , Balbir Singh , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue , Dave Martin , Weijiang Yang , Pengfei Xu , Haitao Huang Subject: Re: [PATCH v23 23/28] x86/cet/shstk: Handle signals for shadow stack Message-ID: <20210319125129.GF6251@zn.tnic> References: <20210316151054.5405-1-yu-cheng.yu@intel.com> <20210316151054.5405-24-yu-cheng.yu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210316151054.5405-24-yu-cheng.yu@intel.com> X-Stat-Signature: rwbfimrye1y1pedidpfnbzugd6pqhdea X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 6233DA0009DE Received-SPF: none (alien8.de>: No applicable sender policy available) receiver=imf24; identity=mailfrom; envelope-from=""; helo=mail.skyhub.de; client-ip=5.9.137.197 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1616158297-869625 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Mar 16, 2021 at 08:10:49AM -0700, Yu-cheng Yu wrote: > To deliver a signal, create a shadow stack restore token and put the token > and the signal restorer address on the shadow stack. For sigreturn, verify > the token and restore from it the shadow stack pointer. > > A shadow stack restore token marks a restore point of the shadow stack, and > the address in a token must point directly above the token, which is within > the same shadow stack. This is distinctively different from other pointers > on the shadow stack; those pointers point to executable code area. > > In sigreturn, restoring from a token ensures the target address is the > location pointed by the token. > > Introduce WRUSS, which is a kernel-mode instruction but writes directly to > user shadow stack. It is used to construct the user signal stack as > described above. > > Currently there is no systematic facility for extending a signal context. > Introduce a signal context extension 'struct sc_ext', which is used to save > shadow stack restore token address and WAIT_ENDBR status. WAIT_ENDBR will > be introduced later in the Indirect Branch Tracking (IBT) series, but add > that into sc_ext now to keep the struct stable in case the IBT series is > applied later. > > Signed-off-by: Yu-cheng Yu > Reviewed-by: Kees Cook > --- > arch/x86/ia32/ia32_signal.c | 17 +++ > arch/x86/include/asm/cet.h | 8 ++ > arch/x86/include/asm/fpu/internal.h | 10 ++ > arch/x86/include/asm/special_insns.h | 32 ++++++ > arch/x86/include/uapi/asm/sigcontext.h | 9 ++ > arch/x86/kernel/cet.c | 152 +++++++++++++++++++++++++ > arch/x86/kernel/fpu/signal.c | 100 ++++++++++++++++ > arch/x86/kernel/signal.c | 10 ++ > 8 files changed, 338 insertions(+) The commit message lacks structure in explaining what the problem/missing functionality is and why this is solved the way it is, with stack tokens. Here's a good example how to structure it properly: https://git.kernel.org/tip/323950a8a98b492ac2fa168e8e4c0becfb4554dd Also, this patch does a couple of things at once and it needs splitting for easier review. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette