Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2195223imm; Mon, 28 May 2018 03:42:34 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJGV90T1zvdekoOGPhCIEUFSSYjNOpFQ8HlcrvT91TLAXeDXyr4+nqogVBif4C6BoQ2iCaa X-Received: by 2002:a65:4cc3:: with SMTP id n3-v6mr2544018pgt.98.1527504154023; Mon, 28 May 2018 03:42:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527504153; cv=none; d=google.com; s=arc-20160816; b=mEU0bBWcZ5Otg0oicnJBA1XdsGMgahYFdGXRRYVPYwKB69MT1GhBiIvBtRrD08KD6r AFTVK/ZZKixlwwXG9K79DRNCqPk6jQPXH822hQ8nq2IyqcrbArHGi1WWnAO07fappT8N rJT939f7jpf1aYy2sBd53jsZrrqYCmOWJoX+iufmGucR2JjQOOu2DzmMoT70j4rQVQPd AenSaUM7FcM2gap9U6JYNYBBYDWDSVt7oQG2xtT9kVkfTl2iwN4jhwYpEnhdlHQYeCF/ Vy1d4C/0CIKyZxxco9VEpEL5LKTS3JnA1EWvQtsDYvA53MtaIUefa/QDpIruOZM+k9CD p/dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=7kJpTwGWcE+X6cd6ny7dqhuUM98/zx9ws1y0GvfdTX4=; b=boBjxRb1BoPU2OlJv1VSczqWdxt2UoIK+TOvG0HgxGDjCaq+HNwmwoRuzdubFGQmRo gUOjXDH6EI/et5wHuAEcRpjgEfUtQzXsZdXPDt81LxMf3GoY04z4jhlST2MJm+l5zrux Jev+B+gw21RgoJ5aPCpc+MNQ3Oaw4qK+oCsFk94WjOUz4y/CKVIpJzz2E5DkDQAgSxLE 0hzlAb2VRsOvGQK02Va0u10S3Gign0wOlk3NdT67YrlE2G8M1zlTpCWg/586Iy/zLXpJ J93frU0Tfc/BS6DFwxmWvEqf7N5SbJJhiEL5beJbue1wsr7tnUI3+o+qNAig+yuKF0+E tjaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BqOtn3nQ; 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 8-v6si30477297plc.444.2018.05.28.03.42.19; Mon, 28 May 2018 03:42:33 -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; dkim=pass header.i=@kernel.org header.s=default header.b=BqOtn3nQ; 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 S932469AbeE1KmB (ORCPT + 99 others); Mon, 28 May 2018 06:42:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:33374 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1163025AbeE1Kl5 (ORCPT ); Mon, 28 May 2018 06:41:57 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (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 E10592086D; Mon, 28 May 2018 10:41:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527504116; bh=3d0r0u4M5FSe+2sX2I5gX0nuaoA2tZlZ4OW678koVqE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BqOtn3nQ0RMG3v41H74STBwnZwyNDkcE9Pgx2I/k/7WrgjdItGp1YoeXlzrI3hRPa bqcz7V09Tc2i2Z2h0mEoYrtvvwgtcJXzEwiBjL5n2uJJSsYQBHzg/gsc7gU7ivX7d5 bLjEtL86Hc/7pQ/vT3LF1KefhbJFvw/y6tS6G6Gc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, James Hogan , "Maciej W. Rozycki" , Ralf Baechle , linux-mips@linux-mips.org Subject: [PATCH 4.14 002/496] MIPS: ptrace: Expose FIR register through FP regset Date: Mon, 28 May 2018 11:56:27 +0200 Message-Id: <20180528100319.614328600@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100319.498712256@linuxfoundation.org> References: <20180528100319.498712256@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Maciej W. Rozycki commit 71e909c0cdad28a1df1fa14442929e68615dee45 upstream. Correct commit 7aeb753b5353 ("MIPS: Implement task_user_regset_view.") and expose the FIR register using the unused 4 bytes at the end of the NT_PRFPREG regset. Without that register included clients cannot use the PTRACE_GETREGSET request to retrieve the complete FPU register set and have to resort to one of the older interfaces, either PTRACE_PEEKUSR or PTRACE_GETFPREGS, to retrieve the missing piece of data. Also the register is irreversibly missing from core dumps. This register is architecturally hardwired and read-only so the write path does not matter. Ignore data supplied on writes then. Fixes: 7aeb753b5353 ("MIPS: Implement task_user_regset_view.") Signed-off-by: James Hogan Signed-off-by: Maciej W. Rozycki Cc: Ralf Baechle Cc: linux-mips@linux-mips.org Cc: # 3.13+ Patchwork: https://patchwork.linux-mips.org/patch/19273/ Signed-off-by: James Hogan Signed-off-by: Greg Kroah-Hartman --- arch/mips/kernel/ptrace.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) --- a/arch/mips/kernel/ptrace.c +++ b/arch/mips/kernel/ptrace.c @@ -454,7 +454,7 @@ static int fpr_get_msa(struct task_struc /* * Copy the floating-point context to the supplied NT_PRFPREG buffer. * Choose the appropriate helper for general registers, and then copy - * the FCSR register separately. + * the FCSR and FIR registers separately. */ static int fpr_get(struct task_struct *target, const struct user_regset *regset, @@ -462,6 +462,7 @@ static int fpr_get(struct task_struct *t void *kbuf, void __user *ubuf) { const int fcr31_pos = NUM_FPU_REGS * sizeof(elf_fpreg_t); + const int fir_pos = fcr31_pos + sizeof(u32); int err; if (sizeof(target->thread.fpu.fpr[0]) == sizeof(elf_fpreg_t)) @@ -474,6 +475,12 @@ static int fpr_get(struct task_struct *t err = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &target->thread.fpu.fcr31, fcr31_pos, fcr31_pos + sizeof(u32)); + if (err) + return err; + + err = user_regset_copyout(&pos, &count, &kbuf, &ubuf, + &boot_cpu_data.fpu_id, + fir_pos, fir_pos + sizeof(u32)); return err; } @@ -522,7 +529,8 @@ static int fpr_set_msa(struct task_struc /* * Copy the supplied NT_PRFPREG buffer to the floating-point context. * Choose the appropriate helper for general registers, and then copy - * the FCSR register separately. + * the FCSR register separately. Ignore the incoming FIR register + * contents though, as the register is read-only. * * We optimize for the case where `count % sizeof(elf_fpreg_t) == 0', * which is supposed to have been guaranteed by the kernel before @@ -536,6 +544,7 @@ static int fpr_set(struct task_struct *t const void *kbuf, const void __user *ubuf) { const int fcr31_pos = NUM_FPU_REGS * sizeof(elf_fpreg_t); + const int fir_pos = fcr31_pos + sizeof(u32); u32 fcr31; int err; @@ -563,6 +572,11 @@ static int fpr_set(struct task_struct *t ptrace_setfcr31(target, fcr31); } + if (count > 0) + err = user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf, + fir_pos, + fir_pos + sizeof(u32)); + return err; }