Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1543623imm; Tue, 2 Oct 2018 09:50:57 -0700 (PDT) X-Google-Smtp-Source: ACcGV61e2aWnynKJjxEWf5xJ85opik/tRj53M4fROV0stvAgWCLbaRk/7RVG/ifnKIKkBiwB/Bwt X-Received: by 2002:a63:4384:: with SMTP id q126-v6mr15221856pga.142.1538499057240; Tue, 02 Oct 2018 09:50:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538499057; cv=none; d=google.com; s=arc-20160816; b=Gz8Tmj3In1HOKH7b5DAhhQ/eAmK8XOe1zGdUl3jv3aMzrWiqZ+qxPF/n54kEMzRIrF Z709vVhf7BNZ+1bT400j44RthWlE8opc7ediCFqwn2hu47QnqJ7/XeQijZyWFka9It0d GkAQTqDGQokEZTgnd4JB2dtn9Wgy35Ek02gN0rmUcQPkT0sj1BVuw8A5yLUO3LOU0nSA d3ru/IT3342P81F28BCPbepqBpGlZO2wbsZZNLjW1vx+Z7XKfqRzw7ck+ybxz7zMrEzI /duGEtVXN9ULctwHylm1aQNwzlZQlsgd0Cglo8NJu4RoTycLRDE7RGFZtuZAS82W7ZBC Bulg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:subject:autocrypt:openpgp:from:references:cc:to; bh=ElwcrjIEeIESwH2jnvMF5yd4bpV235zYK6JhEWK2rck=; b=fCu231t23kmx2A8LyAq5iGG2obNd0xueXabw8/tghK/NShoT/8Dtmm/i1ifJ4opg1I +XrnjHNPbqA9U8uNL64qOtp7E4KU2XayuHvvw72mL/IA0CdLpyRyZiNbn7PyK8aRJzPM uHL9myJxSH4CjTGD/rWX61YpFM6FtD6eqLzjUPOC1K8QXtt4I8vAAU7hqEfcN4gKrdIG DqxgpmZadDmH+IPvvzSMI0O1y2+5kVxp5TZ19JXim2ZjPTufdDahJV7O5auWUDPHLaW2 FBaN/WyVpHVXeCAMg8OmCQTAwozjY5DTZg5Jb42gVx/rTisFwkjqQUMTiq5QJrLEUf7h QaqA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v128-v6si16923286pfc.193.2018.10.02.09.50.42; Tue, 02 Oct 2018 09:50:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729567AbeJBXIY (ORCPT + 99 others); Tue, 2 Oct 2018 19:08:24 -0400 Received: from mga06.intel.com ([134.134.136.31]:54080 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727351AbeJBXIY (ORCPT ); Tue, 2 Oct 2018 19:08:24 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Oct 2018 09:24:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,332,1534834800"; d="scan'208";a="237895489" Received: from schen9-desk.jf.intel.com (HELO [10.54.74.144]) ([10.54.74.144]) by orsmga004.jf.intel.com with ESMTP; 02 Oct 2018 09:24:13 -0700 To: Ingo Molnar Cc: Jiri Kosina , Thomas Gleixner , Tom Lendacky , Ingo Molnar , Peter Zijlstra , Josh Poimboeuf , Andrea Arcangeli , David Woodhouse , Andi Kleen , Dave Hansen , Casey Schaufler , Asit Mallick , Arjan van de Ven , Jon Masters , linux-kernel@vger.kernel.org, x86@kernel.org References: <20181002092328.GA122128@gmail.com> From: Tim Chen Openpgp: preference=signencrypt Autocrypt: addr=tim.c.chen@linux.intel.com; prefer-encrypt=mutual; keydata= xsFNBE6ONugBEAC1c8laQ2QrezbYFetwrzD0v8rOqanj5X1jkySQr3hm/rqVcDJudcfdSMv0 BNCCjt2dofFxVfRL0G8eQR4qoSgzDGDzoFva3NjTJ/34TlK9MMouLY7X5x3sXdZtrV4zhKGv 3Rt2osfARdH3QDoTUHujhQxlcPk7cwjTXe4o3aHIFbcIBUmxhqPaz3AMfdCqbhd7uWe9MAZX 7M9vk6PboyO4PgZRAs5lWRoD4ZfROtSViX49KEkO7BDClacVsODITpiaWtZVDxkYUX/D9OxG AkxmqrCxZxxZHDQos1SnS08aKD0QITm/LWQtwx1y0P4GGMXRlIAQE4rK69BDvzSaLB45ppOw AO7kw8aR3eu/sW8p016dx34bUFFTwbILJFvazpvRImdjmZGcTcvRd8QgmhNV5INyGwtfA8sn L4V13aZNZA9eWd+iuB8qZfoFiyAeHNWzLX/Moi8hB7LxFuEGnvbxYByRS83jsxjH2Bd49bTi XOsAY/YyGj6gl8KkjSbKOkj0IRy28nLisFdGBvgeQrvaLaA06VexptmrLjp1Qtyesw6zIJeP oHUImJltjPjFvyfkuIPfVIB87kukpB78bhSRA5mC365LsLRl+nrX7SauEo8b7MX0qbW9pg0f wsiyCCK0ioTTm4IWL2wiDB7PeiJSsViBORNKoxA093B42BWFJQARAQABzTRUaW0gQ2hlbiAo d29yayByZWxhdGVkKSA8dGltLmMuY2hlbkBsaW51eC5pbnRlbC5jb20+wsF+BBMBAgAoAhsD BgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAUCWfPBPgUJDyfxUQAKCRCi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AUCWfPBJQUJDyfxOAAKCRCi Z7WKota4SZKQD/wLu3j8kgATic+wF3ekngjwPcW3JhbQJeHxUZwsb9OgVMHumlrZHGoltKQu FfAhG/sOfuAh5f7QMzzA1M+2JD1Q6lr74vUHNBu+xBFMgZstE6hpkKmn0pNZ5JS3iZRVRLBx dWw63DYr0GM80vmbHjAhwxoF2PsO2/PkWTc68+pFyl3Dy0heZSJii81hkzh8FnF8CaMH0VXu MJoWyuYgnC058hHj0QqXvlNx9LzMtmrsskTmPvwqXTgG/dTEfTkQ4RfX3enrBy55cg9tMc88 BEQ/0/JV1bCDwyWXKRpz6FsHbICGQ4G9TTD4pS5QJ+oRQccMjfiDM3rFTcG1RYP2lHXjSm9c 0VnimpQBz3LarrdHJilmTHbAWf5KLmtWfYXHrlncnhnCtw2nfwBBdy8cQW4tUyniSVRLOwGm eJziyuPJ5SVVZcil2oN5/o7js7BYAeAV/WVF2Sk/blnXaaObIYIVqnDhV4N0oUz1KXq1Leem Uvjo5rljmmhOBdgl6D0scXCWICbuuWN9eW2fZl38hBSI3M0MX0jnV2e+0FY+76iNmKadpTDw gY3OaQAZ/UlJVI+pRV4JtRrajtpo9Vb38SBPXwp9moWmwVQyIdFUXjCTQARvxjRsUoPVu9oA SCd9W74oOgrqC1hadvVU867d07PlWksfYwCeYP4bs+4GSLzI1w== Subject: Re: [Patch v2 1/4] x86/speculation: Option to select app to app mitigation for spectre_v2 Message-ID: <26675a26-a4b4-a148-2e3a-1c29432119b2@linux.intel.com> Date: Tue, 2 Oct 2018 09:24:12 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0 MIME-Version: 1.0 In-Reply-To: <20181002092328.GA122128@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/02/2018 02:23 AM, Ingo Molnar wrote: > > * Tim Chen wrote: > >> Subject: x86/speculation: Option to select app to app mitigation for spectre_v2 >> > > We prefer to start commit titles with verbs, not nouns, so this should be something like: > > x86/speculation: Add option to select app to app mitigation for spectre_v2 > >> Jiri Kosina's patch makes IBPB and STIBP available for >> general spectre v2 app to app mitigation. IBPB will be issued for >> switching to an app that's not ptraceable by the previous >> app and STIBP will be always turned on. >> >> However, app to app exploit is in general difficult >> due to address space layout randomization in apps and >> the need to know an app's address space layout ahead of time. >> Users may not wish to incur app to app performance >> overhead from IBPB and STIBP for general non security sensitive apps. >> >> This patch provides a lite option for spectre_v2 app to app >> mitigation where IBPB is only issued for security sensitive >> non-dumpable app. >> >> The strict option will keep system at high security level >> where IBPB and STIBP are used to defend all apps against >> spectre_v2 app to app attack. > > s/system > /the system > > s/attack > attacks > >> + spectre_v2_app2app= >> + [X86] Control app to app mitigation of Spectre variant 2 >> + (indirect branch speculation) vulnerability. >> + >> + lite - only turn on mitigation for non-dumpable processes >> + strict - protect against attacks for all user processes >> + auto - let kernel decide lite or strict mode > > Perhaps add: > lite - only turn on mitigation for non-dumpable processes (i.e. > protect daemons and other privileged processes that tend > to be non-dumpable) > > ? Will do. > >> + >> >> +static const char *spectre_v2_app2app_strings[] = { >> + [SPECTRE_V2_APP2APP_NONE] = "App-App Vulnerable", >> + [SPECTRE_V2_APP2APP_LITE] = "App-App Mitigation: Protect only non-dumpable process", >> + [SPECTRE_V2_APP2APP_STRICT] = "App-App Mitigation: Full app to app attack protection", >> +}; >> + >> +DEFINE_STATIC_KEY_FALSE(spectre_v2_app_lite); >> +EXPORT_SYMBOL(spectre_v2_app_lite); > > EXPORT_SYMBOL_GPL() I suspect? This is only used in the core kernel functions related to context switches. So I don't expect any module functions needing this value. > >> + >> #undef pr_fmt >> #define pr_fmt(fmt) "Spectre V2 : " fmt >> >> static enum spectre_v2_mitigation spectre_v2_enabled __ro_after_init = >> SPECTRE_V2_NONE; >> >> +static enum spectre_v2_mitigation spectre_v2_app2app_enabled __ro_after_init = >> + SPECTRE_V2_APP2APP_NONE; >> + >> void >> x86_virt_spec_ctrl(u64 guest_spec_ctrl, u64 guest_virt_spec_ctrl, bool setguest) >> { >> @@ -275,6 +293,46 @@ static const struct { >> { "auto", SPECTRE_V2_CMD_AUTO, false }, >> }; >> >> +static const struct { >> + const char *option; >> + enum spectre_v2_app2app_mitigation_cmd cmd; >> + bool secure; >> +} app2app_mitigation_options[] = { >> + { "lite", SPECTRE_V2_APP2APP_CMD_LITE, false }, >> + { "strict", SPECTRE_V2_APP2APP_CMD_STRICT, false }, >> + { "auto", SPECTRE_V2_APP2APP_CMD_AUTO, false }, >> +}; > > Am I reading this right that it's not possible to configure this to 'none', i.e. to disable the > protection altogether? Sure, I can add a none option. I'll probably put that in patch 4 which is easy to disable the mitigation by not turning on STIBP flag for the none option. > > >> + * For lite protection mode, we only protect the non-dumpable >> + * processes. >> + * >> + * Otherwise check if the current (previous) task has access to the memory >> + * of the @tsk (next) task for strict app to app protection. >> + * If access is denied, make sure to >> * issue a IBPB to stop user->user Spectre-v2 attacks. > > s/a IBPB > /an IBPB > Tim