Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1760495imm; Sun, 27 May 2018 15:34:32 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp3cexGqCr/hwcnh06YapTXDyM113Smbsa7HzyXvQMXobzAcWihsAgcmPbQkN+6qx3Yo7rt X-Received: by 2002:aa7:81cc:: with SMTP id c12-v6mr11172100pfn.169.1527460471985; Sun, 27 May 2018 15:34:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527460471; cv=none; d=google.com; s=arc-20160816; b=XRZoWkqhoJnOUW7gc3ShgzrmOKYIVX4sHC/aaS35N6/npOAAihQEtO0rG07VXnMuVm n9RY/U2gjxdMKQdwCyg4Gi/Q4yPl+MRok6KXRXNkyzD2DkIOqmYEXvLRjO6de+rSPY9L zlwkpAVd+qkKiQHbVq/Ze5HbSIE7yOrlseS4/sxWdbx7VFEZ5Y18KfBdsFAQfWKnM9BH xhtZ0s75msfTdZRvsslIACFf6JaRSwhB5n/O7Ms7p4eLghMzgJsG7JlSy8VsLME/7RoS MQAtMg4olCakhiqIL9ZuHkTxGZnXzRVrf0rVobvt0qsCmlbfner6a2cZrqbIBMhYyY9B zDKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date :arc-authentication-results; bh=7xIFkik0Wnjt3WqIyPqHJz6UD2psZ9xaUldvK/qHT3o=; b=TEKp2G1wLUFV5NTAECbd8cJOCCygx0Na12mngz5rA7Z5TvDf4KbS0tDU4565bYG9dU POhimQEUIKOQYLrZ0FBmFZACKcyBR8nO5LDIsyhiSuzcVRO/2D9doeNKo6bW6z8LUziu dRB9ihuc8QK18hQA8QRvmSr3AyCWtC3d+dp0518qTpeCANoETWuHUbdRa05BnQbRLGsy YNG2szznQ+UBsSDqgmmmFOs+c20wQ21Cajcqo0xxHy5sDrEqcY267Sj+ZdiOu9yp07Ge fTJKhbw1jGrn3x5+OT85gdyKZwYjq2Z2YCVQ5fkGNwxwERuERzBfpUY6SbhnOoYnzCK0 AJHw== 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 n2-v6si29954655plk.433.2018.05.27.15.34.15; Sun, 27 May 2018 15:34:31 -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 S1752177AbeE0WeI (ORCPT + 99 others); Sun, 27 May 2018 18:34:08 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:51088 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751879AbeE0WeF (ORCPT ); Sun, 27 May 2018 18:34:05 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.87 #1 (Red Hat Linux)) id 1fN4El-00086m-EI; Sun, 27 May 2018 22:34:03 +0000 Date: Sun, 27 May 2018 23:34:03 +0100 From: Al Viro To: linuxppc-dev@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, Michael Ellerman Subject: [PATCH][RFC] [powerpc] arch_ptrace() uses of access_ok() are pointless Message-ID: <20180527223403.GT30522@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org make it use copy_{from,to}_user(), rather than access_ok() + __copy_... Signed-off-by: Al Viro --- arch/powerpc/kernel/ptrace.c | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c index d23cf632edf0..d8b0fd2fa3aa 100644 --- a/arch/powerpc/kernel/ptrace.c +++ b/arch/powerpc/kernel/ptrace.c @@ -3081,27 +3081,19 @@ long arch_ptrace(struct task_struct *child, long request, #endif /* CONFIG_HAVE_HW_BREAKPOINT */ #endif /* CONFIG_PPC_ADV_DEBUG_REGS */ - if (!access_ok(VERIFY_WRITE, datavp, - sizeof(struct ppc_debug_info))) + if (unlikely(copy_to_user(datavp, &dbginfo, + sizeof(struct ppc_debug_info))) return -EFAULT; - ret = __copy_to_user(datavp, &dbginfo, - sizeof(struct ppc_debug_info)) ? - -EFAULT : 0; - break; + return 0; } case PPC_PTRACE_SETHWDEBUG: { struct ppc_hw_breakpoint bp_info; - if (!access_ok(VERIFY_READ, datavp, - sizeof(struct ppc_hw_breakpoint))) - return -EFAULT; - ret = __copy_from_user(&bp_info, datavp, - sizeof(struct ppc_hw_breakpoint)) ? - -EFAULT : 0; - if (!ret) - ret = ppc_set_hwdebug(child, &bp_info); - break; + if (unlikely(copy_from_user(&bp_info, datavp, + sizeof(struct ppc_hw_breakpoint))) + return -EFAULT; + return ppc_set_hwdebug(child, &bp_info); } case PPC_PTRACE_DELHWDEBUG: { -- 2.11.0