From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A89C3C433E2 for ; Mon, 14 Sep 2020 20:52:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 68460215A4 for ; Mon, 14 Sep 2020 20:52:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="32A5zbE1"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="lS+dygw7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726208AbgINUwM (ORCPT ); Mon, 14 Sep 2020 16:52:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726120AbgINUv7 (ORCPT ); Mon, 14 Sep 2020 16:51:59 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66F2EC061788 for ; Mon, 14 Sep 2020 13:51:58 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1600116716; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=aDiPSzZTn9VZOgWHTza0B6Xq/ARyn+pdBM1nVtKC6oU=; b=32A5zbE18lOTSAlbzsrHu7jkmGQbH0a/kGsnBli5tZQ9xlnz9kvE5EjBkd0SNa9M1Ke6Lk c/ZGk2IK8T+Pnl7tLnOP4zCtjiOAlRiEL6mBO9ixx7fm5VjafED9vAZnjITWxxrjD5ONLP +3aryQVETV9Dph2wXKa88xhaF9/zBVkz8n41CxiSVQKMQ3bX1ByFL09l7hYOIR/T79IqQF a6uNJ7UC7rjtLjtpzXyCb+6rHxyMa1UkO01G8iuIJ9qhH+TzXzW9HNUSDVoNTrqViPWcNf zb6KspRL1eXMYCJdyxecIkbskkhb0U/q7Ad4RwG6b/57ZF963yWh7vGraiYs/Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1600116716; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=aDiPSzZTn9VZOgWHTza0B6Xq/ARyn+pdBM1nVtKC6oU=; b=lS+dygw7Bu6tTKSgjeG33hsJOu7VPkl8naz4rp9u58R8+gDAWipqZH7fXcv3wuW3UOS9Hf UiWeuPAIFCadLlAQ== To: Josh Poimboeuf , x86@kernel.org, Al Viro Cc: linux-kernel@vger.kernel.org, Linus Torvalds , Will Deacon , Dan Williams , Andrea Arcangeli , Waiman Long , Peter Zijlstra , Andrew Cooper , Andy Lutomirski , Christoph Hellwig , David Laight , Mark Rutland Subject: Re: [PATCH v3] x86/uaccess: Use pointer masking to limit uaccess speculation In-Reply-To: <20200914195354.yghlqlwtqz7mqteb@treble> References: <1d06ed6485b66b9f674900368b63d7ef79f666ca.1599756789.git.jpoimboe@redhat.com> <20200914195354.yghlqlwtqz7mqteb@treble> Date: Mon, 14 Sep 2020 22:51:56 +0200 Message-ID: <877dswozdf.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 14 2020 at 14:53, Josh Poimboeuf wrote: > Al, > > This depends on Christoph's set_fs() removal patches. Would you be > willing to take this in your tree? Ack. > On Thu, Sep 10, 2020 at 12:22:53PM -0500, Josh Poimboeuf wrote: >> The x86 uaccess code uses barrier_nospec() in various places to prevent >> speculative dereferencing of user-controlled pointers (which might be >> combined with further gadgets or CPU bugs to leak data). >> >> There are some issues with the current implementation: >> >> - The barrier_nospec() in copy_from_user() was inadvertently removed >> with: 4b842e4e25b1 ("x86: get rid of small constant size cases in >> raw_copy_{to,from}_user()") >> >> - copy_to_user() and friends should also have a speculation barrier, >> because a speculative write to a user-controlled address can still >> populate the cache line with the original data. >> >> - The LFENCE in barrier_nospec() is overkill, when more lightweight user >> pointer masking can be used instead. >> >> Remove all existing barrier_nospec() usage, and instead do user pointer >> masking, throughout the x86 uaccess code. This is similar to what arm64 >> is already doing with uaccess_mask_ptr(). >> >> barrier_nospec() is now unused, and can be removed. >> >> Fixes: 4b842e4e25b1 ("x86: get rid of small constant size cases in raw_copy_{to,from}_user()") >> Suggested-by: Will Deacon >> Signed-off-by: Josh Poimboeuf Reviewed-by: Thomas Gleixner