Received: by 10.192.165.148 with SMTP id m20csp4715012imm; Tue, 24 Apr 2018 07:19:34 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+0pHARuden9Zox6tbirl47uvXyQUuY3Si3UpgYLmd1jqOatEO9XKzLFq/gwq4BSYff1+S0 X-Received: by 2002:a17:902:760c:: with SMTP id k12-v6mr25361700pll.338.1524579574434; Tue, 24 Apr 2018 07:19:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524579574; cv=none; d=google.com; s=arc-20160816; b=pSjOqMJ1HwhHFGD7mFJHGFekbvqNZiBinJtMU/4AfpWi+yrMM5hOIlstJtWdZsBS7q wChnupm79LJHMgCgU763l3o6BbmjivP+yy8zvZbY+1CUFalj1ZWsla2WhKIiL+NsZwZ0 SaovxkJAi57Tu4Qs0GOF3lFu/+iSpT24CgxcH4gNuGgtiD/yqFVHnff2qg1cNikbqNRQ C1IWNxlNgAJOMjxzDbq+ElvczURB/f9O8jgaBnO0OFTN7Kr27EGGd/MGArFfVuEnb2fd W+WME0T5+LgniRj4kCBW2wcx8Q4Mf/44xs2LDosStEeGsWLl1/1zP9ljbUeJ74qaHZuk URGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:message-id:cc:to:subject:from :arc-authentication-results; bh=uqbcbMJ+sNmuYb7pKaX5Nq3euJ8k+xY1rDwH6EpRnSM=; b=ddP49u5FngtgwEBGuSR07+0lfWKxBcfRwezijEw34AXBB4xtdWWWCEIyfuMoYfoezv /jCXchOls1Pxpxb9XyfTBUj+lSZqoQWUKwDfGnnFiKOEnUg0FKwMgDJ2eECFlPa4q/PJ 1q1ylsZNddpk6SoBM1KkByBF0YMAIbZHLvF2IH2u7tnUHgJi7HAkJvY3xwP08v+WDYOm gMycyADzk4faaxs0hh2utrxR2GZLmn9yC+PMRm1JYT3X/LcZW5of+UbnJEIVKjNuZItW 90Ivw93xbbwTfbzuCg+5V0m/jeMrYdn6SEvaBjDNf8UaZT1QefuJK9F4/NjavsrVsGnt MuaQ== 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 d26si6351210pge.576.2018.04.24.07.19.19; Tue, 24 Apr 2018 07:19:34 -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 S1758331AbeDXOSE (ORCPT + 99 others); Tue, 24 Apr 2018 10:18:04 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:9048 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758299AbeDXOSB (ORCPT ); Tue, 24 Apr 2018 10:18:01 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 40Vlm73pjYz9ttl8; Tue, 24 Apr 2018 16:17:59 +0200 (CEST) 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 yiLXjNM6h1Pf; Tue, 24 Apr 2018 16:17:59 +0200 (CEST) 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 40Vlm739l2z9ttkf; Tue, 24 Apr 2018 16:17:59 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 65D438B909; Tue, 24 Apr 2018 16:18:00 +0200 (CEST) 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 q2qmoO4XEt2L; Tue, 24 Apr 2018 16:18:00 +0200 (CEST) Received: from po15720vm.idsi0.si.c-s.fr (po15451.idsi0.si.c-s.fr [172.25.231.2]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 359A78B902; Tue, 24 Apr 2018 16:18:00 +0200 (CEST) Received: by po15720vm.idsi0.si.c-s.fr (Postfix, from userid 0) id F02AF6C59D; Tue, 24 Apr 2018 16:17:59 +0200 (CEST) From: Christophe Leroy Subject: [PATCH] powerpc/signal32: Use fault_in_pages_readable() to prefault user context To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Mathieu Malaterre Message-Id: <20180424141759.F02AF6C59D@po15720vm.idsi0.si.c-s.fr> Date: Tue, 24 Apr 2018 16:17:59 +0200 (CEST) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use fault_in_pages_readable() to prefault user context instead of open coding Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/signal_32.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c index 492f03451877..cfacb2726152 100644 --- a/arch/powerpc/kernel/signal_32.c +++ b/arch/powerpc/kernel/signal_32.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #ifdef CONFIG_PPC64 #include @@ -1045,7 +1046,6 @@ long sys_swapcontext(struct ucontext __user *old_ctx, struct ucontext __user *new_ctx, int ctx_size, int r6, int r7, int r8, struct pt_regs *regs) { - unsigned char tmp __maybe_unused; int ctx_has_vsx_region = 0; #ifdef CONFIG_PPC64 @@ -1109,9 +1109,8 @@ long sys_swapcontext(struct ucontext __user *old_ctx, } if (new_ctx == NULL) return 0; - if (!access_ok(VERIFY_READ, new_ctx, ctx_size) - || __get_user(tmp, (u8 __user *) new_ctx) - || __get_user(tmp, (u8 __user *) new_ctx + ctx_size - 1)) + if (!access_ok(VERIFY_READ, new_ctx, ctx_size) || + fault_in_pages_readable((u8 __user *)new_ctx, ctx_size)) return -EFAULT; /* @@ -1231,7 +1230,6 @@ int sys_debug_setcontext(struct ucontext __user *ctx, { struct sig_dbg_op op; int i; - unsigned char tmp __maybe_unused; unsigned long new_msr = regs->msr; #ifdef CONFIG_PPC_ADV_DEBUG_REGS unsigned long new_dbcr0 = current->thread.debug.dbcr0; @@ -1287,9 +1285,8 @@ int sys_debug_setcontext(struct ucontext __user *ctx, current->thread.debug.dbcr0 = new_dbcr0; #endif - if (!access_ok(VERIFY_READ, ctx, sizeof(*ctx)) - || __get_user(tmp, (u8 __user *) ctx) - || __get_user(tmp, (u8 __user *) (ctx + 1) - 1)) + if (!access_ok(VERIFY_READ, ctx, sizeof(*ctx)) || + fault_in_pages_readable((u8 __user *)ctx, 1)) return -EFAULT; /* -- 2.13.3