From patchwork Fri Jun 19 14:33:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 223689 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA3CFC433E1 for ; Fri, 19 Jun 2020 16:42:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AC0E6206B7 for ; Fri, 19 Jun 2020 16:42:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592584953; bh=YGB3RjlvoFqQ6Gp0s5xKy1Vy0GNUVzaHRZx854z92ug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Cl1U4rfr2WEmcVAl0rnLqT2AvAGOOruzP+cpE7XwAsnUUGBLCwmtY9L9J7SbGsGDJ s5A2VvkNRhUuRCIHDWIyKSJ2Mp60AH/lte5jUZ8tsw/Uf5qZ+UOGSqBqGHqIjW4rx+ gM4Fy+xxBg+PQBsR0TFY4A+n/1izknY5uF25B2QY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2395359AbgFSQmc (ORCPT ); Fri, 19 Jun 2020 12:42:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:35596 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388551AbgFSOoT (ORCPT ); Fri, 19 Jun 2020 10:44:19 -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 EF89E21707; Fri, 19 Jun 2020 14:44:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592577859; bh=YGB3RjlvoFqQ6Gp0s5xKy1Vy0GNUVzaHRZx854z92ug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ot+PvC/Az55ACdKwqXvRI1XthgWSDTCLlqiVYLeg9BWiL4vYPYu/RXHMLeaKGyAl9 q3NA5hzCnNOa/AMGMngvKQYOfaJK4m+GIgzIa5Ri5UGBeSnCZTEESjgcISWtF9nA3j 4XryfGLz6LtgjcX/Jr9LzdZ0NXUO6glvkOTB97cY= 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.9 117/128] sparc64: fix misuses of access_process_vm() in genregs32_[sg]et() Date: Fri, 19 Jun 2020 16:33:31 +0200 Message-Id: <20200619141626.312794435@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141620.148019466@linuxfoundation.org> References: <20200619141620.148019466@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 @@ -533,19 +533,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++; } } } @@ -645,12 +639,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)