Commit 2d6532ce authored by Dave Martin's avatar Dave Martin Committed by Greg Kroah-Hartman

metag/ptrace: Provide default TXSTATUS for short NT_PRSTATUS

commit 5fe81fe9 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: default avatarJames Hogan <james.hogan@imgtec.com>
Signed-off-by: default avatarDave Martin <Dave.Martin@arm.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2739b487
...@@ -24,6 +24,16 @@ ...@@ -24,6 +24,16 @@
* user_regset definitions. * user_regset definitions.
*/ */
static unsigned long user_txstatus(const struct pt_regs *regs)
{
unsigned long data = (unsigned long)regs->ctx.Flags;
if (regs->ctx.SaveMask & TBICTX_CBUF_BIT)
data |= USER_GP_REGS_STATUS_CATCH_BIT;
return data;
}
int metag_gp_regs_copyout(const struct pt_regs *regs, int metag_gp_regs_copyout(const struct pt_regs *regs,
unsigned int pos, unsigned int count, unsigned int pos, unsigned int count,
void *kbuf, void __user *ubuf) void *kbuf, void __user *ubuf)
...@@ -62,9 +72,7 @@ int metag_gp_regs_copyout(const struct pt_regs *regs, ...@@ -62,9 +72,7 @@ int metag_gp_regs_copyout(const struct pt_regs *regs,
if (ret) if (ret)
goto out; goto out;
/* TXSTATUS */ /* TXSTATUS */
data = (unsigned long)regs->ctx.Flags; data = user_txstatus(regs);
if (regs->ctx.SaveMask & TBICTX_CBUF_BIT)
data |= USER_GP_REGS_STATUS_CATCH_BIT;
ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
&data, 4*25, 4*26); &data, 4*25, 4*26);
if (ret) if (ret)
...@@ -119,6 +127,7 @@ int metag_gp_regs_copyin(struct pt_regs *regs, ...@@ -119,6 +127,7 @@ int metag_gp_regs_copyin(struct pt_regs *regs,
if (ret) if (ret)
goto out; goto out;
/* TXSTATUS */ /* TXSTATUS */
data = user_txstatus(regs);
ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
&data, 4*25, 4*26); &data, 4*25, 4*26);
if (ret) if (ret)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment