Skip to content

Commit ca42bc4

Browse files
Al ViroRich Felker
authored andcommitted
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 <[email protected]> Tested-by: John Paul Adrian Glaubitz <[email protected]> Signed-off-by: Rich Felker <[email protected]>
1 parent 6880fa6 commit ca42bc4

File tree

5 files changed

+13
-12
lines changed

5 files changed

+13
-12
lines changed

arch/sh/include/asm/checksum_32.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ static inline __sum16 csum_fold(__wsum sum)
8484
*/
8585
static inline __sum16 ip_fast_csum(const void *iph, unsigned int ihl)
8686
{
87-
unsigned int sum, __dummy0, __dummy1;
87+
__wsum sum;
88+
unsigned int __dummy0, __dummy1;
8889

8990
__asm__ __volatile__(
9091
"mov.l @%1+, %0\n\t"
@@ -197,6 +198,6 @@ static inline __wsum csum_and_copy_to_user(const void *src,
197198
{
198199
if (!access_ok(dst, len))
199200
return 0;
200-
return csum_partial_copy_generic((__force const void *)src, dst, len);
201+
return csum_partial_copy_generic(src, (__force void *)dst, len);
201202
}
202203
#endif /* __ASM_SH_CHECKSUM_H */

arch/sh/include/asm/uaccess.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ struct __large_struct { unsigned long buf[100]; };
6868
({ \
6969
long __gu_err = -EFAULT; \
7070
unsigned long __gu_val = 0; \
71-
const __typeof__(*(ptr)) *__gu_addr = (ptr); \
71+
const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \
7272
if (likely(access_ok(__gu_addr, (size)))) \
7373
__get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
7474
(x) = (__force __typeof__(*(ptr)))__gu_val; \
@@ -124,7 +124,7 @@ raw_copy_to_user(void __user *to, const void *from, unsigned long n)
124124
* Clear the area and return remaining number of bytes
125125
* (on failure. Usually it's 0.)
126126
*/
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);
128128

129129
#define clear_user(addr,n) \
130130
({ \

arch/sh/kernel/traps_32.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ asmlinkage void do_address_error(struct pt_regs *regs,
490490
inc_unaligned_user_access();
491491

492492
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),
494494
sizeof(instruction))) {
495495
force_uaccess_end(oldfs);
496496
goto uspace_segv;
@@ -614,7 +614,7 @@ asmlinkage void do_reserved_inst(void)
614614
unsigned short inst = 0;
615615
int err;
616616

617-
get_user(inst, (unsigned short*)regs->pc);
617+
get_user(inst, (unsigned short __user *)regs->pc);
618618

619619
err = do_fpu_inst(inst, regs);
620620
if (!err) {
@@ -699,9 +699,9 @@ asmlinkage void do_illegal_slot_inst(void)
699699
return;
700700

701701
#ifdef CONFIG_SH_FPU_EMU
702-
get_user(inst, (unsigned short *)regs->pc + 1);
702+
get_user(inst, (unsigned short __user *)regs->pc + 1);
703703
if (!do_fpu_inst(inst, regs)) {
704-
get_user(inst, (unsigned short *)regs->pc);
704+
get_user(inst, (unsigned short __user *)regs->pc);
705705
if (!emulate_branch(inst, regs))
706706
return;
707707
/* fault in branch.*/

arch/sh/math-emu/math.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
#define Rn (regs->regs[n])
5252
#define Rm (regs->regs[m])
5353

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;})
5656

5757
#define PACK_S(r,f) FP_PACK_SP(&r,f)
5858
#define UNPACK_S(f,r) FP_UNPACK_SP(f,&r)

arch/sh/mm/nommu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ __kernel_size_t __copy_user(void *to, const void *from, __kernel_size_t n)
2828
return 0;
2929
}
3030

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)
3232
{
33-
memset(to, 0, n);
33+
memset((__force void *)to, 0, n);
3434
return 0;
3535
}
3636

0 commit comments

Comments
 (0)