]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.9.107/mips-prctl-disallow-fre-without-fr-with-pr_set_fp_mode-requests.patch
Fix up backported ptrace patch
[thirdparty/kernel/stable-queue.git] / releases / 4.9.107 / mips-prctl-disallow-fre-without-fr-with-pr_set_fp_mode-requests.patch
1 From 28e4213dd331e944e7fca1954a946829162ed9d4 Mon Sep 17 00:00:00 2001
2 From: "Maciej W. Rozycki" <macro@mips.com>
3 Date: Tue, 15 May 2018 23:04:44 +0100
4 Subject: MIPS: prctl: Disallow FRE without FR with PR_SET_FP_MODE requests
5
6 From: Maciej W. Rozycki <macro@mips.com>
7
8 commit 28e4213dd331e944e7fca1954a946829162ed9d4 upstream.
9
10 Having PR_FP_MODE_FRE (i.e. Config5.FRE) set without PR_FP_MODE_FR (i.e.
11 Status.FR) is not supported as the lone purpose of Config5.FRE is to
12 emulate Status.FR=0 handling on FPU hardware that has Status.FR=1
13 hardwired[1][2]. Also we do not handle this case elsewhere, and assume
14 throughout our code that TIF_HYBRID_FPREGS and TIF_32BIT_FPREGS cannot
15 be set both at once for a task, leading to inconsistent behaviour if
16 this does happen.
17
18 Return unsuccessfully then from prctl(2) PR_SET_FP_MODE calls requesting
19 PR_FP_MODE_FRE to be set with PR_FP_MODE_FR clear. This corresponds to
20 modes allowed by `mips_set_personality_fp'.
21
22 References:
23
24 [1] "MIPS Architecture For Programmers, Vol. III: MIPS32 / microMIPS32
25 Privileged Resource Architecture", Imagination Technologies,
26 Document Number: MD00090, Revision 6.02, July 10, 2015, Table 9.69
27 "Config5 Register Field Descriptions", p. 262
28
29 [2] "MIPS Architecture For Programmers, Volume III: MIPS64 / microMIPS64
30 Privileged Resource Architecture", Imagination Technologies,
31 Document Number: MD00091, Revision 6.03, December 22, 2015, Table
32 9.72 "Config5 Register Field Descriptions", p. 288
33
34 Fixes: 9791554b45a2 ("MIPS,prctl: add PR_[GS]ET_FP_MODE prctl options for MIPS")
35 Signed-off-by: Maciej W. Rozycki <macro@mips.com>
36 Cc: Ralf Baechle <ralf@linux-mips.org>
37 Cc: linux-mips@linux-mips.org
38 Cc: <stable@vger.kernel.org> # 4.0+
39 Patchwork: https://patchwork.linux-mips.org/patch/19327/
40 Signed-off-by: James Hogan <jhogan@kernel.org>
41 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
42
43 ---
44 arch/mips/kernel/process.c | 4 ++++
45 1 file changed, 4 insertions(+)
46
47 --- a/arch/mips/kernel/process.c
48 +++ b/arch/mips/kernel/process.c
49 @@ -699,6 +699,10 @@ int mips_set_process_fp_mode(struct task
50 if (value & ~known_bits)
51 return -EOPNOTSUPP;
52
53 + /* Setting FRE without FR is not supported. */
54 + if ((value & (PR_FP_MODE_FR | PR_FP_MODE_FRE)) == PR_FP_MODE_FRE)
55 + return -EOPNOTSUPP;
56 +
57 /* Avoid inadvertently triggering emulation */
58 if ((value & PR_FP_MODE_FR) && raw_cpu_has_fpu &&
59 !(raw_current_cpu_data.fpu_id & MIPS_FPIR_F64))