From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x224KV4gixO0yKEDvklONCZYIuDhYsLWVbZnG3Om0VYxmNMzT+PeE1x4BVlqELTWXD9h12ExS ARC-Seal: i=1; a=rsa-sha256; t=1517371178; cv=none; d=google.com; s=arc-20160816; b=aDtn28f3JnQjfu74vuxp+gv4kDZzfBtJSs/UyxhnL1LQpgp6xBSjuQtSW6hOW3LsZM 8EWtUwOwLGIeWLpDoknP364jWU/3vAM7XSJhw1unyi+eVWwjbHWqxrnlYlPg/vPN3+NP aknigqwrknizg8D7cev2TXGVkv8hdAAXMa7BTuYOQa2PSKfyPq4VQIT0cak73s5ywxUU 9uD5kCKq1wZru429+EDNRAW0RsiSpA+DM7m6iEomZ21rcby7DOYMSqPWlMtnR13O0siL 5jfAZ2WjM1zEHsIEJjD2NVHW8VMX618FjvqlQe3DHpkEvldvespHPXdCO6ePxuHtUypi zQ3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:arc-authentication-results; bh=heXgli1NUaVYMlSXzKRzq8xtLAeJ0n5F1k8+S8E7tHI=; b=D873AcMyBvUKZrfYSKsba3dplOvlbRzFmCOxx9tpw6WIUryaZ47SqU86PSlAZ0m1Ae re2KcNQSP4Iv8xr6QayFoSNX+MWFqIlJiWzDFfI1I5uM2q50iisVHgMCykrQYMp0SRxy g1/9AcyEBopPY7BGKHzCwXyaPH8bYvxSogKhO1GFSptNNzafZg8Iyu2dwkNQ25JHokDW 63/ac8bQhkEvJXVujf8apNYvfDgbZ6+A76t1cFw/+6PdIsqAaCdvEi1MP+IWsHmDoAvp n6Qy7DRRmPKLM8L/GY+CNBqJ+uj1n+p3/s36a/ItICSCr43JMChquuY6uLgVCti8pai1 /qfg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of jpoimboe@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=jpoimboe@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Authentication-Results: mx.google.com; spf=pass (google.com: domain of jpoimboe@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=jpoimboe@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Date: Tue, 30 Jan 2018 21:59:07 -0600 From: Josh Poimboeuf To: Tim Chen Cc: David Woodhouse , arjan@linux.intel.com, tglx@linutronix.de, karahmed@amazon.de, x86@kernel.org, linux-kernel@vger.kernel.org, bp@alien8.de, peterz@infradead.org, pbonzini@redhat.com, ak@linux.intel.com, torvalds@linux-foundation.org, gregkh@linux-foundation.org, mingo@kernel.org, luto@kernel.org, linux@dominikbrodowski.net Subject: Re: [PATCH] x86/speculation: Use Indirect Branch Prediction Barrier in context switch Message-ID: <20180131035907.sye4x7f3e77wnroh@treble> References: <1517263487-3708-1-git-send-email-dwmw@amazon.co.uk> <20180130174850.bwypk4r5yn2344jb@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.0.1 (2016-04-01) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: =?utf-8?q?1590966106432961445?= X-GMAIL-MSGID: =?utf-8?q?1591079001124711732?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: On Tue, Jan 30, 2018 at 01:23:17PM -0800, Tim Chen wrote: > On 01/30/2018 09:48 AM, Josh Poimboeuf wrote: > > On Mon, Jan 29, 2018 at 10:04:47PM +0000, David Woodhouse wrote: > >> From: Tim Chen > >> > >> Flush indirect branches when switching into a process that marked itself > >> non dumpable. This protects high value processes like gpg better, > >> without having too high performance overhead. > > > > I wonder what the point of this patch is. An audit of my laptop shows > > only a single user of PR_SET_DUMPABLE: systemd-coredump. > > This is an opt in approach. For processes who need extra > security, it set itself as non-dumpable. Then it can > ensure that it doesn't see any poisoned BTB. I don't want other users reading my applications' memory. I don't want other containers reading my containers' memory. I don't want *any* user tasks reading root daemons' memory. Those are not unreasonable expectations. So now I have to go and modify all my containers and applications to set PR_SET_DUMPABLE? That seems highly impractical and unlikely. Plus, I happen to *like* core dumps. The other option is to rebuild the entire userland with retpolines, but again, that would make this patch completely pointless. > > [ And yes, I have gpg-agent running. Also, a grep of the gnupg source > > doesn't show any evidence of it being used there. So the gpg thing > > seems to be a myth. ] > > I'm less familiar with gpg-agent. Dave was the one who > put in comments about gpg-agent in this patch so perhaps > he can comment. > > > > > But also, I much preferred the original version of the patch which only > > skipped IBPB when 'prev' could ptrace 'next'. > > For the A->kernel thread->B scenario, you will need context of A > to decide if you need IBPB when switching to B. You need to > worry about whether the context of A has been released ... etc if > you want to use ptrace. Is that why the ptrace approach was abandoned? Surely that's a solvable problem? We have some smart people on lkml. And anyway I didn't see it discussed anywhere. In the worst case we could just always do IBPB when switching between kernel and user tasks. -- Josh