提交 dabaad5b 编写于 作者: M Mike Frysinger 提交者: Bryan Wu

Blackfin arch: fix bug -- PTRACE_PEEKDATA does not seem to work which breaks umoven() in strace

Don't add arbitrary offset when peeking at data
Signed-off-by: NMike Frysinger <vapier.adi@gmail.com>
Signed-off-by: NBryan Wu <cooloney@kernel.org>
上级 dd4354fa
...@@ -46,7 +46,6 @@ ...@@ -46,7 +46,6 @@
#include <asm/dma.h> #include <asm/dma.h>
#include <asm/fixed_code.h> #include <asm/fixed_code.h>
#define MAX_SHARED_LIBS 3
#define TEXT_OFFSET 0 #define TEXT_OFFSET 0
/* /*
* does not yet catch signals sent when the child dies. * does not yet catch signals sent when the child dies.
...@@ -192,14 +191,12 @@ void ptrace_disable(struct task_struct *child) ...@@ -192,14 +191,12 @@ void ptrace_disable(struct task_struct *child)
long arch_ptrace(struct task_struct *child, long request, long addr, long data) long arch_ptrace(struct task_struct *child, long request, long addr, long data)
{ {
int ret; int ret;
int add = 0;
unsigned long __user *datap = (unsigned long __user *)data; unsigned long __user *datap = (unsigned long __user *)data;
switch (request) { switch (request) {
/* when I and D space are separate, these will need to be fixed. */ /* when I and D space are separate, these will need to be fixed. */
case PTRACE_PEEKDATA: case PTRACE_PEEKDATA:
pr_debug("ptrace: PEEKDATA\n"); pr_debug("ptrace: PEEKDATA\n");
add = MAX_SHARED_LIBS * 4; /* space between text and data */
/* fall through */ /* fall through */
case PTRACE_PEEKTEXT: /* read word at location addr. */ case PTRACE_PEEKTEXT: /* read word at location addr. */
{ {
...@@ -207,39 +204,38 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) ...@@ -207,39 +204,38 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
int copied; int copied;
ret = -EIO; ret = -EIO;
pr_debug("ptrace: PEEKTEXT at addr 0x%08lx + add %d %ld\n", addr, add, pr_debug("ptrace: PEEKTEXT at addr 0x%08lx + %ld\n", addr, sizeof(data));
sizeof(data)); if (is_user_addr_valid(child, addr, sizeof(tmp)) < 0)
if (is_user_addr_valid(child, addr + add, sizeof(tmp)) < 0)
break; break;
pr_debug("ptrace: user address is valid\n"); pr_debug("ptrace: user address is valid\n");
#if L1_CODE_LENGTH != 0 #if L1_CODE_LENGTH != 0
if (addr + add >= L1_CODE_START if (addr >= L1_CODE_START
&& addr + add + sizeof(tmp) <= L1_CODE_START + L1_CODE_LENGTH) { && addr + sizeof(tmp) <= L1_CODE_START + L1_CODE_LENGTH) {
safe_dma_memcpy (&tmp, (const void *)(addr + add), sizeof(tmp)); safe_dma_memcpy (&tmp, (const void *)(addr), sizeof(tmp));
copied = sizeof(tmp); copied = sizeof(tmp);
} else } else
#endif #endif
#if L1_DATA_A_LENGTH != 0 #if L1_DATA_A_LENGTH != 0
if (addr + add >= L1_DATA_A_START if (addr >= L1_DATA_A_START
&& addr + add + sizeof(tmp) <= L1_DATA_A_START + L1_DATA_A_LENGTH) { && addr + sizeof(tmp) <= L1_DATA_A_START + L1_DATA_A_LENGTH) {
memcpy(&tmp, (const void *)(addr + add), sizeof(tmp)); memcpy(&tmp, (const void *)(addr), sizeof(tmp));
copied = sizeof(tmp); copied = sizeof(tmp);
} else } else
#endif #endif
#if L1_DATA_B_LENGTH != 0 #if L1_DATA_B_LENGTH != 0
if (addr + add >= L1_DATA_B_START if (addr >= L1_DATA_B_START
&& addr + add + sizeof(tmp) <= L1_DATA_B_START + L1_DATA_B_LENGTH) { && addr + sizeof(tmp) <= L1_DATA_B_START + L1_DATA_B_LENGTH) {
memcpy(&tmp, (const void *)(addr + add), sizeof(tmp)); memcpy(&tmp, (const void *)(addr), sizeof(tmp));
copied = sizeof(tmp); copied = sizeof(tmp);
} else } else
#endif #endif
if (addr + add >= FIXED_CODE_START if (addr >= FIXED_CODE_START
&& addr + add + sizeof(tmp) <= FIXED_CODE_END) { && addr + sizeof(tmp) <= FIXED_CODE_END) {
memcpy(&tmp, (const void *)(addr + add), sizeof(tmp)); memcpy(&tmp, (const void *)(addr), sizeof(tmp));
copied = sizeof(tmp); copied = sizeof(tmp);
} else } else
copied = access_process_vm(child, addr + add, &tmp, copied = access_process_vm(child, addr, &tmp,
sizeof(tmp), 0); sizeof(tmp), 0);
pr_debug("ptrace: copied size %d [0x%08lx]\n", copied, tmp); pr_debug("ptrace: copied size %d [0x%08lx]\n", copied, tmp);
if (copied != sizeof(tmp)) if (copied != sizeof(tmp))
...@@ -291,39 +287,39 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) ...@@ -291,39 +287,39 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
int copied; int copied;
ret = -EIO; ret = -EIO;
pr_debug("ptrace: POKETEXT at addr 0x%08lx + add %d %ld bytes %lx\n", pr_debug("ptrace: POKETEXT at addr 0x%08lx + %ld bytes %lx\n",
addr, add, sizeof(data), data); addr, sizeof(data), data);
if (is_user_addr_valid(child, addr + add, sizeof(data)) < 0) if (is_user_addr_valid(child, addr, sizeof(data)) < 0)
break; break;
pr_debug("ptrace: user address is valid\n"); pr_debug("ptrace: user address is valid\n");
#if L1_CODE_LENGTH != 0 #if L1_CODE_LENGTH != 0
if (addr + add >= L1_CODE_START if (addr >= L1_CODE_START
&& addr + add + sizeof(data) <= L1_CODE_START + L1_CODE_LENGTH) { && addr + sizeof(data) <= L1_CODE_START + L1_CODE_LENGTH) {
safe_dma_memcpy ((void *)(addr + add), &data, sizeof(data)); safe_dma_memcpy ((void *)(addr), &data, sizeof(data));
copied = sizeof(data); copied = sizeof(data);
} else } else
#endif #endif
#if L1_DATA_A_LENGTH != 0 #if L1_DATA_A_LENGTH != 0
if (addr + add >= L1_DATA_A_START if (addr >= L1_DATA_A_START
&& addr + add + sizeof(data) <= L1_DATA_A_START + L1_DATA_A_LENGTH) { && addr + sizeof(data) <= L1_DATA_A_START + L1_DATA_A_LENGTH) {
memcpy((void *)(addr + add), &data, sizeof(data)); memcpy((void *)(addr), &data, sizeof(data));
copied = sizeof(data); copied = sizeof(data);
} else } else
#endif #endif
#if L1_DATA_B_LENGTH != 0 #if L1_DATA_B_LENGTH != 0
if (addr + add >= L1_DATA_B_START if (addr >= L1_DATA_B_START
&& addr + add + sizeof(data) <= L1_DATA_B_START + L1_DATA_B_LENGTH) { && addr + sizeof(data) <= L1_DATA_B_START + L1_DATA_B_LENGTH) {
memcpy((void *)(addr + add), &data, sizeof(data)); memcpy((void *)(addr), &data, sizeof(data));
copied = sizeof(data); copied = sizeof(data);
} else } else
#endif #endif
if (addr + add >= FIXED_CODE_START if (addr >= FIXED_CODE_START
&& addr + add + sizeof(data) <= FIXED_CODE_END) { && addr + sizeof(data) <= FIXED_CODE_END) {
memcpy((void *)(addr + add), &data, sizeof(data)); memcpy((void *)(addr), &data, sizeof(data));
copied = sizeof(data); copied = sizeof(data);
} else } else
copied = access_process_vm(child, addr + add, &data, copied = access_process_vm(child, addr, &data,
sizeof(data), 1); sizeof(data), 1);
pr_debug("ptrace: copied size %d\n", copied); pr_debug("ptrace: copied size %d\n", copied);
if (copied != sizeof(data)) if (copied != sizeof(data))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册