Commit 2227901a authored by Victor Kamensky's avatar Victor Kamensky Committed by Catalin Marinas

arm64: ptrace: fix empty registers set in prstatus of aarch32 process core

Currently core file of aarch32 process prstatus note has empty
registers set. As result aarch32 core files create by V8 kernel are
not very useful.

It happens because compat_gpr_get and compat_gpr_set functions can
copy registers values to/from either kbuf or ubuf. ELF core file
collection function fill_thread_core_info calls compat_gpr_get
with kbuf set and ubuf set to 0. But current compat_gpr_get and
compat_gpr_set function handle copy to/from only ubuf case.

Fix is to handle kbuf and ubuf as two separate cases in similar
way as other functions like user_regset_copyout, user_regset_copyin do.
Signed-off-by: default avatarVictor Kamensky <victor.kamensky@linaro.org>
Acked-by: default avatarWill Deacon <will.deacon@arm.com>
Cc: stable@vger.kernel.org
Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
parent 34c65c43
...@@ -655,11 +655,16 @@ static int compat_gpr_get(struct task_struct *target, ...@@ -655,11 +655,16 @@ static int compat_gpr_get(struct task_struct *target,
reg = task_pt_regs(target)->regs[idx]; reg = task_pt_regs(target)->regs[idx];
} }
ret = copy_to_user(ubuf, &reg, sizeof(reg)); if (kbuf) {
if (ret) memcpy(kbuf, &reg, sizeof(reg));
break; kbuf += sizeof(reg);
} else {
ubuf += sizeof(reg); ret = copy_to_user(ubuf, &reg, sizeof(reg));
if (ret)
break;
ubuf += sizeof(reg);
}
} }
return ret; return ret;
...@@ -689,11 +694,16 @@ static int compat_gpr_set(struct task_struct *target, ...@@ -689,11 +694,16 @@ static int compat_gpr_set(struct task_struct *target,
unsigned int idx = start + i; unsigned int idx = start + i;
compat_ulong_t reg; compat_ulong_t reg;
ret = copy_from_user(&reg, ubuf, sizeof(reg)); if (kbuf) {
if (ret) memcpy(&reg, kbuf, sizeof(reg));
return ret; kbuf += sizeof(reg);
} else {
ret = copy_from_user(&reg, ubuf, sizeof(reg));
if (ret)
return ret;
ubuf += sizeof(reg); ubuf += sizeof(reg);
}
switch (idx) { switch (idx) {
case 15: case 15:
......
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