Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp399361rdb; Thu, 19 Oct 2023 07:40:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGApz35G7Nj4WjybYHDXAX1zLEJTEgInfKLdTZiH84iWNk91x0LuMLpwfLnQlt8uz04G9mZ X-Received: by 2002:a05:6a00:22d6:b0:6be:4909:d66a with SMTP id f22-20020a056a0022d600b006be4909d66amr2273273pfj.17.1697726451725; Thu, 19 Oct 2023 07:40:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697726451; cv=none; d=google.com; s=arc-20160816; b=to6RbQADtdHoSIiVsXDKJ+yjtVZsUWo0pQWUNjiuehZqQhvjTXDIfMIHdThzYsNVjE VW9tQ8plaGUxORU5Kz3XhRd7T5EatPdm3nD9PpNDrbzXPcebURoOSisxFLsNTH5s3cl8 5cU7Pety1iUn8vPlYlwKT8q3nJr/tal28bljXPclLKYBfvUGcE6ykgVur07J8wdqyT28 IBBdhY1m3W2mxLpBtX/IgL4QyOa+1KmqewVmAgcXuiVesY0CCVhJv8R5zkCoWg9XQdXZ sGAemqI3qZk50LzgS0CzmYgd5u+rGEdw/vmFAhHLSbjpD+eh8qNGlGCzcxzfqmzgm9AD 83WA== 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=cZwK9x89mo9GWD6pGRjp0GF65LecA8F0ra0gDgvQOAE=; fh=o7f+sCs/OEYhvPzqaa6atRkPvl9PeGSZRzOEeSlTqqE=; b=soya1rkWf+7qLqLupUgqqoMujVWyFUE3n35FPdsUN0ivasnxs0APdM2hlNb41P9/zK 1TnHC6yaR3+B/MU/tP1huyRiEPfqtYIyrxRPZmrG4Ts8GJlCY1k+xobiHHWZ7/FF/oKT 3rya9QxYFJZ4b0fwVG8m+poT2sB7Q8b/kpgP6GZxv03D9Q5uRC9z5A1MbcDInYG/ijG2 XEfK6ZE8B8DBiU3quprx39KbE4t91iXMhfFACb8ToTpRoiLHZcgqO39Me2r8JDIOB61J SC9f7Thdwwya3Nc9AIRPBQR0JcE/l5gZEIAwNYx4zpc8lYyGxlwTm6AnRGwJ+SzT9PMw G56Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=alien8 header.b=PJC66fvV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id o23-20020aa79797000000b006be246c6decsi6100217pfp.351.2023.10.19.07.40.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 07:40:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=alien8 header.b=PJC66fvV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id E37E6807753B; Thu, 19 Oct 2023 07:40:21 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346154AbjJSOkH (ORCPT + 99 others); Thu, 19 Oct 2023 10:40:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346140AbjJSOkG (ORCPT ); Thu, 19 Oct 2023 10:40:06 -0400 Received: from mail.alien8.de (mail.alien8.de [65.109.113.108]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D492D13D; Thu, 19 Oct 2023 07:40:03 -0700 (PDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with ESMTP id DC77040E0187; Thu, 19 Oct 2023 14:40:01 +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 GAEMYLTle8OJ; Thu, 19 Oct 2023 14:40:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=alien8; t=1697726400; bh=cZwK9x89mo9GWD6pGRjp0GF65LecA8F0ra0gDgvQOAE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=PJC66fvVWHut2ol07FMXyRKJ30GGYSEgxoNT4iYGoeqk0EFqrvLPTlQ2U+eixE7Wz KTvzaYeiDipWe1D0F2ARjjaSwtOmPluZ/UEc6AwtbDC9xTf2+PuiUQGZPcS+T0TpfZ osJlGC/GLswi1keBwHKflD2N1PQ+tb4Jg3JBhfo2QGoj4qFyMMMr1q8KPj8aJcxJMx jSALpIEmCzhLdCZAvzpWv7ffUcZz3aXqZticBt10z1JD0qAVXbLpeYYkaGzULC54Op D21XiBY482pLXOtIu/3QYtF4tAHka/5R3erPKl/aDqoo0SsqH/Dak2bXhkyGgOJN8E qH7xIKBgPUzwaDGz+syM/3sf9aFjmchP8BPSGAwPvCQxlDeUqNUbrZnPNsKs0XRE8Z 3/oKekt1F0T3UGwOtMvlfSRlPSPwpVwu/g5I3dFzgAAYk0NKmLYF658guhi7TQ44Rf CvtSb2t+mmfj9ACjMjdAKfwApuakt1LQMAMy1f22e28x7oLXk0mpUJqOp/kOlgHyTO ge7unMgtnetlVRct5LNSC3EoyHMkTdsQHV0RspGcG/PsrLI3MstNjPIZMQaTfKDoTI MCkrXK+CZXYg0tEONO62SsAC4Xk01JtscHpPpsAYGpAJP1704gfef44KVhEeekSzaQ MOeH4IrhBFV4n2bus4t7EIg4= 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 E505940E01AF; Thu, 19 Oct 2023 14:39:51 +0000 (UTC) Date: Thu, 19 Oct 2023 16:39:51 +0200 From: Borislav Petkov To: "Kaplan, David" Cc: Josh Poimboeuf , Ingo Molnar , "linux-kernel@vger.kernel.org" , "linux-tip-commits@vger.kernel.org" , "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: <20231019143951.GEZTE/t/wECKBxMSjl@fat_crate.local> References: <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> <20231019141514.GCZTE58qPOvcJCiBp3@fat_crate.local> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: 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 pete.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 (pete.vger.email [0.0.0.0]); Thu, 19 Oct 2023 07:40:23 -0700 (PDT) On Thu, Oct 19, 2023 at 02:21:40PM +0000, Kaplan, David wrote: > The return thunk is used for all functions though, including assembly > coded functions which may use non-standard calling conventions and > aren't visible to gcc. I think the only safe thing would be to > preserve all GPRs across the call to check_thunks. Something like > PUSH_REGS/call check_thunks/POP_REGS. That call nop will be inside the return thunk. I.e., something like this: SYM_CODE_START(__x86_return_thunk) UNWIND_HINT_FUNC ANNOTATE_NOENDBR ANNOTATE_UNRET_SAFE ALTERNATIVE CALL nop, check_thunks, X86_FEATURE_ALWAYS ret int3 SYM_CODE_END(__x86_return_thunk) EXPORT_SYMBOL(__x86_return_thunk) I suspect that gcc doesn't know that there is a function call in the asm there, which is also what you hint at - I need to ask a compiler guy. But yeah, if it doesn't, then we'll need to push/pop regs as you suggest. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette