Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp593565pxb; Thu, 25 Feb 2021 09:58:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJxlOg/HpkfiWeBcGYpo2OFSrYL8rH45OPk0jMi4zaEmu38+8j9QL3VywlsN5rxHpFdSUkEZ X-Received: by 2002:aa7:da19:: with SMTP id r25mr4326047eds.367.1614275890241; Thu, 25 Feb 2021 09:58:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614275890; cv=none; d=google.com; s=arc-20160816; b=iKi+OVNXE/Isj5wVsA0zQl2awlvxnsxz17bEbm0+HYUF45HsAOzIxcm7qx8Ss834xU /7WPgK5fXDBwh47THTPiq0/ENllcT6E9Oq+nJJQEYDPUgdaDRoF+bWRbnfAn+0ypzwhr RNlMQs5jV8Kv8FEhaIwPgBK6MoWNpaPyo7Zxk/3oAENVLVidtQ4lHnyLBQ77P+OfFfyF HjqyK6kta/cQu2fb+FdW5o8Y4rqDaVSurvb/MNGbB/WwGd+plZ8cq5m8OPFFC6eaIXw3 tN8kR9c9R8NeDcf8wFSuGGBC5sYklRqzR1hnkmh5bFKpF2UFx3xGKpbihBJ7kRmj3XiH uMMw== 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=PmOehPMq6CWgz6k/qByZs5K704GVPYDOt71NXUoMAIk=; b=iAEOyy03vJSrLqR3crsHQ0Osehl1A99dU8J2XSEWOWuyRTZJyCz/910elhF5od0VuW k6LH4l0N1XxpSub3wU1P9fikglqKXBu4yXbwVZEm/p7KI8npdit6Q+6PlTr415Ig0TRh Tx1tfzi7S8Vsm8oSYadF5wY8LGI90RENgO6mFrpk2fn+YlOIg6FpluNNHM4p6B0AGLMX GAPaOxBGT8nd+jzzRNb3OtfY1EZ/X+Ac/CF5s1AoUXMIeKghPhvRmEApNyJ8TJBsjiau Fu/n51rZUsgSQKQ+eWFJ1x5weNoLoQHkjZrZN14ub8K+BZ8tHjmFe5MkWbfYdB8tGqxM YKww== 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 k24si3506043edq.177.2021.02.25.09.57.47; Thu, 25 Feb 2021 09:58:10 -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 S232631AbhBYR5C (ORCPT + 99 others); Thu, 25 Feb 2021 12:57:02 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:3096 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232778AbhBYRwU (ORCPT ); Thu, 25 Feb 2021 12:52:20 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 4DmgLT6T7Tz9v1BF; Thu, 25 Feb 2021 18:50:41 +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 bufoj8NCcU2h; Thu, 25 Feb 2021 18:50:41 +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 4DmgLT5Ssvz9v19y; Thu, 25 Feb 2021 18:50:41 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 96DAD8B895; Thu, 25 Feb 2021 18:50:43 +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 sOO75PUKSqhN; Thu, 25 Feb 2021 18:50:43 +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 651528B88B; Thu, 25 Feb 2021 18:50:43 +0100 (CET) Received: by po16121vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 3E11F67442; Thu, 25 Feb 2021 17:50:43 +0000 (UTC) Message-Id: In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v1 13/15] powerpc/uaccess: Swap clear_user() and __clear_user() 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:43 +0000 (UTC) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It is clear_user() which is expected to call __clear_user(), not the reverse. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/uaccess.h | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h index 671c083f2f2f..b3bd1fb42242 100644 --- a/arch/powerpc/include/asm/uaccess.h +++ b/arch/powerpc/include/asm/uaccess.h @@ -283,21 +283,20 @@ raw_copy_to_user(void __user *to, const void *from, unsigned long n) unsigned long __arch_clear_user(void __user *addr, unsigned long size); -static inline unsigned long clear_user(void __user *addr, unsigned long size) +static inline unsigned long __clear_user(void __user *addr, unsigned long size) { - unsigned long ret = size; + unsigned long ret; + might_fault(); - if (likely(access_ok(addr, size))) { - allow_write_to_user(addr, size); - ret = __arch_clear_user(addr, size); - prevent_write_to_user(addr, size); - } + allow_write_to_user(addr, size); + ret = __arch_clear_user(addr, size); + prevent_write_to_user(addr, size); return ret; } -static inline unsigned long __clear_user(void __user *addr, unsigned long size) +static inline unsigned long clear_user(void __user *addr, unsigned long size) { - return clear_user(addr, size); + return likely(access_ok(addr, size)) ? __clear_user(addr, size) : size; } extern long strncpy_from_user(char *dst, const char __user *src, long count); -- 2.25.0