Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754211AbeALBOc (ORCPT + 1 other); Thu, 11 Jan 2018 20:14:32 -0500 Received: from mail-ot0-f195.google.com ([74.125.82.195]:35031 "EHLO mail-ot0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754077AbeALBOa (ORCPT ); Thu, 11 Jan 2018 20:14:30 -0500 X-Google-Smtp-Source: ACJfBosxLqn5+CwGNZtTPGz5ZYWJUuakbbrhF2nvEY7sRkzwwHwSC1glXjDQf5vDWRZGV3wUzuC0JLyOyBvPRv2oOR0= MIME-Version: 1.0 In-Reply-To: References: <151571798296.27429.7166552848688034184.stgit@dwillia2-desk3.amr.corp.intel.com> <151571802814.27429.12886210130791656117.stgit@dwillia2-desk3.amr.corp.intel.com> From: Dan Williams Date: Thu, 11 Jan 2018 17:14:29 -0800 Message-ID: Subject: Re: [PATCH v2 08/19] x86: use __uaccess_begin_nospec and ASM_IFENCE in get_user paths To: Linus Torvalds Cc: Linux Kernel Mailing List , linux-arch@vger.kernel.org, Andi Kleen , Kees Cook , kernel-hardening@lists.openwall.com, "the arch/x86 maintainers" , Ingo Molnar , Al Viro , "H. Peter Anvin" , Thomas Gleixner , Andrew Morton , Alan Cox 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 11, 2018 at 5:11 PM, Linus Torvalds wrote: > This patch doesn't affect arch/x86/lib/getuser.S, which I find surprising. > > Of all the user access functions, I actually think that get_user() is > the one most likely to have the result then used speculatively as an > index (the required second dependent read to actually leak data). > > I do *not* see people doing "copy_from_user()" and then somehow using > the thing as an index to another array. I mean, it can happen (copy a > structure, use a member in that structure), but it doesn't seem to be > the most likely thing. > > The most likely thing would seem to be some random ioctl() do a > "get_user()" to get an index, and then using that index. That would > seem to be one of the easier ways to perhaps get that kind of kernel > spectre attack. > > Adding the ASM_IFENCE to __get_user_X() in arch/x86/lib/getuser.S > would seem to go naturally together with the copy_user_64.S changes in > this patch. > > Is there some reason __get_user_X() was overlooked? Those are _the_ > most common user accessor functions that do the address limit > checking. Oversight, I was focused on the uaccess_begin conversions. Yes, let me go add ASM_IFENCE after the ASM_STAC in those paths.