Skip to content

Commit

Permalink
[S390] sparse: fix sparse warnings with __user pointers
Browse files Browse the repository at this point in the history
Use __force to quiet sparse warnings about user address space.

Signed-off-by: Martin Schwidefsky <[email protected]>
  • Loading branch information
Martin Schwidefsky committed Oct 30, 2011
1 parent 5b479a7 commit 3c52e49
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
23 changes: 12 additions & 11 deletions arch/s390/kernel/compat_signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from)
break;
case __SI_FAULT >> 16:
err |= __get_user(tmp, &from->si_addr);
to->si_addr = (void __user *)(u64) (tmp & PSW32_ADDR_INSN);
to->si_addr = (void __force __user *)
(u64) (tmp & PSW32_ADDR_INSN);
break;
case __SI_POLL >> 16:
err |= __get_user(to->si_band, &from->si_band);
Expand Down Expand Up @@ -482,7 +483,7 @@ static int setup_frame32(int sig, struct k_sigaction *ka,
} else {
regs->gprs[14] = (__u64) frame->retcode | PSW32_ADDR_AMODE;
if (__put_user(S390_SYSCALL_OPCODE | __NR_sigreturn,
(u16 __user *)(frame->retcode)))
(u16 __force __user *)(frame->retcode)))
goto give_sigsegv;
}

Expand All @@ -491,20 +492,20 @@ static int setup_frame32(int sig, struct k_sigaction *ka,
goto give_sigsegv;

/* Set up registers for signal handler */
regs->gprs[15] = (__u64) frame;
regs->gprs[15] = (__force __u64) frame;
regs->psw.mask |= PSW_MASK_BA; /* force amode 31 */
regs->psw.addr = (__u64) ka->sa.sa_handler;
regs->psw.addr = (__force __u64) ka->sa.sa_handler;

regs->gprs[2] = map_signal(sig);
regs->gprs[3] = (__u64) &frame->sc;
regs->gprs[3] = (__force __u64) &frame->sc;

/* We forgot to include these in the sigcontext.
To avoid breaking binary compatibility, they are passed as args. */
regs->gprs[4] = current->thread.trap_no;
regs->gprs[5] = current->thread.prot_addr;

/* Place signal number on stack to allow backtrace from handler. */
if (__put_user(regs->gprs[2], (int __user *) &frame->signo))
if (__put_user(regs->gprs[2], (int __force __user *) &frame->signo))
goto give_sigsegv;
return 0;

Expand Down Expand Up @@ -547,21 +548,21 @@ static int setup_rt_frame32(int sig, struct k_sigaction *ka, siginfo_t *info,
} else {
regs->gprs[14] = (__u64) frame->retcode;
err |= __put_user(S390_SYSCALL_OPCODE | __NR_rt_sigreturn,
(u16 __user *)(frame->retcode));
(u16 __force __user *)(frame->retcode));
}

/* Set up backchain. */
if (__put_user(regs->gprs[15], (unsigned int __user *) frame))
if (__put_user(regs->gprs[15], (unsigned int __force __user *) frame))
goto give_sigsegv;

/* Set up registers for signal handler */
regs->gprs[15] = (__u64) frame;
regs->gprs[15] = (__force __u64) frame;
regs->psw.mask |= PSW_MASK_BA; /* force amode 31 */
regs->psw.addr = (__u64) ka->sa.sa_handler;

regs->gprs[2] = map_signal(sig);
regs->gprs[3] = (__u64) &frame->info;
regs->gprs[4] = (__u64) &frame->uc;
regs->gprs[3] = (__force __u64) &frame->info;
regs->gprs[4] = (__force __u64) &frame->uc;
return 0;

give_sigsegv:
Expand Down
3 changes: 2 additions & 1 deletion arch/s390/kernel/traps.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,8 @@ void __kprobes do_per_trap(struct pt_regs *regs)
info.si_signo = SIGTRAP;
info.si_errno = 0;
info.si_code = TRAP_HWBKPT;
info.si_addr = (void *) current->thread.per_event.address;
info.si_addr =
(void __force __user *) current->thread.per_event.address;
force_sig_info(SIGTRAP, &info, current);
}

Expand Down
6 changes: 4 additions & 2 deletions arch/s390/lib/uaccess_pt.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,8 @@ int futex_atomic_op_pt(int op, u32 __user *uaddr, int oparg, int *old)
if (segment_eq(get_fs(), KERNEL_DS))
return __futex_atomic_op_pt(op, uaddr, oparg, old);
spin_lock(&current->mm->page_table_lock);
uaddr = (int __user *) __dat_user_addr((unsigned long) uaddr);
uaddr = (u32 __force __user *)
__dat_user_addr((__force unsigned long) uaddr);
if (!uaddr) {
spin_unlock(&current->mm->page_table_lock);
return -EFAULT;
Expand Down Expand Up @@ -378,7 +379,8 @@ int futex_atomic_cmpxchg_pt(u32 *uval, u32 __user *uaddr,
if (segment_eq(get_fs(), KERNEL_DS))
return __futex_atomic_cmpxchg_pt(uval, uaddr, oldval, newval);
spin_lock(&current->mm->page_table_lock);
uaddr = (int __user *) __dat_user_addr((unsigned long) uaddr);
uaddr = (u32 __force __user *)
__dat_user_addr((__force unsigned long) uaddr);
if (!uaddr) {
spin_unlock(&current->mm->page_table_lock);
return -EFAULT;
Expand Down

0 comments on commit 3c52e49

Please sign in to comment.