Commit a1f8213b authored by Arnd Bergmann's avatar Arnd Bergmann

score: add address space annotations

Annotate the address space for pointers that are used
correctly with __user and __iomem, so that sparse
can better warn about incorrect casts.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
parent 9fb24cc5
...@@ -13,9 +13,9 @@ extern int fixup_exception(struct pt_regs *regs); ...@@ -13,9 +13,9 @@ extern int fixup_exception(struct pt_regs *regs);
#ifndef __ASSEMBLY__ #ifndef __ASSEMBLY__
#define __range_ok(addr, size) \ #define __range_ok(addr, size) \
((((unsigned long)(addr) >= 0x80000000) \ ((((unsigned long __force)(addr) >= 0x80000000) \
|| ((unsigned long)(size) > 0x80000000) \ || ((unsigned long)(size) > 0x80000000) \
|| (((unsigned long)(addr) + (unsigned long)(size)) > 0x80000000))) || (((unsigned long __force)(addr) + (unsigned long)(size)) > 0x80000000)))
#define __access_ok(addr, size) \ #define __access_ok(addr, size) \
(__range_ok((addr), (size)) == 0) (__range_ok((addr), (size)) == 0)
......
...@@ -267,6 +267,7 @@ long ...@@ -267,6 +267,7 @@ long
arch_ptrace(struct task_struct *child, long request, long addr, long data) arch_ptrace(struct task_struct *child, long request, long addr, long data)
{ {
int ret; int ret;
unsigned long __user *datap = (void __user *)data;
switch (request) { switch (request) {
/* Read the word at location addr in the USER area. */ /* Read the word at location addr in the USER area. */
...@@ -316,7 +317,7 @@ arch_ptrace(struct task_struct *child, long request, long addr, long data) ...@@ -316,7 +317,7 @@ arch_ptrace(struct task_struct *child, long request, long addr, long data)
return -EIO; return -EIO;
} }
ret = put_user(tmp, (unsigned long *) data); ret = put_user(tmp, (unsigned int __user *) datap);
return ret; return ret;
} }
...@@ -355,11 +356,11 @@ arch_ptrace(struct task_struct *child, long request, long addr, long data) ...@@ -355,11 +356,11 @@ arch_ptrace(struct task_struct *child, long request, long addr, long data)
} }
case PTRACE_GETREGS: case PTRACE_GETREGS:
ret = ptrace_getregs(child, (void __user *)data); ret = ptrace_getregs(child, (void __user *)datap);
break; break;
case PTRACE_SETREGS: case PTRACE_SETREGS:
ret = ptrace_setregs(child, (void __user *)data); ret = ptrace_setregs(child, (void __user *)datap);
break; break;
default: default:
......
...@@ -131,13 +131,13 @@ void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs, ...@@ -131,13 +131,13 @@ void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,
if ((ka->sa.sa_flags & SA_ONSTACK) && (!on_sig_stack(sp))) if ((ka->sa.sa_flags & SA_ONSTACK) && (!on_sig_stack(sp)))
sp = current->sas_ss_sp + current->sas_ss_size; sp = current->sas_ss_sp + current->sas_ss_size;
return (void *)((sp - frame_size) & ~7); return (void __user*)((sp - frame_size) & ~7);
} }
int score_sigaltstack(struct pt_regs *regs) int score_sigaltstack(struct pt_regs *regs)
{ {
const stack_t *uss = (const stack_t *) regs->regs[4]; const stack_t __user *uss = (const stack_t __user *) regs->regs[4];
stack_t *uoss = (stack_t *) regs->regs[5]; stack_t __user *uoss = (stack_t __user *) regs->regs[5];
unsigned long usp = regs->regs[0]; unsigned long usp = regs->regs[0];
return do_sigaltstack(uss, uoss, usp); return do_sigaltstack(uss, uoss, usp);
...@@ -188,7 +188,7 @@ void score_rt_sigreturn(struct pt_regs *regs) ...@@ -188,7 +188,7 @@ void score_rt_sigreturn(struct pt_regs *regs)
int setup_rt_frame(struct k_sigaction *ka, struct pt_regs *regs, int setup_rt_frame(struct k_sigaction *ka, struct pt_regs *regs,
int signr, sigset_t *set, siginfo_t *info) int signr, sigset_t *set, siginfo_t *info)
{ {
struct rt_sigframe *frame; struct rt_sigframe __user *frame;
int err = 0; int err = 0;
frame = get_sigframe(ka, regs, sizeof(*frame)); frame = get_sigframe(ka, regs, sizeof(*frame));
...@@ -209,7 +209,7 @@ int setup_rt_frame(struct k_sigaction *ka, struct pt_regs *regs, ...@@ -209,7 +209,7 @@ int setup_rt_frame(struct k_sigaction *ka, struct pt_regs *regs,
err |= copy_siginfo_to_user(&frame->rs_info, info); err |= copy_siginfo_to_user(&frame->rs_info, info);
err |= __put_user(0, &frame->rs_uc.uc_flags); err |= __put_user(0, &frame->rs_uc.uc_flags);
err |= __put_user(0, &frame->rs_uc.uc_link); err |= __put_user(0, &frame->rs_uc.uc_link);
err |= __put_user((void *)current->sas_ss_sp, err |= __put_user((void __user *)current->sas_ss_sp,
&frame->rs_uc.uc_stack.ss_sp); &frame->rs_uc.uc_stack.ss_sp);
err |= __put_user(sas_ss_flags(regs->regs[0]), err |= __put_user(sas_ss_flags(regs->regs[0]),
&frame->rs_uc.uc_stack.ss_flags); &frame->rs_uc.uc_stack.ss_flags);
......
...@@ -87,18 +87,19 @@ int score_clone(struct pt_regs *regs) ...@@ -87,18 +87,19 @@ int score_clone(struct pt_regs *regs)
* sys_execve() executes a new program. * sys_execve() executes a new program.
* This is called indirectly via a small wrapper * This is called indirectly via a small wrapper
*/ */
int score_execve(struct pt_regs *regs) asmlinkage long
score_execve(struct pt_regs *regs)
{ {
int error; int error;
char *filename; char *filename;
filename = getname((char *) (long) regs->regs[4]); filename = getname((char __user*)regs->regs[4]);
error = PTR_ERR(filename); error = PTR_ERR(filename);
if (IS_ERR(filename)) if (IS_ERR(filename))
return error; return error;
error = do_execve(filename, (char **) (long) regs->regs[5], error = do_execve(filename, (char __user *__user*)regs->regs[5],
(char **) (long) regs->regs[6], regs); (char __user *__user *) regs->regs[6], regs);
putname(filename); putname(filename);
return error; return error;
......
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