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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3AF43C6FD1F for ; Sat, 11 Mar 2023 15:06:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4E6436B0071; Sat, 11 Mar 2023 10:06:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4950E8E0002; Sat, 11 Mar 2023 10:06:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 383C18E0001; Sat, 11 Mar 2023 10:06:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 29EFF6B0071 for ; Sat, 11 Mar 2023 10:06:20 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id AF8131A0779 for ; Sat, 11 Mar 2023 15:06:19 +0000 (UTC) X-FDA: 80556943278.28.8D22569 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by imf13.hostedemail.com (Postfix) with ESMTP id 0933C2001B for ; Sat, 11 Mar 2023 15:06:11 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=temperror ("DNS error when getting key") header.d=alien8.de header.s=dkim header.b=SggQnHUg; spf=temperror (imf13.hostedemail.com: error in processing during lookup of bp@alien8.de: DNS error) smtp.mailfrom=bp@alien8.de; dmarc=temperror reason="SPF/DKIM temp error" header.from=alien8.de (policy=temperror) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678547177; a=rsa-sha256; cv=none; b=Gx+BABAP9ztoJ2TU3oKcVDZ/IV7BTfFJ1HUXhbjNDAWc8kzLFR4faOAQmFR1OuDhJQXHx4 3U5EADhgSb+xw/5d0objAQypEFUrSTFYK2hmahDBpB75kDDj1wy/gJ3Q2chGYgwADRX6mB k+blttx3GJHgqabscedfIMa13YoN2J4= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=temperror ("DNS error when getting key") header.d=alien8.de header.s=dkim header.b=SggQnHUg; spf=temperror (imf13.hostedemail.com: error in processing during lookup of bp@alien8.de: DNS error) smtp.mailfrom=bp@alien8.de; dmarc=temperror reason="SPF/DKIM temp error" header.from=alien8.de (policy=temperror) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1678547177; h=from:from:sender: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:dkim-signature; bh=i83jfo39n7QMWxUoY3tEAV03lUsmodN+NDXkdxSgb/8=; b=V2xqcNU7zXdGY+dvBGlmhlb0zYblWd8usGwUR++S2H4htI/NHUGx79WHsLKBgzMpA0ZYSy gjZUk2+A8g1ypIzesIl+o7oL7PADfk5U/AUMahbQP0jAqDSj1KNh1+Xpx3lP9W8aAGyyn6 sHm4jLv4kF3WKKTHy6zfYMjqm1fp6jQ= Received: from zn.tnic (p5de8e9fe.dip0.t-ipconnect.de [93.232.233.254]) (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 250D91EC0501; Sat, 11 Mar 2023 16:06:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1678547167; 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=i83jfo39n7QMWxUoY3tEAV03lUsmodN+NDXkdxSgb/8=; b=SggQnHUgQJgx3LqZReMr0kMmCymGL3wmgRsic7eHnZ0lKfbKfBbtV3o/gIij9K4QAzCZI/ ewqsr3IuyHt2IdnynzYStZidsPtO5oYVJBw6cX88UZd5t5g5YELH+rP2ZHr4CKEb2PaLr+ DZUyBLy+vG75cHJywPqFlYmuMf3DEuQ= Date: Sat, 11 Mar 2023 16:06:02 +0100 From: Borislav Petkov To: Rick Edgecombe 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 , Weijiang Yang , "Kirill A . Shutemov" , John Allen , kcc@google.com, eranian@google.com, rppt@kernel.org, jamorris@linux.microsoft.com, dethoma@microsoft.com, akpm@linux-foundation.org, Andrew.Cooper3@citrix.com, christina.schimpe@intel.com, david@redhat.com, debug@rivosinc.com, Yu-cheng Yu Subject: Re: [PATCH v7 39/41] x86: Add PTRACE interface for shadow stack Message-ID: References: <20230227222957.24501-1-rick.p.edgecombe@intel.com> <20230227222957.24501-40-rick.p.edgecombe@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230227222957.24501-40-rick.p.edgecombe@intel.com> X-Rspam-User: X-Rspamd-Queue-Id: 0933C2001B X-Rspamd-Server: rspam01 X-Stat-Signature: 3taabm4ssrjyt818a9nky36fxn8smepa X-HE-Tag: 1678547171-216828 X-HE-Meta: U2FsdGVkX1/PveITn+rooefFBvPXernlY3B5E2mGY2AIDDWDKYQ4WmrrYuAdsdW4DFzArkttpfgpyo7InKGVDodGsEikDWB9weX6Atx0+GYnOyubxpJHN5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+87D9WbIBV8yv3/mcWyNR4vRHXYi3SUVjKc0q7ShmdxoDpC2ttXRID6LaVgNmzrC/4shwpmvJAQx+JfClzRqlszc+4hmQIWX1RnsbW+fTx7sqMS9MbFHTl8SRBX0sueCVVG2RatLLg9rBzKaTvqERRFT6U2zz3v/tE6Buj1T+RWKLQEvU= 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 Mon, Feb 27, 2023 at 02:29:55PM -0800, Rick Edgecombe wrote: > The only downside to not having a generic supervisor xfeature regset, > is that apps need to be enlightened of any new supervisor xfeature > exposed this way (i.e. they can't try to have generic save/restore > logic). But maybe that is a good thing, because they have to think > through each new xfeature instead of encountering issues when new a new Remove the first "new". > supervisor xfeature was added. > > By adding a shadow stack regset, it also has the effect of including the > shadow stack state in a core dump, which could be useful for debugging. > > The shadow stack specific xstate includes the SSP, and the shadow stack > and WRSS enablement status. Enabling shadow stack or wrss in the kernel ^^^^ "WRSS" > involves more than just flipping the bit. The kernel is made aware that > it has to do extra things when cloning or handling signals. That logic > is triggered off of separate feature enablement state kept in the task > struct. So the flipping on HW shadow stack enforcement without notifying > the kernel to change its behavior would severely limit what an application > could do without crashing, and the results would depend on kernel > internal implementation details. There is also no known use for controlling > this state via prtace today. So only expose the SSP, which is something Unknown word [prtace] in commit message. Suggestions: ['ptrace' > that userspace already has indirect control over. > > Tested-by: Pengfei Xu > Tested-by: John Allen > Tested-by: Kees Cook > Acked-by: Mike Rapoport (IBM) > Reviewed-by: Kees Cook > Co-developed-by: Rick Edgecombe > Signed-off-by: Rick Edgecombe > Signed-off-by: Yu-cheng Yu I think your SOB should come last: ... Signed-off-by: Yu-cheng Yu Co-developed-by: Rick Edgecombe Signed-off-by: Rick Edgecombe Pls check whole set. > +#ifdef CONFIG_X86_USER_SHADOW_STACK > +int ssp_active(struct task_struct *target, const struct user_regset *regset) > +{ > + if (target->thread.features & ARCH_SHSTK_SHSTK) > + return regset->n; > + > + return 0; > +} > + > +int ssp_get(struct task_struct *target, const struct user_regset *regset, > + struct membuf to) > +{ > + struct fpu *fpu = &target->thread.fpu; > + struct cet_user_state *cetregs; > + > + if (!boot_cpu_has(X86_FEATURE_USER_SHSTK)) check_for_deprecated_apis: WARNING: arch/x86/kernel/fpu/regset.c:193: Do not use boot_cpu_has() - use cpu_feature_enabled() instead. Check your whole set pls. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette