Subject: Re: [PATCH v3 2/7] uaccess: Tell user_access_begin() if it's for a write or not

From: kbuild test robot <[email-masked]>
Date: Sat, 25 Jan 2020 22:40:11 +0800

Hi Christophe,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on powerpc/next]
[also build test ERROR on tip/x86/core drm-intel/for-linux-next v5.5-rc7]
[cannot apply to linus/master next-20200124]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Christophe-Leroy/fs-readdir-Fix-filldir-and-filldir64-use-of-user_access_begin/20200125-070606
base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
config: x86_64-randconfig-s0-20200125 (attached as .config)
compiler: gcc-7 (Debian 7.5.0-3) 7.5.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <[email-masked]>

All error/warnings (new ones prefixed by >>):

   kernel/exit.c: In function '__do_sys_waitid':
>> kernel/exit.c:1567:53: error: macro "user_access_begin" passed 3 arguments, but takes just 2
     key = user_access_begin(infop, sizeof(*infop), true);
                                                        ^
>> kernel/exit.c:1567:6: warning: assignment makes integer from pointer without a cast [-Wint-conversion]
     key = user_access_begin(infop, sizeof(*infop), true);
         ^
   kernel/exit.c: In function '__do_compat_sys_waitid':
   kernel/exit.c:1697:53: error: macro "user_access_begin" passed 3 arguments, but takes just 2
     key = user_access_begin(infop, sizeof(*infop), true);
                                                        ^
   kernel/exit.c:1697:6: warning: assignment makes integer from pointer without a cast [-Wint-conversion]
     key = user_access_begin(infop, sizeof(*infop), true);
         ^
--
   kernel/compat.c: In function 'compat_get_bitmap':
>> kernel/compat.c:267:55: error: macro "user_access_begin" passed 3 arguments, but takes just 2
     key = user_access_begin(umask, bitmap_size / 8, false);
                                                          ^
>> kernel/compat.c:267:6: warning: assignment makes integer from pointer without a cast [-Wint-conversion]
     key = user_access_begin(umask, bitmap_size / 8, false);
         ^
   kernel/compat.c: In function 'compat_put_bitmap':
   kernel/compat.c:298:54: error: macro "user_access_begin" passed 3 arguments, but takes just 2
     key = user_access_begin(umask, bitmap_size / 8, true);
                                                         ^
   kernel/compat.c:298:6: warning: assignment makes integer from pointer without a cast [-Wint-conversion]
     key = user_access_begin(umask, bitmap_size / 8, true);
         ^
--
   fs/readdir.c: In function 'filldir':
>> fs/readdir.c:242:58: error: macro "user_access_begin" passed 3 arguments, but takes just 2
     key = user_access_begin(prev, reclen + prev_reclen, true);
                                                             ^
>> fs/readdir.c:242:6: warning: assignment makes integer from pointer without a cast [-Wint-conversion]
     key = user_access_begin(prev, reclen + prev_reclen, true);
         ^
   fs/readdir.c: In function 'filldir64':
   fs/readdir.c:329:58: error: macro "user_access_begin" passed 3 arguments, but takes just 2
     key = user_access_begin(prev, reclen + prev_reclen, true);
                                                             ^
   fs/readdir.c:329:6: warning: assignment makes integer from pointer without a cast [-Wint-conversion]
     key = user_access_begin(prev, reclen + prev_reclen, true);
         ^
--
   lib/usercopy.c: In function 'check_zeroed_user':
>> lib/usercopy.c:62:43: error: macro "user_access_begin" passed 3 arguments, but takes just 2
     key = user_access_begin(from, size, false);
                                              ^
>> lib/usercopy.c:62:6: warning: assignment makes integer from pointer without a cast [-Wint-conversion]
     key = user_access_begin(from, size, false);
         ^
--
   lib/strncpy_from_user.c: In function 'strncpy_from_user':
>> lib/strncpy_from_user.c:120:42: error: macro "user_access_begin" passed 3 arguments, but takes just 2
      key = user_access_begin(src, max, false);
                                             ^
>> lib/strncpy_from_user.c:120:7: warning: assignment makes integer from pointer without a cast [-Wint-conversion]
      key = user_access_begin(src, max, false);
          ^
--
   lib/strnlen_user.c: In function 'strnlen_user':
>> lib/strnlen_user.c:113:42: error: macro "user_access_begin" passed 3 arguments, but takes just 2
      key = user_access_begin(str, max, false);
                                             ^
>> lib/strnlen_user.c:113:7: warning: assignment makes integer from pointer without a cast [-Wint-conversion]
      key = user_access_begin(str, max, false);
          ^

vim +/user_access_begin +1567 kernel/exit.c

  1548	
  1549	SYSCALL_DEFINE5(waitid, int, which, pid_t, upid, struct siginfo __user *,
  1550			infop, int, options, struct rusage __user *, ru)
  1551	{
  1552		struct rusage r;
  1553		struct waitid_info info = {.status = 0};
  1554		long err = kernel_waitid(which, upid, &info, options, ru ? &r : NULL);
  1555		int signo = 0;
  1556		unsigned long key;
  1557	
  1558		if (err > 0) {
  1559			signo = SIGCHLD;
  1560			err = 0;
  1561			if (ru && copy_to_user(ru, &r, sizeof(struct rusage)))
  1562				return -EFAULT;
  1563		}
  1564		if (!infop)
  1565			return err;
  1566	
> 1567		key = user_access_begin(infop, sizeof(*infop), true);
  1568		if (!key)
  1569			return -EFAULT;
  1570	
  1571		unsafe_put_user(signo, &infop->si_signo, Efault);
  1572		unsafe_put_user(0, &infop->si_errno, Efault);
  1573		unsafe_put_user(info.cause, &infop->si_code, Efault);
  1574		unsafe_put_user(info.pid, &infop->si_pid, Efault);
  1575		unsafe_put_user(info.uid, &infop->si_uid, Efault);
  1576		unsafe_put_user(info.status, &infop->si_status, Efault);
  1577		user_access_end(key);
  1578		return err;
  1579	Efault:
  1580		user_access_end(key);
  1581		return -EFAULT;
  1582	}
  1583	

---
0-DAY kernel test infrastructure                 Open Source Technology Center
https://lists.01.org/hyperkitty/list/[email-masked] Intel Corporation