aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWill Deacon <will.deacon@arm.com>2014-06-02 06:47:23 -0400
committerCatalin Marinas <catalin.marinas@arm.com>2014-06-18 07:40:57 -0400
commitc168870704bcde6bb63d05f7882b620dd3985a46 (patch)
tree174f2ba42679903c0178f1a684adcad893e18b4e
parent2d5a5612bceda8edd25b29f363c4e2c6cda28bab (diff)
arm64: ptrace: change fs when passing kernel pointer to regset code
Our compat PTRACE_POKEUSR implementation simply passes the user data to regset_copy_from_user after some simple range checking. Unfortunately, the data in question has already been copied to the kernel stack by this point, so the subsequent access_ok check fails and the ptrace request returns -EFAULT. This causes problems tracing fork() with older versions of strace. This patch briefly changes the fs to KERNEL_DS, so that the access_ok check passes even with a kernel address. Signed-off-by: Will Deacon <will.deacon@arm.com> Cc: <stable@vger.kernel.org> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
-rw-r--r--arch/arm64/kernel/ptrace.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
index 3e926b9c0641..993cdb79b70e 100644
--- a/arch/arm64/kernel/ptrace.c
+++ b/arch/arm64/kernel/ptrace.c
@@ -827,6 +827,7 @@ static int compat_ptrace_write_user(struct task_struct *tsk, compat_ulong_t off,
827 compat_ulong_t val) 827 compat_ulong_t val)
828{ 828{
829 int ret; 829 int ret;
830 mm_segment_t old_fs = get_fs();
830 831
831 if (off & 3 || off >= COMPAT_USER_SZ) 832 if (off & 3 || off >= COMPAT_USER_SZ)
832 return -EIO; 833 return -EIO;
@@ -834,10 +835,13 @@ static int compat_ptrace_write_user(struct task_struct *tsk, compat_ulong_t off,
834 if (off >= sizeof(compat_elf_gregset_t)) 835 if (off >= sizeof(compat_elf_gregset_t))
835 return 0; 836 return 0;
836 837
838 set_fs(KERNEL_DS);
837 ret = copy_regset_from_user(tsk, &user_aarch32_view, 839 ret = copy_regset_from_user(tsk, &user_aarch32_view,
838 REGSET_COMPAT_GPR, off, 840 REGSET_COMPAT_GPR, off,
839 sizeof(compat_ulong_t), 841 sizeof(compat_ulong_t),
840 &val); 842 &val);
843 set_fs(old_fs);
844
841 return ret; 845 return ret;
842} 846}
843 847