Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp296079lqg; Thu, 11 Apr 2024 03:17:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWi83dFXAjGe/NGUbRPaJQxWfqDX5Si1slZ/YxDMiqh7lnQwxS8tSVP+PN6ysti2ZLfjg9ojxmbKq4SUZFo6B5/QrWUb2T3qzo3W04PQw== X-Google-Smtp-Source: AGHT+IG2cFpFKtAtm24UQOdSh5amTGbGWqvaO3IwwsWgvLuW39T/IEWGxdmD7sXt5ifTPAwvOLTK X-Received: by 2002:a05:6a00:10c9:b0:6ed:41f4:1886 with SMTP id d9-20020a056a0010c900b006ed41f41886mr2811581pfu.8.1712830672742; Thu, 11 Apr 2024 03:17:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712830672; cv=pass; d=google.com; s=arc-20160816; b=OOOcz+U4V5xDAkXjWDIR9DPzs8d7kTa0vuPBq6wqUOHWJOhfZzklIjsEv4MetBgVBI 0GpgnBew3SljNxCu4fUBsDyMy/IBsmmVea6no9xYAKycByUw826uidxMH90kn+fK14PW 0d2JpTq1Fv/Wq3b7KDtgIFHp5hnIsMvIIaLJ8+ysOE4YXQ2TYrdOGVd133QkhPLgmxKh XLHiOHWW+fdKYTqTpdG1hcXQeWMhuOtBFMN6BcPh9sdVEm5a7HRLg3bwbQpBplsOASmG jF59Cj1i2RCHY/PuaqyNxQeC+xawyKW6ySUngHErDOlbgdgUBx3n4bU9dCAdkPRMgOtT TZFQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=Foy9WqKERvjhgUhaW1/uCkkkVxAcBiEx95BrDWa5sqI=; fh=w5B2SRupPaAk6pgTTP3JnOYGqQqtR05cDvTlCBpT9aM=; b=Y1QVnxwCAh6lUeIOPI734RanOPa449sejUp1f9J2YnnVCcpHBFcngn6iUbeTZy82nm 6ZUa5eavmtZ2q8UD6H5ErkoYo1KNXx8vXNOo5/OVaUuG3Q/qfZGIca9Wl1yACU3yaruk JPJwH4P5kctdVgkpcddRNHMCwzOqGsdNA+YF8WhKxj/qQZXD7O/ndGEJqeMsQS7jw4W3 j8AwmGIfsSqRm2zoyEZ+52BTMLao+YODPpY/4e8yEgNhy4UxNNympotUlzewpeRXTSVZ 465bnQC19e4SmNDXIjLSbcc6TqT5TwhTeaS5ZAAf575tb/+IEdO23QwaVv3MaKaWLSht 6Tew==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@citrix.com header.s=google header.b=GEEV72jt; arc=pass (i=1 spf=pass spfdomain=cloud.com dkim=pass dkdomain=citrix.com dmarc=pass fromdomain=citrix.com); spf=pass (google.com: domain of linux-kernel+bounces-140221-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-140221-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=citrix.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id i5-20020a63cd05000000b005e2a306df29si1021557pgg.21.2024.04.11.03.17.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 03:17:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-140221-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@citrix.com header.s=google header.b=GEEV72jt; arc=pass (i=1 spf=pass spfdomain=cloud.com dkim=pass dkdomain=citrix.com dmarc=pass fromdomain=citrix.com); spf=pass (google.com: domain of linux-kernel+bounces-140221-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-140221-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=citrix.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id F0AE6B26617 for ; Thu, 11 Apr 2024 10:06:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 77600145B06; Thu, 11 Apr 2024 10:06:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="GEEV72jt" Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8EF01448F3 for ; Thu, 11 Apr 2024 10:06:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712830002; cv=none; b=UKjuhcyX06sP760+rD55kFOOhdGHNC49u7qeYbCRnbZjmfmRISMiMZY+ZUfheQQPL+sGMazmVEmyzEgkFPAZfAGSbPgIkI/oMu4egNqUEHoDknBhMscAqVgj4nQS4hfdtS5pR1IyDQfQov9Gm8j9GbFCYxJ7j/xtEifr28ZqVOw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712830002; c=relaxed/simple; bh=bPpAIuWgLmcnLIqq/BO9qElKeo19XgGZ6Za3XfyGvZw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=hf/L99j0tp7EGbZccia/Zx16JOybbn0mAPj/lA5I7wAOBX/sMrb4INYiFm3pky3WcSDETSk0m15dEhM7qvrj823EyFpkEFPP8nWFUwgIZ/pzclBjzDjrmykc9cvtrobLVUJYGgcKmuI2zbCkNhWRuUPjI6eySINvxSvtb+um0eU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=citrix.com; spf=pass smtp.mailfrom=cloud.com; dkim=pass (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b=GEEV72jt; arc=none smtp.client-ip=209.85.218.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=citrix.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cloud.com Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-a44665605f3so850067266b.2 for ; Thu, 11 Apr 2024 03:06:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1712829999; x=1713434799; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=Foy9WqKERvjhgUhaW1/uCkkkVxAcBiEx95BrDWa5sqI=; b=GEEV72jta1aJ9H3AMhfLQFQnTjRgrNOikSdTRZdJdIJQUmJXwzlxAExJNJ6+khBuh6 Xhuw8P6qDa8/fZK96lcTBBa2S+d78NgTqf+vPvhzDaX04B1kjpwoaDTRcWqn6+Kad7ge 34j0aM+U/8IykCwVqkprLS2i54Rkxpsh62v3k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712829999; x=1713434799; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Foy9WqKERvjhgUhaW1/uCkkkVxAcBiEx95BrDWa5sqI=; b=im7AzUvsVwnS1NUSUhPrQWlfgvbAZ8XEHBOSJnbrJC7PQgYPq9DEUdfkDUJ+/4Q8gy ChcBtKcf1IEvntaRTaXLMgWEYaPKAhVL0EDWhFpwx5BDcjVQfhnG6XYkE5V6gdqJyY4e 5j7HPgIHON83a/1OTDaz1JpxAcqMfcEi6iUEGLUUiK+yEDmi0Q+0UINw4ZRiDSBEJIr5 jhaLlpLr5FjZTtTbiuKtZxZrpFW+LQ27k80SfaLDZSnjCnJWzr/QibIg30igsq+laqfV uiqVzk8hXEc0c6K5PG386RiXioAQkRWxi3sRYMAl0KVPaZOXKwSuojYeQmzBlZuPTQ7m wYow== X-Gm-Message-State: AOJu0YxCLn0M5pf8bGhqGSupCIUyvvUAdL94shbwwJudBog5kygGpFua fVUM/4dDWUN8xPhzRpW3MlOWzKcAHPeNCZKJYA8dZ3ZRlkTgCW4CoGLlgNEP7Fs= X-Received: by 2002:a17:906:11c6:b0:a51:ff7e:7a7 with SMTP id o6-20020a17090611c600b00a51ff7e07a7mr2969237eja.31.1712829999149; Thu, 11 Apr 2024 03:06:39 -0700 (PDT) Received: from [10.80.67.140] (default-46-102-197-194.interdsl.co.uk. [46.102.197.194]) by smtp.gmail.com with ESMTPSA id wg5-20020a17090705c500b00a4e2db8ffdcsm605845ejb.111.2024.04.11.03.06.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 11 Apr 2024 03:06:38 -0700 (PDT) Message-ID: <90405c43-daca-48e4-b424-d66d6bf4dd87@citrix.com> Date: Thu, 11 Apr 2024 11:06:37 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 5/7] x86/bugs: Only harden syscalls when needed To: Josh Poimboeuf , x86@kernel.org Cc: linux-kernel@vger.kernel.org, Linus Torvalds , Daniel Sneddon , Pawan Gupta , Thomas Gleixner , Alexandre Chartre , Konrad Rzeszutek Wilk , Peter Zijlstra , Greg Kroah-Hartman , Sean Christopherson , Dave Hansen , Nikolay Borisov , KP Singh , Waiman Long , Borislav Petkov References: <97befd7c1e008797734dee05181c49056ff6de57.1712813475.git.jpoimboe@kernel.org> Content-Language: en-GB From: Andrew Cooper Autocrypt: addr=andrew.cooper3@citrix.com; keydata= xsFNBFLhNn8BEADVhE+Hb8i0GV6mihnnr/uiQQdPF8kUoFzCOPXkf7jQ5sLYeJa0cQi6Penp VtiFYznTairnVsN5J+ujSTIb+OlMSJUWV4opS7WVNnxHbFTPYZVQ3erv7NKc2iVizCRZ2Kxn srM1oPXWRic8BIAdYOKOloF2300SL/bIpeD+x7h3w9B/qez7nOin5NzkxgFoaUeIal12pXSR Q354FKFoy6Vh96gc4VRqte3jw8mPuJQpfws+Pb+swvSf/i1q1+1I4jsRQQh2m6OTADHIqg2E ofTYAEh7R5HfPx0EXoEDMdRjOeKn8+vvkAwhviWXTHlG3R1QkbE5M/oywnZ83udJmi+lxjJ5 YhQ5IzomvJ16H0Bq+TLyVLO/VRksp1VR9HxCzItLNCS8PdpYYz5TC204ViycobYU65WMpzWe LFAGn8jSS25XIpqv0Y9k87dLbctKKA14Ifw2kq5OIVu2FuX+3i446JOa2vpCI9GcjCzi3oHV e00bzYiHMIl0FICrNJU0Kjho8pdo0m2uxkn6SYEpogAy9pnatUlO+erL4LqFUO7GXSdBRbw5 gNt25XTLdSFuZtMxkY3tq8MFss5QnjhehCVPEpE6y9ZjI4XB8ad1G4oBHVGK5LMsvg22PfMJ ISWFSHoF/B5+lHkCKWkFxZ0gZn33ju5n6/FOdEx4B8cMJt+cWwARAQABzSlBbmRyZXcgQ29v cGVyIDxhbmRyZXcuY29vcGVyM0BjaXRyaXguY29tPsLBegQTAQgAJAIbAwULCQgHAwUVCgkI CwUWAgMBAAIeAQIXgAUCWKD95wIZAQAKCRBlw/kGpdefoHbdD/9AIoR3k6fKl+RFiFpyAhvO 59ttDFI7nIAnlYngev2XUR3acFElJATH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NNYjgbbmML7y0fsJT5RgvefAIFfHBg7fTY/i kBEimoUsTEQz+N4hbKwo1hULfVxDJStE4sbPhjbsPCrlXf6W9CxSyQ0qmZ2bXsLQYRj2xqd1 bpA+1o1j2N4/au1R/uSiUFjewJdT/LX1EklKDcQwpk06Af/N7VZtSfEJeRV04unbsKVXWZAk uAJyDDKN99ziC0Wz5kcPyVD1HNf8bgaqGDzrv3TfYjwqayRFcMf7xJaL9xXedMcAEQEAAcLB XwQYAQgACQUCUuE2fwIbDAAKCRBlw/kGpdefoG4XEACD1Qf/er8EA7g23HMxYWd3FXHThrVQ HgiGdk5Yh632vjOm9L4sd/GCEACVQKjsu98e8o3ysitFlznEns5EAAXEbITrgKWXDDUWGYxd pnjj2u+GkVdsOAGk0kxczX6s+VRBhpbBI2PWnOsRJgU2n10PZ3mZD4Xu9kU2IXYmuW+e5KCA vTArRUdCrAtIa1k01sPipPPw6dfxx2e5asy21YOytzxuWFfJTGnVxZZSCyLUO83sh6OZhJkk b9rxL9wPmpN/t2IPaEKoAc0FTQZS36wAMOXkBh24PQ9gaLJvfPKpNzGD8XWR5HHF0NLIJhgg 4ZlEXQ2fVp3XrtocHqhu4UZR4koCijgB8sB7Tb0GCpwK+C4UePdFLfhKyRdSXuvY3AHJd4CP 4JzW0Bzq/WXY3XMOzUTYApGQpnUpdOmuQSfpV9MQO+/jo7r6yPbxT7CwRS5dcQPzUiuHLK9i nvjREdh84qycnx0/6dDroYhp0DFv4udxuAvt1h4wGwTPRQZerSm4xaYegEFusyhbZrI0U9tJ B8WrhBLXDiYlyJT6zOV2yZFuW47VrLsjYnHwn27hmxTC/7tvG3euCklmkn9Sl9IAKFu29RSo d5bD8kMSCYsTqtTfT6W4A3qHGvIDta3ptLYpIAOD2sY3GYq2nf3Bbzx81wZK14JdDDHUX2Rs 6+ahAA== In-Reply-To: <97befd7c1e008797734dee05181c49056ff6de57.1712813475.git.jpoimboe@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 11/04/2024 6:40 am, Josh Poimboeuf wrote: > diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c > index 6de50b80702e..80d432d2fe44 100644 > --- a/arch/x86/entry/common.c > +++ b/arch/x86/entry/common.c > @@ -39,6 +39,28 @@ > > #ifdef CONFIG_X86_64 > > +/* > + * Do either a direct or an indirect call, depending on whether indirect calls > + * are considered safe. > + */ > +#define __do_syscall(table, func_direct, nr, regs) \ > +({ \ > + unsigned long __rax, __rdi, __rsi; \ > + \ > + asm_inline volatile( \ > + ALTERNATIVE("call " __stringify(func_direct) "\n\t", \ > + ANNOTATE_RETPOLINE_SAFE \ > + "call *%[func_ptr]\n\t", \ This wants to be a plain maybe-thunk'd indirect call, and without the ANNOTATE_RETPOLINE_SAFE. Or you're going to get into cases where some combinations of command line options do unexpected things e.g. retpolining everything except the syscall dispatch. ~Andrew