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=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 CF296C4CEC9 for ; Wed, 18 Sep 2019 14:30:06 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4BD53218AE for ; Wed, 18 Sep 2019 14:30:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ellerman.id.au header.i=@ellerman.id.au header.b="Z2MY+PcE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4BD53218AE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ellerman.id.au Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 46YMnk6WD9zF1bc for ; Thu, 19 Sep 2019 00:30:02 +1000 (AEST) Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 46YMDV253rzDrgF for ; Thu, 19 Sep 2019 00:04:42 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ellerman.id.au Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ellerman.id.au header.i=@ellerman.id.au header.b="Z2MY+PcE"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 46YMDF51tFz9sNk; Thu, 19 Sep 2019 00:04:29 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ellerman.id.au; s=201909; t=1568815472; bh=OtjuN7b/JN32k8kTJz7+0zZjBH9OAYcEhMOUPbHgnfk=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=Z2MY+PcEhO6O1VNORO4MD+IYzWGkjYpSASQ3suWSOb3YeWqAXdkom3LG5G5DkX1hv i0dCuJ6WXJ/yMQSyCKpIqcOr12myYDgrSBeut9jjRymem3H7v/oI9dmM4df5LS73MS 8HBl2kd5nfV5JTNNJzC6JUZOJJjPXua6NID6AfmmRLAicvWWe5SVnvtdyJtIfD7pwm vgi/aZSJWohpFUz6D+qQV03zpP+h+M8kU5Q7NR7B8TQofTwqX2qxCPEbQY/WdFHbSV 9JolaenYcNvK61MU8QII+zn6WujxiF2t0Di757vJ+O7dRGQ0GIspq2tSuxLelx2Oad B2HEq0VM8ypcw== From: Michael Ellerman To: Michal =?utf-8?Q?Such=C3=A1nek?= , Suraj Jitindar Singh Subject: Re: [PATCH] powerpc: Add barrier_nospec to raw_copy_in_user() In-Reply-To: <20190821153656.57fabe9c@kitsune.suse.cz> References: <20190306011038.16449-1-sjitindarsingh@gmail.com> <20190821153656.57fabe9c@kitsune.suse.cz> Date: Thu, 19 Sep 2019 00:04:27 +1000 Message-ID: <87o8zhvgyc.fsf@mpe.ellerman.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linuxppc-dev@lists.ozlabs.org, Al Viro Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" Michal Such=C3=A1nek writes: > On Wed, 6 Mar 2019 12:10:38 +1100 > Suraj Jitindar Singh wrote: > >> Commit ddf35cf3764b ("powerpc: Use barrier_nospec in copy_from_user()") >> Added barrier_nospec before loading from user-controller pointers. >> The intention was to order the load from the potentially user-controlled >> pointer vs a previous branch based on an access_ok() check or similar. >>=20 >> In order to achieve the same result, add a barrier_nospec to the >> raw_copy_in_user() function before loading from such a user-controlled >> pointer. >>=20 >> Signed-off-by: Suraj Jitindar Singh >> --- >> arch/powerpc/include/asm/uaccess.h | 1 + >> 1 file changed, 1 insertion(+) >>=20 >> diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/a= sm/uaccess.h >> index e3a731793ea2..bb615592d5bb 100644 >> --- a/arch/powerpc/include/asm/uaccess.h >> +++ b/arch/powerpc/include/asm/uaccess.h >> @@ -306,6 +306,7 @@ extern unsigned long __copy_tofrom_user(void __user = *to, >> static inline unsigned long >> raw_copy_in_user(void __user *to, const void __user *from, unsigned lon= g n) >> { >> + barrier_nospec(); >> return __copy_tofrom_user(to, from, n); >> } >> #endif /* __powerpc64__ */ > > Hello, > > AFAICT this is not needed. The data cannot be used in the kernel without > subsequent copy_from_user which already has the nospec barrier. Suraj did talk to me about this before sending the patch. My memory is that he came up with a scenario where it was at least theoretically useful, but he didn't mention that in the change log. He was working on nested KVM at the time. I've now forgotten, and he's moved on to other things so probably won't remember either, if he's even checking his mail :/ cheers