Received: by 2002:ab2:7041:0:b0:1f4:bcc8:f211 with SMTP id x1csp48612lql; Fri, 12 Apr 2024 03:25:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXJ6C+kMMmlpnq+XDEol310uZKavlsN5CO+FDtgrjlozArq8mg8srHDrah6gHuRZ69169/sH4WYaFjnswVqQy/qVnouoHg5RtnrOJ/fJQ== X-Google-Smtp-Source: AGHT+IGFxGyLUdnemNpuq7dgC9Jkfji2Vit/A5Q5/mclaBvQPcZhXmz96QyXEyFYaXTn/moXUwoL X-Received: by 2002:a05:620a:b84:b0:78d:5afc:eeec with SMTP id k4-20020a05620a0b8400b0078d5afceeecmr1943217qkh.20.1712917507028; Fri, 12 Apr 2024 03:25:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712917507; cv=pass; d=google.com; s=arc-20160816; b=N57MN6QHfGa67+bTL5hNm2sSWK6ogGY7uW8tkVYMOzMSRmEJ203/EzoerR0Myij3t7 JG+OYT+aQw6RXCwk7f6TVRlKjzMlXbEWBaublqz18gb5PaLdX55kdGMbFBPRwz1ZmHQA T101WjBUU1rRIuncqj9GpCyobGGJtsBniy59O/UXMGyqoJZ9cfNelOzoDKu2GuSkuuOk EG4X8gxmwC4ELksy+lKARdVt8wS79jYaPc/gytk+qpJJjD7hu6zSb2+XIiHeBCp/KkZz hIq3vY/OO4Ps23xNgYfjlYKCrBQE3NUobB1YWCrywm2INFeLWymn0goc4omYT7UpvZ5Z jl/w== 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=yXjVQsLqyM7W96iPN2njoIot7m3tPecpIfZcOMPHqes=; fh=GBUQYUfYiGnw7yM56/9wmvL/ge1HC07pdRgOP6mTbdk=; b=a63zsoIaZlO+qAm+g/3J5qXNtpQ6JeFI8ooVwZtItcyXMcflUvJaU378AgzR+8WnDb jpxvPSIP3R8a7eE8vtxbxWJdNGCspBYiDqAgAnJg7sKnkEmDXe21d6UW7VgPvm8AzhaF FTmCXFLpR6758w0s06GWAZh4r6rhKF+9z/lAoqN8F4Gp5OspMqTHO8cgJtwTfSv7ylAk yfUxLPMudUrcblT/8+8ZobTJ5O7PEzZwHELmb00dco+hCw8yZ0YFgI2P5ZHMJvksIv21 Uuwyq1CBskVCnzWuiXKTX3CwVWJ3mu7XJY1Ee1TB+L1K/RwsWhEluqkqcYLdPE57W5vr j5nA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@citrix.com header.s=google header.b=iOXyIG1O; 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-142491-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142491-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=citrix.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id t27-20020a05620a035b00b0078a1e52cbb3si3417358qkm.301.2024.04.12.03.25.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 03:25:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-142491-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@citrix.com header.s=google header.b=iOXyIG1O; 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-142491-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142491-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id B50C21C2172D for ; Fri, 12 Apr 2024 10:25:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 14F6153816; Fri, 12 Apr 2024 10:25:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="iOXyIG1O" Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) (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 9D0904A29 for ; Fri, 12 Apr 2024 10:24:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712917500; cv=none; b=tOC+AhoZLf4KmG5Uhc/n8ebYhdD6iNMllmB606tZbF0Q1efu+XrYWssjo584qkiV1pWi5U0/VI09qOjm9z/Yi8kZT2smW4TEhzbXT/eUinfMmX8vW2wdsyK6DHHtNAAJ1leIcymElyONn/o/1lp5CDlRZ6SN1szN54PCSsta8yg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712917500; c=relaxed/simple; bh=mTije8i7p8SYTaRp24DV1G8IgwrSNJqgcNiym+vSaCw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=fmy8ygGvlOgRCr/2oIoecd0fNCnTTH4yjKJln0BlyRFJGtL6c1ezXEuvSP6x1P54TPw/uWcdtadm55hEAAGy1/1Z2KgzoIEgqCImWuDJ623x3x8+Vm9PfPsk5Arg19uc5IOXHPLlvB7kjjMdMfiWFafVa1LbKddHcPCMfHmPQ74= 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=iOXyIG1O; arc=none smtp.client-ip=209.85.222.182 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-qk1-f182.google.com with SMTP id af79cd13be357-78ec0d2e1e9so32772785a.3 for ; Fri, 12 Apr 2024 03:24:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1712917497; x=1713522297; 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=yXjVQsLqyM7W96iPN2njoIot7m3tPecpIfZcOMPHqes=; b=iOXyIG1OHyqnAZaQ/p7AXXNqRpnsnQ9ivTdRO6jdBZ5BLsrtu5ttTuKBv3okmplddQ JmmBevMnOkR9z7Wvkzsukt5vFtC5zeXPnyQo7itzLyGAXSthkfq6S+BvXtySWmWlx9K+ J2xEPAO5lgxBO55EEDEaUmEajDAcXuNicAr4c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712917497; x=1713522297; 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=yXjVQsLqyM7W96iPN2njoIot7m3tPecpIfZcOMPHqes=; b=JWuSByrkrcCU2Bae/6dayew0sElDrVsMy1kYen8RZD11qdh6/wFUWajn31sRqP15/a kZaMe6udEniznZIFVsAbP6XzHCPXoZvSQIq/AbYqPeA4vAFLQkUyuzLnz6Frr8xWQjpG 5mUMvLW9F0kNY0LQiz23bqpSllhAOhKBnaSC1UtDTJW4iWJ2JuaBdlCjX0D7qNq10oP/ WEOJTgcXsxx+ueQf2Tod2pJZC2JjSaU+vjLLN8FWAZkLicgTMGah999efAJWbsHCLjaH f9h9wEvTybsmsjHO7whS631uJxEKGxLJcU9jPA9hQEUYq9AwgPFFU9fiMf3+fkKOCaVP +K/Q== X-Forwarded-Encrypted: i=1; AJvYcCXCUNtrmvzhnV5zdwXe2pMJluq2+mVzhagN4untJ3JePKwWClfvx0GMcq7PKb+fRmgcHAa16jt+ApBakzm56czF/xRii0Iw08DaSLVS X-Gm-Message-State: AOJu0Yz7tQ7B6jU4IvS4uEiNXYM7Mimk+8DKJg16iFoAPn8yfFf9/Xji PNAkaUAd/LHZLEbf2LdadDV58qwOyOUgp4iBQQJgAkGg9pR/HBguh+14eM0br3E= X-Received: by 2002:a05:620a:5dce:b0:78d:68de:e3ac with SMTP id xy14-20020a05620a5dce00b0078d68dee3acmr2029293qkn.76.1712917497479; Fri, 12 Apr 2024 03:24:57 -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 m14-20020a05620a220e00b0078d61011c6fsm2219918qkh.6.2024.04.12.03.24.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 12 Apr 2024 03:24:56 -0700 (PDT) Message-ID: <323fbfe5-ad21-4606-93c7-d3ad6bbc8620@citrix.com> Date: Fri, 12 Apr 2024 11:24:53 +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 Cc: x86@kernel.org, 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> <90405c43-daca-48e4-b424-d66d6bf4dd87@citrix.com> <20240411153841.zexbsqrdli54kiez@treble> 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 cGVyIDxhbmRyZX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tTfT6W4A3qHGvIDta3ptLYpIAOD2sY3GYq2nf3Bbzx81wZK14JdDDHUX2Rs 6+ahAA== In-Reply-To: <20240411153841.zexbsqrdli54kiez@treble> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 11/04/2024 4:38 pm, Josh Poimboeuf wrote: > On Thu, Apr 11, 2024 at 11:06:37AM +0100, Andrew Cooper wrote: >>> +#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. > In that case won't X86_FEATURE_INDIRECT_SAFE get cleared, resulting in > the above using a direct call? Or did I miss something? That works until the next time anyone touches the logic.  Then it's latent vulnerability, or an incorrect trial of a non-default option. I guarantee you'll save someone (probably someone on this CC list) a headache in the future by not introducing an unnecessary special case here. ~Andrew