Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp593947pxb; Thu, 25 Feb 2021 09:58:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJwihmXTip4fbBoMqHRbIGiK1p67v2kFClEWjRr/aJFugK/7kZs2+2mD/V9B8cBtQnRZMoST X-Received: by 2002:a17:907:212e:: with SMTP id qo14mr3860748ejb.515.1614275933642; Thu, 25 Feb 2021 09:58:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614275933; cv=none; d=google.com; s=arc-20160816; b=UjNurIeVJJE0KwF+f0RtvHJ//3KMB4H4in5fHONbIBdOaE1KymJxb60Fbni5lTiX1w zPj6Wtx1g+ToS+1YfV9UY4xf9GAhiN/ce6WGlUzSRzBfd10bImc6qCsTGzXRd11RsTcZ Vdh5ypbJmSMAU0rPd6i124r68EGlPzXGNmruZ4WkqSoKW+vLnGgkZfizygM46X4CP0BV O+Tyz6RrjJQbDVAizAqvoGi4hGXRuS8bTSc1Fz8RBBqb/ZHChQxVr+j8D5p8CFoqEOin qAH3IKkJXM58j9lPMryVYq58j9r7YvfZGycCLYp+mkFzppI0iMW4s928cDuZeCKUziFt sOew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:cc:to:subject:from:references:in-reply-to :message-id; bh=ct9U+E3qPskcTHov8tgJrhKhMyl/qy94toSW9VA2MDw=; b=nFBrHJmYquGipTkHQ8112cqhYdYfo3YRvrtG3nimDvSN4pKbSwgidHuTfIVe6m/xmy CUVQvSn9jnrfzsWdTI7oQAsUKlZ6dVKbv0Z2W+HiSEez0o3F5wwsnB2nYz/VhfM2bKC+ 7IfELRewdseMlEPoLQziDOJOMH4z9SIHXUeaolQ0UiXHj81/nZRAWhUSbaanG5pJToih rcYjlnU7J66xw2KqdIIAMMIAC4J0x0FAK58nre99ej8udAaPw6XyP7b4fdKSmgcLepvg Mwrq2CVN69w5yRA17to3o1cKGEqiTPRCb+xr0Txn2D2TqS4XWOQAGOrHPGGppDoVLrGn z+QA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cx12si3613146edb.460.2021.02.25.09.58.31; Thu, 25 Feb 2021 09:58:53 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233585AbhBYR5y (ORCPT + 99 others); Thu, 25 Feb 2021 12:57:54 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:40679 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232903AbhBYRwW (ORCPT ); Thu, 25 Feb 2021 12:52:22 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 4DmgLQ6NXvz9v1BB; Thu, 25 Feb 2021 18:50:38 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id QvMhW63DNFRf; Thu, 25 Feb 2021 18:50:38 +0100 (CET) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 4DmgLQ5FHxz9v19y; Thu, 25 Feb 2021 18:50:38 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 905668B895; Thu, 25 Feb 2021 18:50:40 +0100 (CET) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id hhm05etgtTnB; Thu, 25 Feb 2021 18:50:40 +0100 (CET) Received: from po16121vm.idsi0.si.c-s.fr (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 4E6888B88B; Thu, 25 Feb 2021 18:50:40 +0100 (CET) Received: by po16121vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 295BD67442; Thu, 25 Feb 2021 17:50:40 +0000 (UTC) Message-Id: <1bca82b81046b5cf094fbb9163d73c4043455865.1614275314.git.christophe.leroy@csgroup.eu> In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v1 10/15] powerpc/uaccess: Split out __get_user_nocheck() To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Thu, 25 Feb 2021 17:50:40 +0000 (UTC) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org One part of __get_user_nocheck() is used for __get_user(), the other part for unsafe_get_user(). Move the part dedicated to unsafe_get_user() in it. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/uaccess.h | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h index a8c683695ec7..678651a615c3 100644 --- a/arch/powerpc/include/asm/uaccess.h +++ b/arch/powerpc/include/asm/uaccess.h @@ -49,7 +49,7 @@ static inline bool __access_ok(unsigned long addr, unsigned long size) __put_user_check((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr))) #define __get_user(x, ptr) \ - __get_user_nocheck((x), (ptr), sizeof(*(ptr)), true) + __get_user_nocheck((x), (ptr), sizeof(*(ptr))) #define __put_user(x, ptr) \ __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr))) @@ -216,19 +216,15 @@ do { \ #define __long_type(x) \ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL)) -#define __get_user_nocheck(x, ptr, size, do_allow) \ +#define __get_user_nocheck(x, ptr, size) \ ({ \ long __gu_err; \ __long_type(*(ptr)) __gu_val; \ __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ __typeof__(size) __gu_size = (size); \ \ - if (do_allow) { \ - might_fault(); \ - __get_user_size(__gu_val, __gu_addr, __gu_size, __gu_err); \ - } else { \ - __get_user_size_allowed(__gu_val, __gu_addr, __gu_size, __gu_err); \ - } \ + might_fault(); \ + __get_user_size(__gu_val, __gu_addr, __gu_size, __gu_err); \ (x) = (__typeof__(*(ptr)))__gu_val; \ \ __gu_err; \ @@ -386,8 +382,14 @@ user_write_access_begin(const void __user *ptr, size_t len) #define user_write_access_end prevent_current_write_to_user #define unsafe_get_user(x, p, e) do { \ - if (unlikely(__get_user_nocheck((x), (p), sizeof(*(p)), false)))\ - goto e; \ + long __gu_err; \ + __long_type(*(p)) __gu_val; \ + __typeof__(*(p)) __user *__gu_addr = (p); \ + \ + __get_user_size_allowed(__gu_val, __gu_addr, sizeof(*(p)), __gu_err); \ + if (__gu_err) \ + goto e; \ + (x) = (__typeof__(*(p)))__gu_val; \ } while (0) #define unsafe_put_user(x, p, e) \ -- 2.25.0