Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5018977imu; Sun, 25 Nov 2018 15:05:46 -0800 (PST) X-Google-Smtp-Source: AFSGD/W7qFe3DLOCWiEuWgouxNlzVG8KaFgHT8w3X4JpuMnjcqnMSty3FxCaD1Fz7+jN7DisxAhP X-Received: by 2002:a65:610d:: with SMTP id z13mr22745331pgu.427.1543187146018; Sun, 25 Nov 2018 15:05:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543187145; cv=none; d=google.com; s=arc-20160816; b=AgiQn/I5QRKmsRyg+EGA8ZzAsMV/SPd14IcIxS6URJ+jC0sF2Ig399CPHCos1dse2e 69kwxbzngT/VaMMCbqjYYuB0/W2w4+KyPAmgCxxvc4ROPFiWWiWmG0SOrWqjwuxeHwOQ lzVoNQ5PgYfvl3Jq8MIkBNtshYpwttWsRUbDhdsFTpWh/rqx1EG9/nPbcP8SbTu/A9O2 5izIfxqdj6tcmlnSCsWQAg6G2qasZR7qLOC6CrTShrJnjWg9ZvU9z1C+6OV725Q2fL7R szk8AEU2/b/tbJfeYt1Gwp36A1Zrh4p9vZI9cLFESJ+kAxvxQaIGly5IwI3l/ElnL4+M pT+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=/4aDE9ihAEIORlpRetXDVtJmf/QKIgFjKPM953lu8EI=; b=EngobLarvamPvMeBLi94AwQKNg+m9tpgGaZEJ3KIVckjql2M8OINRCWM9+6izXE17b QHf5HtH6kk6RDE60g2EaLIgP+EnpgXxV118EU/qJ32QzYDp+1ansJf9OR1+3NR2Fb7vj kDAuE+DEyhRqN8H1bk8OQQYx8KuBVsFkpMATGViqPqxi0lTxH2l3he1ZnX4aV31jLM3b 6J+M261IKDlbqkCDrzilWPF2PUIu0BRe0gZBsL2kv362BDs61/zMOmw9NTnQSfTIw2Yx EuMI9nL/4dloHEROLIkGs3PcesWpzdDo6rsk34MsuNOAKqq4heKrSkTdlsonKp3PbHQq jAdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=Dup2epzI; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o14si38347817pgj.59.2018.11.25.15.05.30; Sun, 25 Nov 2018 15:05:45 -0800 (PST) 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; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=Dup2epzI; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726191AbeKZJ4t (ORCPT + 99 others); Mon, 26 Nov 2018 04:56:49 -0500 Received: from mail-pf1-f172.google.com ([209.85.210.172]:33264 "EHLO mail-pf1-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726076AbeKZJ4s (ORCPT ); Mon, 26 Nov 2018 04:56:48 -0500 Received: by mail-pf1-f172.google.com with SMTP id c123so4915829pfb.0 for ; Sun, 25 Nov 2018 15:04:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=/4aDE9ihAEIORlpRetXDVtJmf/QKIgFjKPM953lu8EI=; b=Dup2epzIbVbzGQ+tvRduX44zsS7aEvVgZClojGuU50/DYLkKKaQyrVi7w9KmHuoQVI rErczr7WtTNwSBGF8G9AHoCi0NdujySuA7nSIP/jCm5Ws5mkyjHqbA3VkAuaS9xkZTR2 UPGd70lJ1WNar/oJpTAZa9nqMJ3r7KC4bkJ6/qs0rEDbXPoIg7Rw/kePWAkO4DTF74O5 iHxfONAXUJbyYH+/QwMmlLj/vc8tcPzpq3VeMVOewLtu/BYW4LtFwftzJhYvF5G+bfIq LszlUWSi0a4nv5XO0lfVIumjtQWWCoR5XiVtYtqN4XEp2T39VxWxW/Aul1Mqdx+8yfTc KBqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=/4aDE9ihAEIORlpRetXDVtJmf/QKIgFjKPM953lu8EI=; b=U/1kYhhjDmQmG0cE7dFHtU4YTM2kPAZzOCExd0X0ERmGJQpFheOrueARTPqD53+sHB LcDTukI3xf+ZHaFH5w2Jx4sCavtQxQcY2ePZKm/YsyEbrj6UgLbPg0VulRGtLivhY4eV Bcdj+ivHaQLvSxBmjuQyyhH1MT5YwwLiE5pfO7sU4Rx/uJK+7pDzzgwQty43aLOATvZE g3Xs0xg6CulKKg3MxKwUD7fj0/QZxgCrFGSn2ErSmQ+FJz7tEYBN2hIeEzrco5iG6anj YQzwt8Lu1Ts5jD/iws6n+pBCdsFSPeLK4drUlLIh0FQOkCQKfTVfD3U+4EcRJ+9bZ1VJ R8+w== X-Gm-Message-State: AA+aEWZFryWSP2n6EQN45GKspn87qsspnYVVjmLLzNb+YHFArdVVMcSB FNuAUr4d4PNmpksj7LeuxHg2Uw== X-Received: by 2002:a63:24c2:: with SMTP id k185mr21810568pgk.406.1543187075558; Sun, 25 Nov 2018 15:04:35 -0800 (PST) Received: from ?IPv6:2601:646:c200:7429:7069:da99:d9d2:c355? ([2601:646:c200:7429:7069:da99:d9d2:c355]) by smtp.gmail.com with ESMTPSA id f193-v6sm89516464pfc.74.2018.11.25.15.04.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Nov 2018 15:04:34 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (1.0) Subject: Re: [patch V2 21/28] x86/speculation: Prepare for conditional IBPB in switch_mm() From: Andy Lutomirski X-Mailer: iPhone Mail (16B92) In-Reply-To: Date: Sun, 25 Nov 2018 15:04:33 -0800 Cc: Andi Kleen , LKML , x86@kernel.org, Peter Zijlstra , Andy Lutomirski , Linus Torvalds , Jiri Kosina , Tom Lendacky , Josh Poimboeuf , Andrea Arcangeli , David Woodhouse , Tim Chen , Dave Hansen , Casey Schaufler , Asit Mallick , Arjan van de Ven , Jon Masters , Waiman Long , Greg KH , Dave Stewart , Kees Cook Content-Transfer-Encoding: quoted-printable Message-Id: <92833780-41BE-446E-A676-925BA1EC93D9@amacapital.net> References: <20181125183328.318175777@linutronix.de> <20181125185005.466447057@linutronix.de> <20181125205330.GO13936@tassilo.jf.intel.com> To: Thomas Gleixner Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Nov 25, 2018, at 2:20 PM, Thomas Gleixner wrote: >=20 > On Sun, 25 Nov 2018, Andi Kleen wrote: >=20 >>> The current check whether two tasks belong to the same context is using t= he >>> tasks context id. While correct, it's simpler to use the mm pointer beca= use >>> it allows to mangle the TIF_SPEC_IB bit into it. The context id based >>> mechanism requires extra storage, which creates worse code. >>=20 >> [We tried similar in some really early versions, but it was replaced >> with the context id later.] >>=20 >> One issue with using the pointer is that the pointer can be reused >> when the original mm_struct is freed, and then gets reallocated >> immediately to an attacker. Then the attacker may avoid the IBPB. >>=20 >> Given it's probably hard to generate any reasonable leak bandwidth with >> such a complex scenario, but it still seemed better to close the hole. >=20 > Sorry, but that's really a purely academic exercise.=20 >=20 >=20 I would guess that it=E2=80=99s actually very easy to force mm_struct* reuse= . Don=E2=80=99t the various allocators try to allocate hot memory? There=E2= =80=99s nothing hotter than a just-freed allocation of the same size. Can someone explain the actual problem with ctx_id? If you just need an ext= ra bit, how about: 2*ctx_id vs 2*ctx_id+1 Or any of the many variants of approximately the same thing? =E2=80=94Andy=