Re: [PATCH v2 12/18] uaccess: fix type mismatch warnings from access_ok()

2022-02-24 Thread Dinh Nguyen




On 2/16/22 07:13, Arnd Bergmann wrote:

From: Arnd Bergmann 

On some architectures, access_ok() does not do any argument type
checking, so replacing the definition with a generic one causes
a few warnings for harmless issues that were never caught before.

Fix the ones that I found either through my own test builds or
that were reported by the 0-day bot.

Reported-by: kernel test robot 
Signed-off-by: Arnd Bergmann 
---
  arch/arc/kernel/process.c   |  2 +-
  arch/arm/kernel/swp_emulate.c   |  2 +-
  arch/arm/kernel/traps.c |  2 +-
  arch/csky/kernel/signal.c   |  2 +-
  arch/mips/sibyte/common/sb_tbprof.c |  6 +++---
  arch/nios2/kernel/signal.c  | 20 +++-


Acked-by: Dinh Nguyen 

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v2 12/18] uaccess: fix type mismatch warnings from access_ok()

2022-02-17 Thread Christoph Hellwig
Looks good,

Reviewed-by: Christoph Hellwig 

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH v2 12/18] uaccess: fix type mismatch warnings from access_ok()

2022-02-16 Thread Arnd Bergmann
From: Arnd Bergmann 

On some architectures, access_ok() does not do any argument type
checking, so replacing the definition with a generic one causes
a few warnings for harmless issues that were never caught before.

Fix the ones that I found either through my own test builds or
that were reported by the 0-day bot.

Reported-by: kernel test robot 
Signed-off-by: Arnd Bergmann 
---
 arch/arc/kernel/process.c   |  2 +-
 arch/arm/kernel/swp_emulate.c   |  2 +-
 arch/arm/kernel/traps.c |  2 +-
 arch/csky/kernel/signal.c   |  2 +-
 arch/mips/sibyte/common/sb_tbprof.c |  6 +++---
 arch/nios2/kernel/signal.c  | 20 +++-
 arch/powerpc/lib/sstep.c|  4 ++--
 arch/riscv/kernel/perf_callchain.c  |  2 +-
 arch/sparc/kernel/signal_32.c   |  2 +-
 lib/test_lockup.c   |  4 ++--
 10 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/arch/arc/kernel/process.c b/arch/arc/kernel/process.c
index 8e90052f6f05..5f7f5aab361f 100644
--- a/arch/arc/kernel/process.c
+++ b/arch/arc/kernel/process.c
@@ -43,7 +43,7 @@ SYSCALL_DEFINE0(arc_gettls)
return task_thread_info(current)->thr_ptr;
 }
 
-SYSCALL_DEFINE3(arc_usr_cmpxchg, int *, uaddr, int, expected, int, new)
+SYSCALL_DEFINE3(arc_usr_cmpxchg, int __user *, uaddr, int, expected, int, new)
 {
struct pt_regs *regs = current_pt_regs();
u32 uval;
diff --git a/arch/arm/kernel/swp_emulate.c b/arch/arm/kernel/swp_emulate.c
index 6166ba38bf99..b74bfcf94fb1 100644
--- a/arch/arm/kernel/swp_emulate.c
+++ b/arch/arm/kernel/swp_emulate.c
@@ -195,7 +195,7 @@ static int swp_handler(struct pt_regs *regs, unsigned int 
instr)
 destreg, EXTRACT_REG_NUM(instr, RT2_OFFSET), data);
 
/* Check access in reasonable access range for both SWP and SWPB */
-   if (!access_ok((address & ~3), 4)) {
+   if (!access_ok((void __user *)(address & ~3), 4)) {
pr_debug("SWP{B} emulation: access to %p not allowed!\n",
 (void *)address);
res = -EFAULT;
diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
index da04ed85855a..26c8c8276297 100644
--- a/arch/arm/kernel/traps.c
+++ b/arch/arm/kernel/traps.c
@@ -576,7 +576,7 @@ do_cache_op(unsigned long start, unsigned long end, int 
flags)
if (end < start || flags)
return -EINVAL;
 
-   if (!access_ok(start, end - start))
+   if (!access_ok((void __user *)start, end - start))
return -EFAULT;
 
return __do_cache_op(start, end);
diff --git a/arch/csky/kernel/signal.c b/arch/csky/kernel/signal.c
index c7b763d2f526..8867ddf3e6c7 100644
--- a/arch/csky/kernel/signal.c
+++ b/arch/csky/kernel/signal.c
@@ -136,7 +136,7 @@ static inline void __user *get_sigframe(struct ksignal 
*ksig,
 static int
 setup_rt_frame(struct ksignal *ksig, sigset_t *set, struct pt_regs *regs)
 {
-   struct rt_sigframe *frame;
+   struct rt_sigframe __user *frame;
int err = 0;
 
frame = get_sigframe(ksig, regs, sizeof(*frame));
diff --git a/arch/mips/sibyte/common/sb_tbprof.c 
b/arch/mips/sibyte/common/sb_tbprof.c
index f80d7a710333..01d00b87d0f5 100644
--- a/arch/mips/sibyte/common/sb_tbprof.c
+++ b/arch/mips/sibyte/common/sb_tbprof.c
@@ -437,13 +437,13 @@ static int sbprof_tb_release(struct inode *inode, struct 
file *filp)
return 0;
 }
 
-static ssize_t sbprof_tb_read(struct file *filp, char *buf,
+static ssize_t sbprof_tb_read(struct file *filp, char __user *buf,
  size_t size, loff_t *offp)
 {
int cur_sample, sample_off, cur_count, sample_left;
char *src;
int   count   =  0;
-   char *dest=  buf;
+   char __user *dest = buf;
long  cur_off = *offp;
 
if (!access_ok(buf, size))
@@ -512,7 +512,7 @@ static long sbprof_tb_ioctl(struct file *filp,
if (err)
break;
 
-   err = put_user(TB_FULL, (int *) arg);
+   err = put_user(TB_FULL, (int __user *) arg);
break;
}
 
diff --git a/arch/nios2/kernel/signal.c b/arch/nios2/kernel/signal.c
index 2009ae2d3c3b..386e46443b60 100644
--- a/arch/nios2/kernel/signal.c
+++ b/arch/nios2/kernel/signal.c
@@ -36,10 +36,10 @@ struct rt_sigframe {
 
 static inline int rt_restore_ucontext(struct pt_regs *regs,
struct switch_stack *sw,
-   struct ucontext *uc, int *pr2)
+   struct ucontext __user *uc, int *pr2)
 {
int temp;
-   unsigned long *gregs = uc->uc_mcontext.gregs;
+   unsigned long __user *gregs = uc->uc_mcontext.gregs;
int err;
 
/* Always make any pending restarted system calls return -EINTR */
@@ -102,10 +102,11 @@ asmlinkage int do_rt_sigreturn(struct switch_stack *sw)
 {
struct pt_regs *regs = (struct pt_regs *)(sw + 1);
/* Verify, can we