Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp453543rdg; Thu, 12 Oct 2023 10:11:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF/PDiuzxVlGbGmzKWUmlKCwZ30sohavmAWasjuDYT251DSMfPp9agYyU9r/UkwxwvgVEny X-Received: by 2002:a17:902:9885:b0:1c6:16d3:1783 with SMTP id s5-20020a170902988500b001c616d31783mr20542237plp.58.1697130716650; Thu, 12 Oct 2023 10:11:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697130716; cv=none; d=google.com; s=arc-20160816; b=EvA/xzAosTakiVTc5htrhAKlki8J4rkJNqByRubZ2bEvOwxl0kf3vSL25LAhlRHYC3 zixjj0oQoU6CLudIZJ2w7he+UHfiBlJAvCxuOtWO9IL4pUrAOxI6Jx0aVMPktxgFSa7B zqfWLlxIANJEwvDEgVMWDOepfP6vcKfcKzppYUJTWVEqzk1CqJoaMndXvDP+R91UHgdE YqtjQNqbCcJXND8NNiEUnHL8FuSvcSaQvMkXFL7LUV9RZu3xsbS4CyMOAd1ax8k+suxy HMGNdLQRAc1ZaT+b8qMpQpt39hiiDGJYA3MqMRlEGmWsXXKDofPZ9PikGlxt/lPU0THz AlFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=O0tV8gMzTksx0sKpxJ0jkyIMJMDlTonulMIwjNnx16c=; fh=mDP7W0GpPIJVn7vWtxd+EIU+zi8Qnkpjyn6Z311Rrv4=; b=BWlDfqWBrE3/zOzaCMAC3igdAz5kbEWEcce//87Knt+vU0xYeF8cxnvE3Clw7ac7us R+FByENgHfDaISurmSzSQZK6fEUsMmjHFykFst+AMC4B0fq1JgTh7wLXRL7TlXSf5kPd iQpI3m1GkjOYR+LcgdZN+RKtInVWhyC+VoQuQ/Q4/JSIYIdf5KdAl7ROjgp7ZGacfXZV 5K3dSYuc3bH7nwLKT9NFtQ49Q/t3+WDtfAY2xc47/1qZlmH3Rd/XDTtZVdyzKWn8rOp6 O5yzHg1Eij3gTC+u11SLtpeQmP4UJJLIEa/k9dfgZ0p/3FmrHLP9MrZ9sbGTKeskZR1w HJng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=K0v2CP0R; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id l17-20020a170903245100b001c413905d87si2807772pls.49.2023.10.12.10.11.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 10:11:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=K0v2CP0R; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 71BB58289506; Thu, 12 Oct 2023 10:11:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347311AbjJLRLt (ORCPT + 99 others); Thu, 12 Oct 2023 13:11:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344032AbjJLRLs (ORCPT ); Thu, 12 Oct 2023 13:11:48 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27C3EB7 for ; Thu, 12 Oct 2023 10:11:47 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E0C7C433C7; Thu, 12 Oct 2023 17:11:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697130706; bh=VzPEcBEfGG7bzCQHi8ZBzVEsTqFFfq1QWeQDFJnhb98=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=K0v2CP0RfbHmYUisPKN1l6Z24/UD9XgfhoxOHWW3opy3RRSJL4GIsi8wjX329XcBv 1EIJTVRVwevDzcAJ7Av5ret0VPTmG3wY1tJWveQO+vx4ZItGiXm8z9zCLeJB/ZTQ5E irWltl0lVTlyMwr1gEe1odqSFk3u+sBRkRQsKX4i8StG+raljDUJ/c2RzMjneZLKqk z1Mf3REJ7emncLYgeTkx/fvkZZxf64UyIFaWjHtI8oVf3xnVqpNOoev/zY6ItsKXy2 oWuR/5uJglvZNLvqjEed8Smx33QvpTZzfWebhehCt/UV9Kq5wPi5BK+wruM244nWtR Z+qg/0oV81Bgg== Date: Thu, 12 Oct 2023 10:11:44 -0700 From: Josh Poimboeuf To: Borislav Petkov Cc: "Kaplan, David" , "x86@kernel.org" , "luto@kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH -v2] x86/retpoline: Ensure default return thunk isn't used at runtime Message-ID: <20231012171144.wtzcheq7x3qwpym6@treble> References: <20231010171020.462211-1-david.kaplan@amd.com> <20231010171020.462211-4-david.kaplan@amd.com> <20231010193643.su6iqjniuxqqke6d@treble> <20231010204119.76i7vwecmeo6ex6d@treble> <20231012141031.GHZSf+V1NjjUJTc9a9@fat_crate.local> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20231012141031.GHZSf+V1NjjUJTc9a9@fat_crate.local> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 12 Oct 2023 10:11:54 -0700 (PDT) On Thu, Oct 12, 2023 at 04:10:31PM +0200, Borislav Petkov wrote: > On Tue, Oct 10, 2023 at 01:41:19PM -0700, Josh Poimboeuf wrote: > > Even if it's not a security hole, I'd still view it as a major BUG() as > > it would directly contradict our understanding (and the comments above) > > and could cause performance or other correctness issues that would > > otherwise go unnoticed. > > > > So I think an unconditional UD2 is warranted. > > Before David's outlook mangles v2, lemme send it from a real mail > client :-P. > > v2 uses X86_FEATURE_ALWAYS as Josh requested. > > --- > From: David Kaplan > Date: Thu, 12 Oct 2023 08:52:32 -0500 > Subject: [PATCH] x86/retpoline: Ensure default return thunk isn't used at runtime > > All CPU bugs that require a return thunk define a special return thunk > to use (e.g., srso_return_thunk). The default thunk, > __x86_return_thunk, should never be used after apply_returns() > completes. Otherwise this could lead to potential speculation holes. > > Enforce this by replacing this thunk with a ud2 when alternatives are > applied. Alternative instructions are applied after apply_returns(). > > The default thunk is only used during kernel boot, it is not used during > module init since that occurs after apply_returns(). > > Signed-off-by: David Kaplan > Signed-off-by: Borislav Petkov (AMD) Reviewed-by: Josh Poimboeuf -- Josh