Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp593245pxb; Thu, 25 Feb 2021 09:57:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJzxB4a/jUUnQahsWd/GtCCVHc7aX+R1gHltIuGcMSwfURd3ABPXAZDRdNZO+1n+hjqn6zIB X-Received: by 2002:a17:907:110c:: with SMTP id qu12mr1556775ejb.442.1614275851072; Thu, 25 Feb 2021 09:57:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614275851; cv=none; d=google.com; s=arc-20160816; b=EEIBS4uc/NYICfGHuoD5tqkzujQO6QDeUw3616lHgIwkD4UaDt4ajSV0Mm55wkcy9V aKHRGPTidzuPSuEoBZWkW2WSjneTUUp6/UrmNHhRNYMbwCNKytPLnd56bwY2FdDyfv7Z C3z8yueUndkgxqGkNYrq85BSJEthWr7b01HJ3mQKhUWbvq3uIoGAekuUaYDq4lc5Y0J0 q9P6A8IkysvIZDq1sXSj5JuNMEiCj+ntMxDiKJ8aa0KsM3RkfEOTZaZNleMfbIa45Tyh h68wQL/9Wr2SK8+Kj7f0o/NW4qbofQR0Jd1fUTnKfs2PsXoUGHbus3vqqmxwNb5BA57X 6yUg== 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=ABRxJjMIbhxGu77BCm6oAaw1H892tyOPynZZRAOmaog=; b=JuwAie9KBbRwb57JBq9Ig71rZp41GFccPut7EvxBT/51g0I9XNQSpEfF4AxESGOMlc jIfynXoeMoAPQMOjmkhk3R3ZrysckbmdN2bJx5Q0aMbq4cY2qopJr8Xi0TtSaNkfxubh 8cLOTvLBQfhPfzoXdTbMNnGhoefjEVTNjsw4uhOL/LeRG/pOOBV6VHWFzToLYi8C69O/ g/XIWfnqoMKxWvVMIGYoB+83GxT+f2SK4HzRmbSzsEnuTDyDjwmvPttGHZgb597tTzz7 RpQ+2znv0XSverLLdZVuGLY0H9aKzAIRV7nJwkwaO+hv4Kf7dyn76kMHjP7rR9aTUjcf YoUg== 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 fj2si3784536ejc.472.2021.02.25.09.57.08; Thu, 25 Feb 2021 09:57:31 -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 S233068AbhBYR4S (ORCPT + 99 others); Thu, 25 Feb 2021 12:56:18 -0500 Received: from pegase1.c-s.fr ([93.17.236.30]:24656 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232804AbhBYRwR (ORCPT ); Thu, 25 Feb 2021 12:52:17 -0500 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 4DmgLK5ypCz9v1B5; Thu, 25 Feb 2021 18:50:33 +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 Z9Pb4fbjnuJQ; Thu, 25 Feb 2021 18:50:33 +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 4DmgLK3p0zz9v19y; Thu, 25 Feb 2021 18:50:33 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 5BA528B895; Thu, 25 Feb 2021 18:50:35 +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 I9ck2BO1wRgn; Thu, 25 Feb 2021 18:50:35 +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 2A1758B88B; Thu, 25 Feb 2021 18:50:35 +0100 (CET) Received: by po16121vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 04CD167442; Thu, 25 Feb 2021 17:50:35 +0000 (UTC) Message-Id: <66b96f8a598b2835855a0ae26ff47bcfff448e9c.1614275314.git.christophe.leroy@csgroup.eu> In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v1 05/15] powerpc/align: Don't use __get_user_instr() on kernel addresses 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:35 +0000 (UTC) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the old days, when we didn't have kernel userspace access protection and had set_fs(), it was wise to use __get_user() and friends to read kernel memory. Nowadays, get_user() is granting userspace access and is exclusively for userspace access. In alignment exception handler, use probe_kernel_read_inst() instead of __get_user_instr() for reading instructions in kernel. This will allow to remove the is_kernel_addr() check in __get/put_user() in a following patch. Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/align.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/align.c b/arch/powerpc/kernel/align.c index 83b199026a1e..55e262627b53 100644 --- a/arch/powerpc/kernel/align.c +++ b/arch/powerpc/kernel/align.c @@ -305,7 +305,11 @@ int fix_alignment(struct pt_regs *regs) */ CHECK_FULL_REGS(regs); - if (unlikely(__get_user_instr(instr, (void __user *)regs->nip))) + if (is_kernel_addr(regs->nip)) + r = probe_kernel_read_inst(&instr, (void *)regs->nip); + else + r = __get_user_instr(instr, (void __user *)regs->nip); + if (unlikely(r)) return -EFAULT; if ((regs->msr & MSR_LE) != (MSR_KERNEL & MSR_LE)) { /* We don't handle PPC little-endian any more... */ -- 2.25.0