Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp594135pxb; Thu, 25 Feb 2021 09:59:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJxBUf45y8fQKRVPTHrgheY/InSbrnD6iE9Abt3CscFTy3twfYizPTmRNF0Y559B9+rYhgrK X-Received: by 2002:aa7:c645:: with SMTP id z5mr4344429edr.126.1614275959390; Thu, 25 Feb 2021 09:59:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614275959; cv=none; d=google.com; s=arc-20160816; b=e8VY5CQK8HFMqk1ebP/xOAp5Y1gBHWhygEnaCl7Yw/k30URoGUl+k8/dm03rnAyhXI sSGZbagDSMZ+Z+K4ibsvXtXQnzutdxmLrTNkU44LL9RkwFw7PtCsGjSbvNg5GUH1cF2Z AvjNQ9zmTPwII3HQhzMhNaYqTRid92LBtiTYTJ/YC8aAGYnzlRVTU7O0sneZpRJ2zuxp h4YWCi5T63OnNufK9n/Otf327/qDledgylwVdMjV/WOE7ZAT0KlTmfUP/yLZsQE253jB SPwr+DsC85stdx9/kRJ9D2dPKhjyOPpVotda0r3rH4MJp8mV0Z1l/hNuFyWSxTw+hTfO S+wQ== 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=vK0IwOJp7BuInTmuRvWVkzzNAKdCJISNQRnDJxluKNU=; b=pQkM/ZjAI+WCbaa0AfqBFV3Zf3bY3OO+aXNQyrqpC8o2gLtmI/YgiRrDNCfJFu4Y3W 8KIFabyUDKR5hnhusNpBaIxCvWt/XGor/4jkIU8N8fQ4yJQF5ngIv3gIEpDgGpe7X4Px h+8C+wU0GsdiYFjABR8h7ASpNJtxHEhgMXxfx+7r7gfHQoOEFKjFkBAjnWO3egkD9r4W QHUS46TBI3/QjU5srXlZHjmtpTV9bCqn2/YPAhC0LGyxzAG+QTGQI9ce3QNnTlDHlTcM 9g4SKb7VtmpkT9vntPmBDar5rWvBZDm4b6vxz59NmGBDoG4mLG9xEpufOt6mojxO9JYN 8cCA== 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 dk7si3880071ejb.570.2021.02.25.09.58.56; Thu, 25 Feb 2021 09:59:19 -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 S232642AbhBYRz4 (ORCPT + 99 others); Thu, 25 Feb 2021 12:55:56 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:49941 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232791AbhBYRwQ (ORCPT ); Thu, 25 Feb 2021 12:52:16 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 4DmgLM0LRyz9v1B6; Thu, 25 Feb 2021 18:50:35 +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 723zQETBnfLL; Thu, 25 Feb 2021 18:50:34 +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 4DmgLL5YzZz9v19y; Thu, 25 Feb 2021 18:50:34 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 66C3E8B895; Thu, 25 Feb 2021 18:50:36 +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 v_z03NBZXZdX; Thu, 25 Feb 2021 18:50:36 +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 30D018B88B; Thu, 25 Feb 2021 18:50:36 +0100 (CET) Received: by po16121vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 0C40667442; Thu, 25 Feb 2021 17:50:36 +0000 (UTC) Message-Id: In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v1 06/15] powerpc/uaccess: Call might_fault() inconditionaly 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:36 +0000 (UTC) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 6bfd93c32a50 ("powerpc: Fix incorrect might_sleep in __get_user/__put_user on kernel addresses") added a check to not call might_sleep() on kernel addresses. This was to enable the use of __get_user() in the alignment exception handler for any address. Then commit 95156f0051cb ("lockdep, mm: fix might_fault() annotation") added a check of the address space in might_fault(), based on set_fs() logic. But this didn't solve the powerpc alignment exception case as it didn't call set_fs(KERNEL_DS). Nowadays, set_fs() is gone, previous patch fixed the alignment exception handler and __get_user/__put_user are not supposed to be used anymore to read kernel memory. Therefore the is_kernel_addr() check has become useless and can be removed. Signed-off-by: Christophe Leroy --- arch/powerpc/include/asm/uaccess.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h index eaa828a6a419..c4bbc64758a0 100644 --- a/arch/powerpc/include/asm/uaccess.h +++ b/arch/powerpc/include/asm/uaccess.h @@ -77,8 +77,7 @@ __pu_failed: \ __typeof__(*(ptr)) __pu_val = (x); \ __typeof__(size) __pu_size = (size); \ \ - if (!is_kernel_addr((unsigned long)__pu_addr)) \ - might_fault(); \ + might_fault(); \ __chk_user_ptr(__pu_addr); \ __put_user_size(__pu_val, __pu_addr, __pu_size, __pu_err); \ \ @@ -238,12 +237,12 @@ do { \ __typeof__(size) __gu_size = (size); \ \ __chk_user_ptr(__gu_addr); \ - if (do_allow && !is_kernel_addr((unsigned long)__gu_addr)) \ + if (do_allow) { \ might_fault(); \ - if (do_allow) \ __get_user_size(__gu_val, __gu_addr, __gu_size, __gu_err); \ - else \ + } else { \ __get_user_size_allowed(__gu_val, __gu_addr, __gu_size, __gu_err); \ + } \ (x) = (__typeof__(*(ptr)))__gu_val; \ \ __gu_err; \ -- 2.25.0