Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

sh: fix trivial misannotations

Trivial misannotations in
* get_user() (__gu_addr is a userland pointer there)
* ip_fast_csum() (sum is __wsum, not unsigned int)
* csum_and_copy_to_user() (destination is void *, not const void * -
mea culpa)
* __clear_user() (to is a userland pointer)
* several places in kernel/traps_32.c (regs->pc is a userland pointer
when regs is a userland pt_regs)
* math-emu/math.c: READ() and WRITE() casts of address should be to
userland pointer.

No changes in code generation and those take care of the majority of
noise from sparse on sh builds.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Tested-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Signed-off-by: Rich Felker <dalias@libc.org>

authored by

Al Viro and committed by
Rich Felker
ca42bc4b 6880fa6c

+13 -12
+3 -2
arch/sh/include/asm/checksum_32.h
··· 84 84 */ 85 85 static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl) 86 86 { 87 - unsigned int sum, __dummy0, __dummy1; 87 + __wsum sum; 88 + unsigned int __dummy0, __dummy1; 88 89 89 90 __asm__ __volatile__( 90 91 "mov.l @%1+, %0\n\t" ··· 198 197 { 199 198 if (!access_ok(dst, len)) 200 199 return 0; 201 - return csum_partial_copy_generic((__force const void *)src, dst, len); 200 + return csum_partial_copy_generic(src, (__force void *)dst, len); 202 201 } 203 202 #endif /* __ASM_SH_CHECKSUM_H */
+2 -2
arch/sh/include/asm/uaccess.h
··· 68 68 ({ \ 69 69 long __gu_err = -EFAULT; \ 70 70 unsigned long __gu_val = 0; \ 71 - const __typeof__(*(ptr)) *__gu_addr = (ptr); \ 71 + const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ 72 72 if (likely(access_ok(__gu_addr, (size)))) \ 73 73 __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \ 74 74 (x) = (__force __typeof__(*(ptr)))__gu_val; \ ··· 124 124 * Clear the area and return remaining number of bytes 125 125 * (on failure. Usually it's 0.) 126 126 */ 127 - __kernel_size_t __clear_user(void *addr, __kernel_size_t size); 127 + __kernel_size_t __clear_user(void __user *addr, __kernel_size_t size); 128 128 129 129 #define clear_user(addr,n) \ 130 130 ({ \
+4 -4
arch/sh/kernel/traps_32.c
··· 490 490 inc_unaligned_user_access(); 491 491 492 492 oldfs = force_uaccess_begin(); 493 - if (copy_from_user(&instruction, (insn_size_t *)(regs->pc & ~1), 493 + if (copy_from_user(&instruction, (insn_size_t __user *)(regs->pc & ~1), 494 494 sizeof(instruction))) { 495 495 force_uaccess_end(oldfs); 496 496 goto uspace_segv; ··· 614 614 unsigned short inst = 0; 615 615 int err; 616 616 617 - get_user(inst, (unsigned short*)regs->pc); 617 + get_user(inst, (unsigned short __user *)regs->pc); 618 618 619 619 err = do_fpu_inst(inst, regs); 620 620 if (!err) { ··· 699 699 return; 700 700 701 701 #ifdef CONFIG_SH_FPU_EMU 702 - get_user(inst, (unsigned short *)regs->pc + 1); 702 + get_user(inst, (unsigned short __user *)regs->pc + 1); 703 703 if (!do_fpu_inst(inst, regs)) { 704 - get_user(inst, (unsigned short *)regs->pc); 704 + get_user(inst, (unsigned short __user *)regs->pc); 705 705 if (!emulate_branch(inst, regs)) 706 706 return; 707 707 /* fault in branch.*/
+2 -2
arch/sh/math-emu/math.c
··· 51 51 #define Rn (regs->regs[n]) 52 52 #define Rm (regs->regs[m]) 53 53 54 - #define WRITE(d,a) ({if(put_user(d, (typeof (d)*)a)) return -EFAULT;}) 55 - #define READ(d,a) ({if(get_user(d, (typeof (d)*)a)) return -EFAULT;}) 54 + #define WRITE(d,a) ({if(put_user(d, (typeof (d) __user *)a)) return -EFAULT;}) 55 + #define READ(d,a) ({if(get_user(d, (typeof (d) __user *)a)) return -EFAULT;}) 56 56 57 57 #define PACK_S(r,f) FP_PACK_SP(&r,f) 58 58 #define UNPACK_S(f,r) FP_UNPACK_SP(f,&r)
+2 -2
arch/sh/mm/nommu.c
··· 28 28 return 0; 29 29 } 30 30 31 - __kernel_size_t __clear_user(void *to, __kernel_size_t n) 31 + __kernel_size_t __clear_user(void __user *to, __kernel_size_t n) 32 32 { 33 - memset(to, 0, n); 33 + memset((__force void *)to, 0, n); 34 34 return 0; 35 35 } 36 36