Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751859AbeAQEaW (ORCPT + 1 other); Tue, 16 Jan 2018 23:30:22 -0500 Received: from mail-ot0-f193.google.com ([74.125.82.193]:44147 "EHLO mail-ot0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750830AbeAQEaS (ORCPT ); Tue, 16 Jan 2018 23:30:18 -0500 X-Google-Smtp-Source: ACJfBot+cjLytU/v6etEMnbrygW2eETQcPfpbsFJMo58fztlBezf8ERGxAX6hrm/s/QPwmU8gEmF+BirDPXXuKdLOAA= MIME-Version: 1.0 In-Reply-To: References: <151586744180.5820.13215059696964205856.stgit@dwillia2-desk3.amr.corp.intel.com> <151586748981.5820.14559543798744763404.stgit@dwillia2-desk3.amr.corp.intel.com> From: Dan Williams Date: Tue, 16 Jan 2018 20:30:17 -0800 Message-ID: Subject: Re: [PATCH v3 8/9] 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, Greg Kroah-Hartman , "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 Tue, Jan 16, 2018 at 2:23 PM, Dan Williams wrote: > On Sat, Jan 13, 2018 at 11:33 AM, Linus Torvalds [..] > I'll respin this set along those lines, and drop the ifence bits. So now I'm not so sure. Yes, get_user_{1,2,4,8} can mask the pointer with the address limit result, but this doesn't work for the access_ok() + __get_user() case. We can either change the access_ok() calling convention to return a properly masked pointer to be used in subsequent calls to __get_user(), or go with lfence on every __get_user call. There seem to be several drivers that open code copy_from_user() with __get_user loops, so the 'fence every __get_user' approach might have noticeable overhead. On the other hand the access_ok conversion, while it could be scripted with coccinelle, is ~300 sites (VERIFY_READ), if you're concerned about having something small to merge for 4.15. I think the access_ok() conversion to return a speculation sanitized pointer or NULL is the way to go unless I'm missing something simpler. Other ideas?