Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp382263rdb; Thu, 19 Oct 2023 07:16:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEsck/DNHTevKaeIqxJpvk9fjxa/Pr6Fb0QrD5CZGR9baj/uKUj0PJ2jbxU1xX0xeMBsYgK X-Received: by 2002:a17:902:fb0e:b0:1c9:d61a:f4a4 with SMTP id le14-20020a170902fb0e00b001c9d61af4a4mr2245326plb.60.1697724960809; Thu, 19 Oct 2023 07:16:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697724960; cv=none; d=google.com; s=arc-20160816; b=pIjUOit0P2FmrD/wY+bbMnxSu916XrTJFSKz9jprFQFknZb/aBM5gFKPpbSghrjGlZ U7b75ItUWC416HWPZIGbLpHxonj06CLSHOJucYeygFd36e8cdcCUCNcoPNWxsb5a//IN tZINOuzeI5Stvm9QD3wu+OPUSguZ2gSy6+neLEl0Rusl88GEzwzrVZKj5QhpzWkXH+X7 1UeAktgsjlpAzBTZhTbxbeYNtLMK8MbDHC7ivSN7HPCn3Q2jC7LnQWNlYUJaiiaE1CsK MyqZSNg9D2YIPUrZ37EGqsKkAei9QiEqYD5RFWOtaCaDg9XKlhhKqQc5PL8iBWbqCp7H crkQ== 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=AvTen/Ml62tmp1Mem7EkFWKLUmw/SFRMP/MUyGnMe9g=; fh=5gNLRMoM+s8WeQuR3TP9hM4p8gAa8/bjMP4LRT++uhg=; b=P1MDFc9pA9KDE/mPg9uzq/T8+fTDntGW+NW3+KWDOqw3jqlIVdo8PQprQEpGslrXhw IpPbLSlAYpXTbvp4umZuPfRE6YnhDn/itHIuKiU1klOTk6N1S/zZQ8G9UMYb3VKUsMw0 V6yjXUP57VijX+tgIE7W50bOc8FtGDB7q7PtZcj4h1iIn9lCnmCz931FS28CdYRjUzQ+ mVGdpBYPxL/XbarXAMEfjvwCh6lUjBWvyIqcJzhhqmr+T8glT+S35ejKYGsw6nMEbOoV cFSiSL0PabtTrn8PmiHYVLXCixrJRzkICxJjRUwFqJpB6qAE4C7iUY3jwvIy10sOQs2x bi9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=alien8 header.b=HePWEr8r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id e13-20020a17090301cd00b001c9d4d2460fsi2536735plh.30.2023.10.19.07.16.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 07:16:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=alien8 header.b=HePWEr8r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 9E9C6810AF56; Thu, 19 Oct 2023 07:15:48 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345828AbjJSOPh (ORCPT + 99 others); Thu, 19 Oct 2023 10:15:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345672AbjJSOPf (ORCPT ); Thu, 19 Oct 2023 10:15:35 -0400 X-Greylist: delayed 71571 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 19 Oct 2023 07:15:32 PDT Received: from mail.alien8.de (mail.alien8.de [IPv6:2a01:4f9:3051:3f93::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC843126; Thu, 19 Oct 2023 07:15:32 -0700 (PDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with ESMTP id AB51C40E01B1; Thu, 19 Oct 2023 14:15:30 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at mail.alien8.de Authentication-Results: mail.alien8.de (amavisd-new); dkim=pass (4096-bit key) header.d=alien8.de Received: from mail.alien8.de ([127.0.0.1]) by localhost (mail.alien8.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id yc603s0_Sao9; Thu, 19 Oct 2023 14:15:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=alien8; t=1697724928; bh=AvTen/Ml62tmp1Mem7EkFWKLUmw/SFRMP/MUyGnMe9g=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=HePWEr8ratskmxLmxjDUBwmb08QxisK8uWR2d/H5KInbJN7W2FsE+NQ4U++nrVRRg veCuoIUyFsI8j4+fF1KLimIhctX1o+ng/xFN9RajYP0O5H4oeo8W5vfdgvvXhATfph yNO/xgiCLH6voylP8XQfeIG8xMyNCaedsVcNiGsErVMVylpZtOluqSC6W6dFGHbMvr BqAhAzexrnQuK/1j2Sd8+wCwKt3TUEizI/Mn2KfaodihT3Sx10T4Hotm/RjH5b9fhN ECAMDY84eF/HX3ALFfTVtdSXvDZucuLYdiY8veFIHS7k1xdkIgEex5oaiSOF/8R1LA 7sqOaM0mQHK391seRHJljQUCGVRJtj0rt5CAzXYEdy484afIJOXq7rZjH00oakTNDC M8NoOjOggbOdbea/tsMRHUO3PtRfwhPquPpsehoLQvUvwbm2BqmaPul23NtjIJyBIl 0mu97YMUKJvEfX6KjppHQLI3FCvk9MF0eSBNKXK5h5X3aCdUL4lshdsIGmExVzK8jN NI6RWB5XWcrxLYgHKl5P5VT/QJBC6jP5GMOu5vH64F/6NX3QI775AsD6GsrOGMiSON /L1PHi3czxH7s2Jvz8f4OgUZ8tehxO+X9er0ix16KS9n50D9uMyqBwFvJvz4fDmw1e frs/VbH800iqRQEzq69AnGiw= Received: from zn.tnic (pd95304da.dip0.t-ipconnect.de [217.83.4.218]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 034BD40E0196; Thu, 19 Oct 2023 14:15:19 +0000 (UTC) Date: Thu, 19 Oct 2023 16:15:14 +0200 From: Borislav Petkov To: Josh Poimboeuf Cc: Ingo Molnar , linux-kernel@vger.kernel.org, linux-tip-commits@vger.kernel.org, David Kaplan , "Peter Zijlstra (Intel)" , x86@kernel.org, David Howells Subject: Re: [tip: x86/bugs] x86/retpoline: Ensure default return thunk isn't used at runtime Message-ID: <20231019141514.GCZTE58qPOvcJCiBp3@fat_crate.local> References: <20231012141031.GHZSf+V1NjjUJTc9a9@fat_crate.local> <169713303534.3135.10558074245117750218.tip-bot2@tip-bot2> <20231018132352.GBZS/caGJ8Wk9kmTbg@fat_crate.local> <20231018151245.GCZS/17QhDGe7q6K+w@fat_crate.local> <20231018155433.z4auwckr5s27wnig@treble> <20231018175531.GEZTAcE2p92U1AuVp1@fat_crate.local> <20231018203747.GJZTBCG7mv5HL4w6CC@fat_crate.local> <20231019063527.iwgyioxi2gznnshp@treble> <20231019065928.mrvhtfaya22p2uzw@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20231019065928.mrvhtfaya22p2uzw@treble> X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,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 groat.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 (groat.vger.email [0.0.0.0]); Thu, 19 Oct 2023 07:15:49 -0700 (PDT) On Wed, Oct 18, 2023 at 11:59:28PM -0700, Josh Poimboeuf wrote: > One last idea, since the return thunk is used everywhere (even non-ABI > compliant functions) it might be possible the "call check_thunks" (and > its call to warn_printk) is clobbering some registers which some code > (exception handling entry code?) doesn't appreciate. Yeah, that is still unclean, I'd say. gcc doesn't know that we patch in a CALL insn in the alternative. What should work is to have alternative_call there which alternates between two calls and gcc knows there's a call so it can act accordingly wrt callee-* regs. Considering how __x86_return_thunk is there only until alternatives have run, we could do something like ALTERNATIVE_CALL nop, check_thunks where nop is a function which doesn't do anything. I say "ALTERNATIVE_CALL" because we don't have a _CALL asm macro yet. And then in check_thunks() we can do all kinds of screaming, tainting and setting mitigation status to vulnerable, etc. Anyway something along those lines. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette