Received: by 10.223.176.46 with SMTP id f43csp2377751wra; Thu, 25 Jan 2018 08:57:53 -0800 (PST) X-Google-Smtp-Source: AH8x225iRPBjFrPqEJVePk2HHg++98ew2K0uO7iLedcTj4rwRYT+DZ4U0l3k5+vqGZvuVkVurgWO X-Received: by 10.101.76.193 with SMTP id n1mr12950233pgt.194.1516899473581; Thu, 25 Jan 2018 08:57:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516899473; cv=none; d=google.com; s=arc-20160816; b=QslL9SCrmZPF8vqCMCwlBsP40pcvSqnqwxDaIFLWWn70dto2cULAZWSo8cbYE1p/0i 0BIucAEgu7wQci1+LWYYB9nFUhxh+2I+sf9ZK/TuRKtzJGAe7dtK232XPMpw4cq3rZ4/ SkObETaWHQ+n1L3fmoyxbB1aG5fjq3pXCcDxw29vE9ZwU/77SGW6hB8VyX2mpTbetgR4 7eABoRvMYVN9X2i4GuEU8Nn9S+5TPdSgYNsk9nJoynqRHiGa6JkSTDuWgG89EJ4FzdOb IXOwIz8jzWn4a9LZJciPeJsrXp4EAWScntK1SrfVknWy2h5LiwanlI0EITaOSQrQPQ9P 0ieg== 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:from:references:cc:to:subject:arc-authentication-results; bh=ImNCRcLNE3OZ5EgZFCMcaGoLZxu+KJJMQ16a1HBLmQE=; b=fdGZCI2fvIF3wglAKgQRBBuEjH4L6HDl+oNaYK9Y00s0B51jaliK3VyDyJO2emDFHM NyordH9h2sS6NabYktCu5/70gkun3rbwFAhxIGe5WPe4Nn2VQklbZombSmU+v3tUA1Ao DNE8UaEsPU+j5WL/D8Lay0MpMtmsmD1a5RvuWmfT6k5WzhHxQUcUhZbKbHitpSq1iclr voQLBZY+GgQGnOqzoWG/5xi1tZeUftr1DB4knYvzzQZWL868t1KmjeBQWE3uOpKD8LFO temalSOLyjqA6trgJ5Yd/FYoYK6+iq6a+PBUCcrZFhNDYvjOmf1MKF20OhTpM4soJQc3 8Hzg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p65si4892321pfg.280.2018.01.25.08.57.39; Thu, 25 Jan 2018 08:57:53 -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; 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 S1751270AbeAYQ5A (ORCPT + 99 others); Thu, 25 Jan 2018 11:57:00 -0500 Received: from mga01.intel.com ([192.55.52.88]:51469 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750992AbeAYQ46 (ORCPT ); Thu, 25 Jan 2018 11:56:58 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jan 2018 08:56:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,412,1511856000"; d="scan'208";a="13454984" Received: from schen9-desk3.jf.intel.com (HELO [10.54.74.42]) ([10.54.74.42]) by orsmga006.jf.intel.com with ESMTP; 25 Jan 2018 08:56:58 -0800 Subject: Re: [RFC PATCH 2/2] x86/ibpb: Prevent missed IBPB flush To: David Woodhouse , linux-kernel@vger.kernel.org Cc: KarimAllah Ahmed , Andi Kleen , Andrea Arcangeli , Andy Lutomirski , Arjan van de Ven , Ashok Raj , Asit Mallick , Borislav Petkov , Dan Williams , Dave Hansen , Greg Kroah-Hartman , "H . Peter Anvin" , Ingo Molnar , Janakarajan Natarajan , Joerg Roedel , Jun Nakajima , Laura Abbott , Linus Torvalds , Masami Hiramatsu , Paolo Bonzini , Peter Zijlstra , rkrcmar@redhat.com, Thomas Gleixner , Tom Lendacky , x86@kernel.org References: <332d3ac8a7018b98d8182ec86b5fc41239c667c6.1516840211.git.tim.c.chen@linux.intel.com> <1516868406.30244.16.camel@infradead.org> From: Tim Chen Message-ID: Date: Thu, 25 Jan 2018 08:56:57 -0800 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: <1516868406.30244.16.camel@infradead.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/25/2018 12:20 AM, David Woodhouse wrote: > On Wed, 2018-01-24 at 16:36 -0800, Tim Chen wrote: >> It is possible that the last uesr mm that we recorded for a cpu was >> released, and a new mm with identical address was allocated when we >> check it again. We could skip IBPB flush here for the process with >> the new mm. >> >> It is a difficult to exploit case as we have to exit() a process on a >> cpu, free the mm, and fork() the victim to use the mm pointer on that >> cpu. The exploiter needs the old mm to get recycled to the >> newly forked process and no other processes run on the target cpu. > > That's what it takes to have the victim process leak information into > the cache. In order to *harvest* that information, the attacker must > then get run on the same CPU again? And since her first process had to > exits, as described above, she needs a new process for that? > > I confess, with all the other wildly theoretical loopholes that exist, > I wasn't losing much sleep over this one. > >> Nevertheless, the patch below is one way to close this hole by >> adding a ref count to prevent the last user mm from being released. >> It does add ref counting overhead, and extra memory cost of keeping an mm >> (though not the VMAs and most of page tables) around longer than we will >> otherwise need to. Any better solutions are welcomed. > > This has no upper bound on the amount of time the user mm gets held, > right? If a given CPU remains idle for ever (and what happens if it's > taken offline?) we'll never do that mmdrop() ? > The downside with this approach is we do hold on to the mm longer than we needs to. Yes, the offline path does need to be fixed up. Tim