Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752606AbeADSdH (ORCPT + 1 other); Thu, 4 Jan 2018 13:33:07 -0500 Received: from mail-it0-f54.google.com ([209.85.214.54]:43028 "EHLO mail-it0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752508AbeADSdG (ORCPT ); Thu, 4 Jan 2018 13:33:06 -0500 X-Google-Smtp-Source: ACJfBosCWu/K7TskoklhcU8ZI+tHqu4UqCeUX3OL9v166OVW1U64pgXMhoRwGV46IEYntXlrCojG2897Qh8vDKD+Mjg= MIME-Version: 1.0 In-Reply-To: <20180104112614.GA1702@amd> References: <20180103230934.15788-1-andi@firstfloor.org> <20180104112614.GA1702@amd> From: Linus Torvalds Date: Thu, 4 Jan 2018 10:33:04 -0800 X-Google-Sender-Auth: fQvMmyFe0iozTuzydJwzUMiGEUo Message-ID: Subject: Re: Avoid speculative indirect calls in kernel To: Pavel Machek Cc: Andi Kleen , tglx@linuxtronix.de, Greg Kroah-Hartman , David Woodhouse , Tim Chen , Linux Kernel Mailing List , Dave Hansen Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Thu, Jan 4, 2018 at 3:26 AM, Pavel Machek wrote: > On Wed 2018-01-03 15:51:35, Linus Torvalds wrote: >> >> A *competent* CPU engineer would fix this by making sure speculation >> doesn't happen across protection domains. Maybe even a L1 I$ that is >> keyed by CPL. > > Would that be enough? No, you'd need to add the CPL to the branch target buffer itself, not the I$ L1. And as somebody pointed out, that only helps the user space messing with the kernel. It doesn't help the "one user context fools another user context to mispredict". (Where the user contexts might be a JIT'ed JS vs the rest of the web browser). So you really would want to just make sure the full address is used to index (or at least verify) the BTB lookup, and even then you'd then need to invalidate the BTB on context switches so that one context can't fill in data for another context. Linus