Skip to content

Commit e441102

Browse files
Dave Martingregkh
authored andcommitted
metag/ptrace: Provide default TXSTATUS for short NT_PRSTATUS
commit 5fe81fe98123ce41265c65e95d34418d30d005d1 upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 2d9bc36 commit e441102

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

arch/metag/kernel/ptrace.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@
2424
* user_regset definitions.
2525
*/
2626

27+
static 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+
2737
int metag_gp_regs_copyout(const struct pt_regs *regs,
2838
unsigned int pos, unsigned int count,
2939
void *kbuf, void __user *ubuf)
@@ -62,9 +72,7 @@ int metag_gp_regs_copyout(const struct pt_regs *regs,
6272
if (ret)
6373
goto out;
6474
/* TXSTATUS */
65-
data = (unsigned long)regs->ctx.Flags;
66-
if (regs->ctx.SaveMask & TBICTX_CBUF_BIT)
67-
data |= USER_GP_REGS_STATUS_CATCH_BIT;
75+
data = user_txstatus(regs);
6876
ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
6977
&data, 4*25, 4*26);
7078
if (ret)
@@ -119,6 +127,7 @@ int metag_gp_regs_copyin(struct pt_regs *regs,
119127
if (ret)
120128
goto out;
121129
/* TXSTATUS */
130+
data = user_txstatus(regs);
122131
ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
123132
&data, 4*25, 4*26);
124133
if (ret)

0 commit comments

Comments
 (0)