Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2454323pxk; Mon, 14 Sep 2020 13:55:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3E10qIn+g9dcFUjK+twmKI6U1BGOE9mEgi1MbQPqWT5jQHxFOBTpyUa4S3QfQvZzkI4FJ X-Received: by 2002:a17:906:a947:: with SMTP id hh7mr16016996ejb.126.1600116937907; Mon, 14 Sep 2020 13:55:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600116937; cv=none; d=google.com; s=arc-20160816; b=tnYKT5URDLVIXIQV9D3OFBfqGmeStagACDev88+QuUt5oF0Z9s5H1oRm7zLdSU463/ 1jMRqU1vaXL0JrHxYuEsBoF+RG64R+1gDO70ZaIVqfHd1RjMPjElb0D77NjLkPAQKEdG cRt5Nd5KdP39WeD86ZmRatG68s2Llr3Pq70hku4w6262qHu9Tqz/zVldjCZLUsF/oXK8 2uE5ekyr9YH6HhODRk3yrjvmQt8FWnA7fWdax5kCWlOR8JYU2/NHr8gviCrlu9gPo329 JzLXIvvzknKXNHABVCc/pquc2Jkk+j8o4iBaxdIT9skw2ZxwvLYfbpSxsmGYfbEbAZXt CNRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=aDiPSzZTn9VZOgWHTza0B6Xq/ARyn+pdBM1nVtKC6oU=; b=dSseICnOeI0Qq3DcTTcnKbuBkYMiv9Zi8sarVClf32DU+IazTkqjhXGQF+HUx77J0e 9k8Ug7fOp/0BtxzWbIGyT02ZHGxonapdOIT7mwT98qw9pjc8eZoGFxOF3L8w1m7Se7Fd +Ir5kT54HsSeqviaB9D1u4sPCXNakfqjMHS8ne/wQlcVFiNF0sjmKGjWsDR2KykBou3Z o0Ry0hN3scdAGM1CFTjo9cMwNgo4Q+JplB5kjH1KH/fIjCVIXJC4bLmKvbPW7FFCevKG JXPAcNcpkufXQQTUNZZlCozCQjxD3zLwKJHZFzwuW/sAGjgjjQ5yelPjGYKLe5aNoAKp 0aGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=32A5zbE1; dkim=neutral (no key) header.i=@vger.kernel.org; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v23si8112248edr.208.2020.09.14.13.55.16; Mon, 14 Sep 2020 13:55:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=32A5zbE1; dkim=neutral (no key) header.i=@vger.kernel.org; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726201AbgINUwH (ORCPT + 99 others); Mon, 14 Sep 2020 16:52:07 -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