Received: by 10.213.65.68 with SMTP id h4csp149139imn; Thu, 15 Mar 2018 12:21:17 -0700 (PDT) X-Google-Smtp-Source: AG47ELtBSb18Va+1dSaVxieLtbb1oAPT/W23shzVwYAYHD9W+XmZo2Of6XkUcdTuaQHFzkD6cQ/n X-Received: by 2002:a17:902:4c88:: with SMTP id b8-v6mr9410787ple.0.1521141677526; Thu, 15 Mar 2018 12:21:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521141677; cv=none; d=google.com; s=arc-20160816; b=qxfKPbXeTLr8mXxd+Rajiw77ISlsiYoY2KECc1SetNtK7chp1wFW5qdXlMWwllFW1p isE31aN461YNrzBdnO9qt7XUUl0oRaVutHNA68gapaGNdo+UlfoZM758S1wY7xIwv2kq Ik8dxBS291FPvyU8y0b/L/ohPud5zmuFeTNhA9KyZufd5wzpjw7EUog5Wgx7hLyl66ou 0Qo8ZAvQkGYKWdiBtOq5ZijTAmh3mBY43x9zBfxx0w7oM5lnNi/tajrWRUOuSc/Y0yBk LJZ627WUTIK5PH73vk3aELdVxg0z4VUjjhbTW/kFZATqZ4vX4Io+yYid1Rnt0Frz6Cev ShHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=UsJ1hngeGJikBHwtvXvxwvouxQC72P+GIqrngCaUNC8=; b=zC04mbHd8dTD9ACI3wZLWzJvfpDh9WdKEFe9UfA53DMMRbOHCvrNHUvd23ZOrUz9rY uJh47/rnJfhhLIjg/dVHMnXp7n/qVkpa9K0Vx8lyTTZBuDViIzKu4tCeBl5OXgbN/UcG adCvlqv6sx6zLyddGA6gL5UXkIaMxfERU7VxvgcVbgU2Ue5GSogtHXYYvHy5+wFyJwiq 1qS6WB1gcXMW610NIwEMy69RGOEIcKePdAIzHoQzpFI3iAYzEGzu1RHP8oGQ5wCEBqL+ fBJA5e7ajoFytDEid2SEDS4wvRmAMK1DVy1jLUHfPRiQ9O2iWxqBFCkWVgqYJYVGP5zD 05Ug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h191si1971386pgc.716.2018.03.15.12.21.03; Thu, 15 Mar 2018 12:21:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932588AbeCOTSh (ORCPT + 99 others); Thu, 15 Mar 2018 15:18:37 -0400 Received: from mx2.suse.de ([195.135.220.15]:45163 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752942AbeCOTQX (ORCPT ); Thu, 15 Mar 2018 15:16:23 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id A1659AE92; Thu, 15 Mar 2018 19:16:21 +0000 (UTC) From: Michal Suchanek To: linuxppc-dev@lists.ozlabs.org Cc: Kate Stewart , Madhavan Srinivasan , Paul Mackerras , Michael Neuling , "Bryant G. Ly" , Mahesh Salgaonkar , "Naveen N. Rao" , Daniel Axtens , Nicholas Piggin , Al Viro , David Gibson , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Sergey Senozhatsky , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Masami Hiramatsu , Andrew Donnellan , Philippe Ombredanne , Joe Perches , Oliver O'Halloran , Andrew Morton , "Tobin C. Harding" , Michal Suchanek Subject: [PATCH RFC rebase 2/9] powerpc: Use barrier_nospec in copy_from_user Date: Thu, 15 Mar 2018 20:15:51 +0100 Message-Id: <32268431948dc1a32264a98a76d41d71ae7536b3.1521141122.git.msuchanek@suse.de> X-Mailer: git-send-email 2.13.6 In-Reply-To: References: <20180313200108.GA4082@hirez.programming.kicks-ass.net> In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is based on x86 patch doing the same. Signed-off-by: Michal Suchanek --- arch/powerpc/include/asm/uaccess.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h index 51bfeb8777f0..af9b0e731f46 100644 --- a/arch/powerpc/include/asm/uaccess.h +++ b/arch/powerpc/include/asm/uaccess.h @@ -248,6 +248,7 @@ do { \ __chk_user_ptr(ptr); \ if (!is_kernel_addr((unsigned long)__gu_addr)) \ might_fault(); \ + barrier_nospec(); \ __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \ (x) = (__typeof__(*(ptr)))__gu_val; \ __gu_err; \ @@ -258,8 +259,10 @@ do { \ long __gu_err = -EFAULT; \ unsigned long __gu_val = 0; \ const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ + int can_access = access_ok(VERIFY_READ, __gu_addr, (size)); \ might_fault(); \ - if (access_ok(VERIFY_READ, __gu_addr, (size))) \ + barrier_nospec(); \ + if (can_access) \ __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \ (x) = (__force __typeof__(*(ptr)))__gu_val; \ __gu_err; \ @@ -271,6 +274,7 @@ do { \ unsigned long __gu_val; \ const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ __chk_user_ptr(ptr); \ + barrier_nospec(); \ __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \ (x) = (__force __typeof__(*(ptr)))__gu_val; \ __gu_err; \ @@ -298,15 +302,19 @@ static inline unsigned long raw_copy_from_user(void *to, switch (n) { case 1: + barrier_nospec(); __get_user_size(*(u8 *)to, from, 1, ret); break; case 2: + barrier_nospec(); __get_user_size(*(u16 *)to, from, 2, ret); break; case 4: + barrier_nospec(); __get_user_size(*(u32 *)to, from, 4, ret); break; case 8: + barrier_nospec(); __get_user_size(*(u64 *)to, from, 8, ret); break; } @@ -314,6 +322,7 @@ static inline unsigned long raw_copy_from_user(void *to, return 0; } + barrier_nospec(); return __copy_tofrom_user((__force void __user *)to, from, n); } -- 2.13.6