tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   aea23e7c464bfdec04b52cf61edb62030e9e0d0a
commit: 3f805f8cc23ba35679dd01446929292911c2b469 LoadPin: Enable loading from 
trusted dm-verity devices
config: s390-randconfig-m031-20220810 
(https://download.01.org/0day-ci/archive/20220814/[email protected]/config)
compiler: s390-linux-gcc (GCC) 12.1.0

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <[email protected]>
Reported-by: Dan Carpenter <[email protected]>

smatch warnings:
security/loadpin/loadpin.c:365 dm_verity_ioctl() warn: maybe return -EFAULT 
instead of the bytes remaining?

vim +365 security/loadpin/loadpin.c

3f805f8cc23ba3 Matthias Kaehlcke 2022-06-27  355  static long 
dm_verity_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
3f805f8cc23ba3 Matthias Kaehlcke 2022-06-27  356  {
3f805f8cc23ba3 Matthias Kaehlcke 2022-06-27  357        void __user *uarg = 
(void __user *)arg;
3f805f8cc23ba3 Matthias Kaehlcke 2022-06-27  358        unsigned int fd;
3f805f8cc23ba3 Matthias Kaehlcke 2022-06-27  359        int rc;
3f805f8cc23ba3 Matthias Kaehlcke 2022-06-27  360  
3f805f8cc23ba3 Matthias Kaehlcke 2022-06-27  361        switch (cmd) {
3f805f8cc23ba3 Matthias Kaehlcke 2022-06-27  362        case 
LOADPIN_IOC_SET_TRUSTED_VERITY_DIGESTS:
3f805f8cc23ba3 Matthias Kaehlcke 2022-06-27  363                rc = 
copy_from_user(&fd, uarg, sizeof(fd));
3f805f8cc23ba3 Matthias Kaehlcke 2022-06-27  364                if (rc)
3f805f8cc23ba3 Matthias Kaehlcke 2022-06-27 @365                        return 
rc;

The copy_from_user() function returns the number of bytes remaining to
be copied.  It should be:

        if (copy_from_user(&fd, uarg, sizeof(fd)))
                return -EFAULT;

3f805f8cc23ba3 Matthias Kaehlcke 2022-06-27  366  
3f805f8cc23ba3 Matthias Kaehlcke 2022-06-27  367                return 
read_trusted_verity_root_digests(fd);
3f805f8cc23ba3 Matthias Kaehlcke 2022-06-27  368  
3f805f8cc23ba3 Matthias Kaehlcke 2022-06-27  369        default:
3f805f8cc23ba3 Matthias Kaehlcke 2022-06-27  370                return -EINVAL;
3f805f8cc23ba3 Matthias Kaehlcke 2022-06-27  371        }
3f805f8cc23ba3 Matthias Kaehlcke 2022-06-27  372  }

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp
_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to