lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAFCwf13OiEtbbca1LXuXaVV7xCxrwLiqv_kAoSc7u5AFhSmjrA@mail.gmail.com>
Date:   Wed, 11 May 2022 12:55:10 +0300
From:   Oded Gabbay <ogabbay@...nel.org>
To:     Dan Carpenter <dan.carpenter@...cle.com>
Cc:     kbuild@...ts.01.org, Tal Cohen <talcohen@...ana.ai>,
        kbuild test robot <lkp@...el.com>, kbuild-all@...ts.01.org,
        "Linux-Kernel@...r. Kernel. Org" <linux-kernel@...r.kernel.org>
Subject: Re: [ogabbay:habanalabs-next 47/47] drivers/misc/habanalabs/common/habanalabs_ioctl.c:135
 events_info() warn: maybe return -EFAULT instead of the bytes remaining?

On Wed, May 11, 2022 at 12:41 PM Dan Carpenter <dan.carpenter@...cle.com> wrote:
>
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/ogabbay/linux.git habanalabs-next
> head:   20c59ac5d71e766235e74f353b74e60facd733c8
> commit: 20c59ac5d71e766235e74f353b74e60facd733c8 [47/47] habanalabs: add support for notification via eventfd
> config: x86_64-randconfig-m001-20220509 (https://download.01.org/0day-ci/archive/20220510/202205100736.Y0Vi5Fcf-lkp@intel.com/config)
> compiler: gcc-11 (Debian 11.2.0-20) 11.2.0
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@...el.com>
> Reported-by: Dan Carpenter <dan.carpenter@...cle.com>
>
> smatch warnings:
> drivers/misc/habanalabs/common/habanalabs_ioctl.c:135 events_info() warn: maybe return -EFAULT instead of the bytes remaining?
>
> vim +135 drivers/misc/habanalabs/common/habanalabs_ioctl.c
>
> 20c59ac5d71e76 drivers/misc/habanalabs/common/habanalabs_ioctl.c Tal Cohen   2022-04-28  119  static int events_info(struct hl_fpriv *hpriv, struct hl_info_args *args)
> 20c59ac5d71e76 drivers/misc/habanalabs/common/habanalabs_ioctl.c Tal Cohen   2022-04-28  120  {
> 20c59ac5d71e76 drivers/misc/habanalabs/common/habanalabs_ioctl.c Tal Cohen   2022-04-28  121    int rc;
> 20c59ac5d71e76 drivers/misc/habanalabs/common/habanalabs_ioctl.c Tal Cohen   2022-04-28  122    u32 max_size = args->return_size;
> 20c59ac5d71e76 drivers/misc/habanalabs/common/habanalabs_ioctl.c Tal Cohen   2022-04-28  123    u64 events_mask;
> 20c59ac5d71e76 drivers/misc/habanalabs/common/habanalabs_ioctl.c Tal Cohen   2022-04-28  124    void __user *out = (void __user *) (uintptr_t) args->return_pointer;
> 20c59ac5d71e76 drivers/misc/habanalabs/common/habanalabs_ioctl.c Tal Cohen   2022-04-28  125
> 20c59ac5d71e76 drivers/misc/habanalabs/common/habanalabs_ioctl.c Tal Cohen   2022-04-28  126    if ((max_size < sizeof(u64)) || (!out))
> 20c59ac5d71e76 drivers/misc/habanalabs/common/habanalabs_ioctl.c Tal Cohen   2022-04-28  127            return -EINVAL;
> 20c59ac5d71e76 drivers/misc/habanalabs/common/habanalabs_ioctl.c Tal Cohen   2022-04-28  128
> 20c59ac5d71e76 drivers/misc/habanalabs/common/habanalabs_ioctl.c Tal Cohen   2022-04-28  129    mutex_lock(&hpriv->notifier_event.lock);
> 20c59ac5d71e76 drivers/misc/habanalabs/common/habanalabs_ioctl.c Tal Cohen   2022-04-28  130    events_mask = hpriv->notifier_event.events_mask;
> 20c59ac5d71e76 drivers/misc/habanalabs/common/habanalabs_ioctl.c Tal Cohen   2022-04-28  131    hpriv->notifier_event.events_mask = 0;
> 20c59ac5d71e76 drivers/misc/habanalabs/common/habanalabs_ioctl.c Tal Cohen   2022-04-28  132    mutex_unlock(&hpriv->notifier_event.lock);
> 20c59ac5d71e76 drivers/misc/habanalabs/common/habanalabs_ioctl.c Tal Cohen   2022-04-28  133
> 20c59ac5d71e76 drivers/misc/habanalabs/common/habanalabs_ioctl.c Tal Cohen   2022-04-28  134    rc = copy_to_user(out, &events_mask, sizeof(u64));
> 20c59ac5d71e76 drivers/misc/habanalabs/common/habanalabs_ioctl.c Tal Cohen   2022-04-28 @135    return rc;
>
> copy_to_user() returns the number of bytes remaining (positive).  This
> should be:
>
>         if (copy_to_user(out, &events_mask, sizeof(u64)))
>                 return -EFAULT;
>
>         return 0;
>
> 20c59ac5d71e76 drivers/misc/habanalabs/common/habanalabs_ioctl.c Tal Cohen   2022-04-28  136  }
>
> --
> 0-DAY CI Kernel Test Service
> https://01.org/lkp
>

Correct, thanks, I'll fix it.
Oded

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ