Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2526250imm; Mon, 28 May 2018 09:45:41 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpDk4HHqTViN3YaoEYuBD5wx1O4ytwPsfwgVnKQwlBedeQ188g/mS2iVVPSUI4t3klPWGZL X-Received: by 2002:a63:7a11:: with SMTP id v17-v6mr11087336pgc.97.1527525940976; Mon, 28 May 2018 09:45:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527525940; cv=none; d=google.com; s=arc-20160816; b=G8etnVvyTn4MYgiIigUwe9MI7tBao4KFazElSjpqnckwThaTReRx+fiG/3+4Z4QCFJ iDGf8JUydESgnbgiboU98gI31vIh1RMnEEXfmYXAtRbj2EQktkZb8BD/CyPWoc7Uyylp EyhUJmFEeJ5veGiuawbGiKJGWWaWYTVlMvE41w5y8NBqwOf5bd+b7c00ESqBLL0qvVT5 XYNPuIGiL52BVOkTTEDHamP9H/oUX8w4MXvFYQCVhUv1p9BDNdczQZn/cbVbXtxlj/zy 46ZqWduVJHcfo4NZvYqc1EbWOHekYEve3L2w5s9K3jRcOuUq1SuchJl0IkcsHIK/m4uw l5HQ== 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=dGtzPX4HbC3Bx7107+j1YYQAWk0bGQEpvjeHrdch1eY=; b=mxuCFBXEodzLV5wevvcGZIbPlFuOneA5WXc0SFYdjlJcPPic4ju30qaVf9QvCm/BLX HNU3AGKexg+VxIHH2SCGzs2S5XZZrxU027cPrUOU9hbjLxeZ5rl1yLs/NDO2tDvZnhAh OR69tB+MmzA9sVZLw4xTZdX4LvybeeVGdr9QDMkMhG6k8BmRlrMadqVlndwKK+mLYzMX KLvO0ftOXfsj7ALL9OoAO3TD1uAo4VeM7+FC9lUDg5XDl89id3yxq6/AJDvObWFHAIFE D3sJR0bVLYfGkDbP8Y4znbEpERhT1ApqzrD/5D9+qs2MOOuDBqPSPiEZ7/HT8q3HL5dP skvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QdU+kIaZ; 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 x3-v6si30249580plb.478.2018.05.28.09.45.26; Mon, 28 May 2018 09:45:40 -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=QdU+kIaZ; 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 S940435AbeE1Qnv (ORCPT + 99 others); Mon, 28 May 2018 12:43:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:55532 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754200AbeE1KH3 (ORCPT ); Mon, 28 May 2018 06:07:29 -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 706962089D; Mon, 28 May 2018 10:07:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527502049; bh=deQIjyeEFU3VAxWbSKrp3WIMbkjjGXziWM4zIAJWLSI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QdU+kIaZXlt0BLBRHtlUfY/vTUf6HS9jIR93akS6bPHmRPiMUvagKIRP8trxoBjZD e+TL3pEvpFbqkMa/haD+pSiKQkkbEvS/KZMQy5eAOMA1CkXAfoZHDsCmVepQolIiip WSirPdnwAn5dxvCan2jnXR+30t30n3ez9OnmHhCc= 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 3.18 001/185] MIPS: ptrace: Expose FIR register through FP regset Date: Mon, 28 May 2018 12:00:42 +0200 Message-Id: <20180528100050.786410467@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180528100050.700971285@linuxfoundation.org> References: <20180528100050.700971285@linuxfoundation.org> User-Agent: quilt/0.65 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 3.18-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 @@ -444,7 +444,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, @@ -452,6 +452,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)) @@ -464,6 +465,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; } @@ -512,7 +519,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 @@ -526,6 +534,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; @@ -551,6 +560,11 @@ static int fpr_set(struct task_struct *t target->thread.fpu.fcr31 = fcr31 & ~FPU_CSR_ALL_X; } + if (count > 0) + err = user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf, + fir_pos, + fir_pos + sizeof(u32)); + return err; }