Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp774383ybt; Fri, 19 Jun 2020 13:26:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzobDiaS/4qcnK/yjEhKp1enRh+Sg6UD9fLy8Y5+fg7Ek4DgP10coNiJqd02W8MZiGw6ils X-Received: by 2002:a17:906:1196:: with SMTP id n22mr5156765eja.33.1592598367328; Fri, 19 Jun 2020 13:26:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592598367; cv=none; d=google.com; s=arc-20160816; b=YIJ2B9Nv/IHxHBUgHBjy/tLddCZ14CV5JklK1gIfpGh6DUe1YeLs+IJu4S1U0CvLUe twZmyUe1+uIJJHGnD1PlA1sDB2ABVQR0lZUqZftpTrNH0sU1T1thUR0YrKdT9sLAW1gx eM4x19qTBd+o8VFe622Ey44rHYoreVJLUArhoyS/tDSZs6jSR/BoLou4BE/bTMq5UFry OZvfRyxnfDgoxCaK+ExX+twogPc6qInTYbuPtSBtf7tKQcJGDWj4ojeRvo0LPP98+Zyt KkXq2yJ8jnSrvh/UfxfZg4Z147/vcOFe7Ajrh/X06N8I3b4m7Ww0mTxDsLQx5pXA88ld bTkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=C3vMvAXocJ4/XzXs5Neq2bjBEys7sEQLB63X/ppnMqk=; b=nckI8VIaSFosZS7Ts2ub+UBIGi72GvcgJ+4EiePtDW/tPXaQ8buqukvBVGg/4Je918 L+h3bKtoPMZb1T3SkcyX7KSWFET73jnGsxpJnsGuE21hwstPvaw/1Ch9fTbQYxUN8QAU EL5P3hygGIrp07L4YnF0WXQIL53uRFBmDnzR4TjNh9NFPUn2nlLQAZsKvon5EOkt1Aza D19NxGmlJe43KrsWg+qGrW61NB4l/JyJCeS9zKN1NvRFWzLtG4f8eUJL+saFU2g5NDU1 AnVJ9JoEI5xeD/o3DF8StZmX5yaMh3U5PuWPt1ABF9n0caLl6UwdiERA8yRZA0UTzhpi XzBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sYo2yjpI; 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 h5si4427102edr.201.2020.06.19.13.25.45; Fri, 19 Jun 2020 13:26:07 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=sYo2yjpI; 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 S2389622AbgFSOwr (ORCPT + 99 others); Fri, 19 Jun 2020 10:52:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:46340 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389558AbgFSOwS (ORCPT ); Fri, 19 Jun 2020 10:52:18 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7BA51217D8; Fri, 19 Jun 2020 14:52:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592578338; bh=+OZj2jAXCncu9wYrjju7ertIwwrHjJKhK6GfzfHwLvk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sYo2yjpIq7oSjJn1jVX+QBQSbNRfgydMa7Jn/9ena56ImmiwYEcSbZ/iJHhBoMDkh wLDiGhNwvZUgK6Rz6rLFSJCG/cVaCPWJByXy7QlGYNStoJBUSZgEOU80vZpkxAhTvL PPhTdXs4VhrnkaFdZc26HBE98ICJqymbJg0q3Jys= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable@kernel.org, Al Viro Subject: [PATCH 4.14 175/190] sparc64: fix misuses of access_process_vm() in genregs32_[sg]et() Date: Fri, 19 Jun 2020 16:33:40 +0200 Message-Id: <20200619141642.524269755@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141633.446429600@linuxfoundation.org> References: <20200619141633.446429600@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Al Viro commit 142cd25293f6a7ecbdff4fb0af17de6438d46433 upstream. We do need access_process_vm() to access the target's reg_window. However, access to caller's memory (storing the result in genregs32_get(), fetching the new values in case of genregs32_set()) should be done by normal uaccess primitives. Fixes: ad4f95764040 ([SPARC64]: Fix user accesses in regset code.) Cc: stable@kernel.org Signed-off-by: Al Viro Signed-off-by: Greg Kroah-Hartman --- arch/sparc/kernel/ptrace_64.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) --- a/arch/sparc/kernel/ptrace_64.c +++ b/arch/sparc/kernel/ptrace_64.c @@ -571,19 +571,13 @@ static int genregs32_get(struct task_str for (; count > 0 && pos < 32; count--) { if (access_process_vm(target, (unsigned long) - ®_window[pos], + ®_window[pos++], ®, sizeof(reg), FOLL_FORCE) != sizeof(reg)) return -EFAULT; - if (access_process_vm(target, - (unsigned long) u, - ®, sizeof(reg), - FOLL_FORCE | FOLL_WRITE) - != sizeof(reg)) + if (put_user(reg, u++)) return -EFAULT; - pos++; - u++; } } } @@ -683,12 +677,7 @@ static int genregs32_set(struct task_str } } else { for (; count > 0 && pos < 32; count--) { - if (access_process_vm(target, - (unsigned long) - u, - ®, sizeof(reg), - FOLL_FORCE) - != sizeof(reg)) + if (get_user(reg, u++)) return -EFAULT; if (access_process_vm(target, (unsigned long)