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 13DA2C64EC3 for ; Fri, 3 Feb 2023 19:44:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 50E2D6B0071; Fri, 3 Feb 2023 14:44:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4BE646B0072; Fri, 3 Feb 2023 14:44:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 385D16B0073; Fri, 3 Feb 2023 14:44:30 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 2CC166B0071 for ; Fri, 3 Feb 2023 14:44:30 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id EC2741A06C5 for ; Fri, 3 Feb 2023 19:44:29 +0000 (UTC) X-FDA: 80427007458.02.69E77D1 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by imf12.hostedemail.com (Postfix) with ESMTP id 0763B40004 for ; Fri, 3 Feb 2023 19:44:25 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=alien8.de header.s=dkim header.b="Yw/nyWbP"; spf=pass (imf12.hostedemail.com: domain of bp@alien8.de designates 5.9.137.197 as permitted sender) smtp.mailfrom=bp@alien8.de; dmarc=pass (policy=none) header.from=alien8.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675453468; 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=Aawd1Ae416cyoOlyUnwX/vsr0DPMmD0L5HLCQmlorYw=; b=IuO/rvGblRy3iSttOZzeTkrJDNviBl3NwF24ET8BQ1x5MkD7n10jBmWN3wjNFdPNJVaSRr 9qa8xlzyYsDTlCupjIdBSYTX/TRFbM1Ji7UEFGZ0W5LAcNCuybVPcxZotWISeqRexEnqYS inY2i7N/rIuqG6HX9LO7Tz13jXBdRzs= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=alien8.de header.s=dkim header.b="Yw/nyWbP"; spf=pass (imf12.hostedemail.com: domain of bp@alien8.de designates 5.9.137.197 as permitted sender) smtp.mailfrom=bp@alien8.de; dmarc=pass (policy=none) header.from=alien8.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675453468; a=rsa-sha256; cv=none; b=jig0Pz0+fGinAf60ESJ/2P8Ks3p+SvNljt7b5FrMt8uREJZTagqETD05otpgIr7bNCC7Ji NEtVgliVoObmNYzdw7Yiu1zbAZ3MH40R4E/Yqy9Ah+5fvRhzKs0OOMaWmSV1P/C1qeHDbU y/6JdRfbE8i/FJlFJ95S8w1a2ieeXTo= 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 30CE51EC050B; Fri, 3 Feb 2023 20:44:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1675453464; 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=Aawd1Ae416cyoOlyUnwX/vsr0DPMmD0L5HLCQmlorYw=; b=Yw/nyWbPDsXI1pcZe7prJu7pg191XIQbuN4noeqgHgrl7hN4Y0WSj41wuH1q0Nf72djV/U 3JCyy3RBcRldDMC8zylW4+u6JZRWwSl56OG6QmFQMZjMxbeVXD2+VY8n5AZoHpQinTiHHI Hr0nGS0ONG4GHznX84tW9AA6HshKxIA= Date: Fri, 3 Feb 2023 20:44:20 +0100 From: Borislav Petkov To: "Edgecombe, Rick P" Cc: "bsingharora@gmail.com" , "hpa@zytor.com" , "Syromiatnikov, Eugene" , "peterz@infradead.org" , "rdunlap@infradead.org" , "keescook@chromium.org" , "Yu, Yu-cheng" , "dave.hansen@linux.intel.com" , "kirill.shutemov@linux.intel.com" , "Eranian, Stephane" , "linux-mm@kvack.org" , "fweimer@redhat.com" , "nadav.amit@gmail.com" , "jannh@google.com" , "dethoma@microsoft.com" , "kcc@google.com" , "linux-arch@vger.kernel.org" , "pavel@ucw.cz" , "oleg@redhat.com" , "hjl.tools@gmail.com" , "Yang, Weijiang" , "Lutomirski, Andy" , "linux-doc@vger.kernel.org" , "arnd@arndb.de" , "tglx@linutronix.de" , "Schimpe, Christina" , "mike.kravetz@oracle.com" , "x86@kernel.org" , "akpm@linux-foundation.org" , "jamorris@linux.microsoft.com" , "john.allen@amd.com" , "rppt@kernel.org" , "andrew.cooper3@citrix.com" , "mingo@redhat.com" , "mtk.manpages@gmail.com" , "corbet@lwn.net" , "linux-kernel@vger.kernel.org" , "linux-api@vger.kernel.org" , "gorcunov@gmail.com" Subject: Re: [PATCH v5 07/39] x86: Add user control-protection fault handler Message-ID: References: <20230119212317.8324-1-rick.p.edgecombe@intel.com> <20230119212317.8324-8-rick.p.edgecombe@intel.com> <393a03d063dee5831af93ca67636df75a76481c3.camel@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <393a03d063dee5831af93ca67636df75a76481c3.camel@intel.com> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 0763B40004 X-Stat-Signature: 1ugnh8p1xamg14qdp5nyem1it3mnchmb X-Rspam-User: X-HE-Tag: 1675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6/akS7hbL25LDvO6TAST3I8/vKCZD+Q4gms8/xE2V6MRWB6SRBINplH2dz4bOwrnsV9lVJu4UdmtLNLqhNdBoxxI2Ktz+3Zi+czFiFPkHNcjQ5sPatB23lU4ieRPbbKX6MNipEty3o6Ja+VCkAJMW3tEoe1gE522QIYNW+AqAu78wothVyi9AdHOTPQJjdDBXXRpa05iqUVHyqHBnbsRsKlMdJtkzZVoRuzox8/5AkN9Ng6FjEFWg1mM+4IdtWV4r 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 Fri, Feb 03, 2023 at 07:24:08PM +0000, Edgecombe, Rick P wrote: > The name seems better, but this is actually from the existing kernel > IBT control protection exception code. So it seems like an separate > change. Would you like to see it snuck into the user shadow stack > handler, or could we leave this for future cleanups? > > Kees pointed out that adding to the handler and moving it in the same > patch makes it difficult to see where the changes are. I'm splitting > this one into two patches for the next version. Yap, that's the right way to do it. > I think we have to read it before we enable interrupts or use > fpregs_lock(). So reading it before saves disabling preemption later. So I'm a bit confused - there's that cond_local_irq_enable() which will enable interrupts if they were enabled before. So if they were enabled before and you reenable them here, then that current could be the wrong one if we schedule in between, right? IOW, shouldn't those two lines be swapped so that it says: tsk = current; cond_local_irq_enable(regs); and you can be sure that tsk is always the right current which caused the #CP? Or am I way off again? -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette