Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2954997imm; Mon, 28 May 2018 20:52:05 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKZymxFsFUjtQLyFrfq84Xxq+GbhBDZyqbSB9dMeOH3XNAEcikSmpedrzFpDGbspQewbGmZ X-Received: by 2002:a65:6157:: with SMTP id o23-v6mr5045781pgv.310.1527565925772; Mon, 28 May 2018 20:52:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527565925; cv=none; d=google.com; s=arc-20160816; b=tYLt5+Zn5QCGCC80IuXwc7JIEXcEkZM+5POVbct1A+KVSKWKs3TKAGVOjDxDe535+Z UpxNbNIHFNPdoDOK7/LHd4XtK6VqBAqr13434ZCJHc4UTSonBXDJXe8Mb5PsiBw0els8 yVSD7mArP71+JyckaAGELEoU8T6JlRp0I+l8fkoITn7vhtT2CRgrcrFbVA3h/R8R/zFE T4OoEAOmqedbhGEvEtX/64+GLttT0TSzibZxG7JNGn6O2pEbugFQ8hUfFtP+eSyFmJkH mM/wzvd0mUorNpGFEXGgt2Hf10iaG7Go+bX8rWklxSpzP8Jpcg8V1vBy5h63LupDnayW /mGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=3b3+PunDVVC4Tdw6veuO3AW5Ub8BUNGWaLcNIqAaKIo=; b=B7vrs8NLCeKeff5fpEETLgFTZVLQoKnEBcZFVE44XoTRjdEkeGE9SmIYwy8a+Uc3d3 c86svuzPH7CU+6htixUeXwssHHyKKPQ6cgGaLiojUNqpnxbuVkHo1eIv7OA69BOm64YV rDLN+uQvmgT3CKExZbxCmrO+Qt69YiOnacD5ur5k1mB77JoX+gHBDfDIK34UhsGGtu7W EhYgi2RV8pRPTTDBT6Vl8eYnygTYkXBrysNCQa7KG+GDogNpQUxkCUo4RY5f1izCelm3 /G6eTKo5CW6AOa0pfUPtt0sN7lTgq4SnfA+D6v5LEEI7UYAz8Nlot9jijUjvU/zQWczT xm8g== 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 h1-v6si1695609pgs.221.2018.05.28.20.51.51; Mon, 28 May 2018 20:52:05 -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 S933931AbeE1UaI (ORCPT + 99 others); Mon, 28 May 2018 16:30:08 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:32788 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932451AbeE1UaH (ORCPT ); Mon, 28 May 2018 16:30:07 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.87 #1 (Red Hat Linux)) id 1fNOmJ-0008Uw-16; Mon, 28 May 2018 20:30:03 +0000 Date: Mon, 28 May 2018 21:30:03 +0100 From: Al Viro To: Mathieu Malaterre Cc: linuxppc-dev , LKML Subject: Re: [PATCH][RFC] [powerpc] arch_ptrace() uses of access_ok() are pointless Message-ID: <20180528203002.GD30522@ZenIV.linux.org.uk> References: <20180527223403.GT30522@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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 > Maybe this is just an RFC, but: > > CALL ../arch/powerpc/kernel/systbl_chk.sh > ../arch/powerpc/kernel/ptrace.c: In function ‘arch_ptrace’: > ../arch/powerpc/kernel/ptrace.c:3086:4: error: expected ‘)’ before ‘return’ > return -EFAULT; > ^~~~~~ and the same a few lines later. What's more, those 'unlikely' are pointless there. Fixed variant follows; only build-tested, though. 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..f557322621e0 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 (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 (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