aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Martin <Dave.Martin@arm.com>2017-03-27 10:10:56 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-03-29 11:54:17 -0400
commit5fe81fe98123ce41265c65e95d34418d30d005d1 (patch)
tree954670ad1295ea964db35e4af2449179d7364245
parenta78ce80d2c9178351b34d78fec805140c29c193e (diff)
metag/ptrace: Provide default TXSTATUS for short NT_PRSTATUS
Ensure that if userspace supplies insufficient data to PTRACE_SETREGSET to fill TXSTATUS, a well-defined default value is used, based on the task's current value. Suggested-by: James Hogan <james.hogan@imgtec.com> Signed-off-by: Dave Martin <Dave.Martin@arm.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--arch/metag/kernel/ptrace.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/arch/metag/kernel/ptrace.c b/arch/metag/kernel/ptrace.c
index ae659ba61948..2e4dfc15abd3 100644
--- a/arch/metag/kernel/ptrace.c
+++ b/arch/metag/kernel/ptrace.c
@@ -24,6 +24,16 @@
24 * user_regset definitions. 24 * user_regset definitions.
25 */ 25 */
26 26
27static unsigned long user_txstatus(const struct pt_regs *regs)
28{
29 unsigned long data = (unsigned long)regs->ctx.Flags;
30
31 if (regs->ctx.SaveMask & TBICTX_CBUF_BIT)
32 data |= USER_GP_REGS_STATUS_CATCH_BIT;
33
34 return data;
35}
36
27int metag_gp_regs_copyout(const struct pt_regs *regs, 37int metag_gp_regs_copyout(const struct pt_regs *regs,
28 unsigned int pos, unsigned int count, 38 unsigned int pos, unsigned int count,
29 void *kbuf, void __user *ubuf) 39 void *kbuf, void __user *ubuf)
@@ -62,9 +72,7 @@ int metag_gp_regs_copyout(const struct pt_regs *regs,
62 if (ret) 72 if (ret)
63 goto out; 73 goto out;
64 /* TXSTATUS */ 74 /* TXSTATUS */
65 data = (unsigned long)regs->ctx.Flags; 75 data = user_txstatus(regs);
66 if (regs->ctx.SaveMask & TBICTX_CBUF_BIT)
67 data |= USER_GP_REGS_STATUS_CATCH_BIT;
68 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, 76 ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
69 &data, 4*25, 4*26); 77 &data, 4*25, 4*26);
70 if (ret) 78 if (ret)
@@ -119,6 +127,7 @@ int metag_gp_regs_copyin(struct pt_regs *regs,
119 if (ret) 127 if (ret)
120 goto out; 128 goto out;
121 /* TXSTATUS */ 129 /* TXSTATUS */
130 data = user_txstatus(regs);
122 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, 131 ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
123 &data, 4*25, 4*26); 132 &data, 4*25, 4*26);
124 if (ret) 133 if (ret)