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-next>] [day] [month] [year] [list]
Date:   Wed, 5 Aug 2020 15:38:45 +0800
From:   kernel test robot <lkp@...el.com>
To:     Amir Goldstein <amir73il@...il.com>
Cc:     kbuild-all@...ts.01.org, linux-kernel@...r.kernel.org,
        Jan Kara <jack@...e.cz>
Subject: fs/notify/fanotify/fanotify_user.c:370:3: warning: Assignment of
 function parameter has no effect outside the function. Did you forget
 dereferencing

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   4da9f3302615f4191814f826054846bf843e24fa
commit: 44d705b0370b1d581f46ff23e5d33e8b5ff8ec58 fanotify: report name info for FAN_DIR_MODIFY event
date:   4 months ago
compiler: nds32le-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@...el.com>


cppcheck warnings: (new ones prefixed by >>)

>> fs/notify/fanotify/fanotify_user.c:370:3: warning: Assignment of function parameter has no effect outside the function. Did you forget dereferencing it? [uselessAssignmentPtrArg]
     buf += ret;
     ^
>> fs/notify/fanotify/fanotify_user.c:371:3: warning: Assignment of function parameter has no effect outside the function. [uselessAssignmentArg]
     count -= ret;
     ^
   fs/notify/fanotify/fanotify_user.c:426:8: warning: Variable 'ret' is reassigned a value before the old one has been used. [redundantAssignment]
      ret = -ERESTARTSYS;
          ^
   fs/notify/fanotify/fanotify_user.c:422:8: note: Variable 'ret' is reassigned a value before the old one has been used.
      ret = -EAGAIN;
          ^
   fs/notify/fanotify/fanotify_user.c:426:8: note: Variable 'ret' is reassigned a value before the old one has been used.
      ret = -ERESTARTSYS;
          ^
   fs/notify/fanotify/fanotify_user.c:613:7: warning: Variable 'ret' is reassigned a value before the old one has been used. [redundantAssignment]
     ret = -ENOTDIR;
         ^
   fs/notify/fanotify/fanotify_user.c:609:7: note: Variable 'ret' is reassigned a value before the old one has been used.
     ret = -EBADF;
         ^
   fs/notify/fanotify/fanotify_user.c:613:7: note: Variable 'ret' is reassigned a value before the old one has been used.
     ret = -ENOTDIR;
         ^
   fs/notify/fanotify/fanotify_user.c:637:6: warning: Variable 'ret' is reassigned a value before the old one has been used. [redundantAssignment]
    ret = inode_permission(path->dentry->d_inode, MAY_READ);
        ^
   fs/notify/fanotify/fanotify_user.c:613:7: note: Variable 'ret' is reassigned a value before the old one has been used.
     ret = -ENOTDIR;
         ^
   fs/notify/fanotify/fanotify_user.c:637:6: note: Variable 'ret' is reassigned a value before the old one has been used.
    ret = inode_permission(path->dentry->d_inode, MAY_READ);
        ^
   fs/notify/fanotify/fanotify_user.c:945:5: warning: Variable 'fd' is reassigned a value before the old one has been used. [redundantAssignment]
    fd = anon_inode_getfd("[fanotify]", &fanotify_fops, group, f_flags);
       ^
   fs/notify/fanotify/fanotify_user.c:922:6: note: Variable 'fd' is reassigned a value before the old one has been used.
     fd = -EPERM;
        ^
   fs/notify/fanotify/fanotify_user.c:945:5: note: Variable 'fd' is reassigned a value before the old one has been used.
    fd = anon_inode_getfd("[fanotify]", &fanotify_fops, group, f_flags);
       ^
   fs/notify/fanotify/fanotify_user.c:945:5: warning: Variable 'fd' is reassigned a value before the old one has been used. [redundantAssignment]
    fd = anon_inode_getfd("[fanotify]", &fanotify_fops, group, f_flags);
       ^
   fs/notify/fanotify/fanotify_user.c:931:6: note: Variable 'fd' is reassigned a value before the old one has been used.
     fd = -EPERM;
        ^
   fs/notify/fanotify/fanotify_user.c:945:5: note: Variable 'fd' is reassigned a value before the old one has been used.
    fd = anon_inode_getfd("[fanotify]", &fanotify_fops, group, f_flags);
       ^
   fs/notify/fanotify/fanotify_user.c:945:5: warning: Variable 'fd' is reassigned a value before the old one has been used. [redundantAssignment]
    fd = anon_inode_getfd("[fanotify]", &fanotify_fops, group, f_flags);
       ^
   fs/notify/fanotify/fanotify_user.c:940:6: note: Variable 'fd' is reassigned a value before the old one has been used.
     fd = -EPERM;
        ^
   fs/notify/fanotify/fanotify_user.c:945:5: note: Variable 'fd' is reassigned a value before the old one has been used.
    fd = anon_inode_getfd("[fanotify]", &fanotify_fops, group, f_flags);
       ^
   fs/notify/fanotify/fanotify_user.c:1086:6: warning: Variable 'ret' is reassigned a value before the old one has been used. [redundantAssignment]
    ret = -EINVAL;
        ^
   fs/notify/fanotify/fanotify_user.c:1077:6: note: Variable 'ret' is reassigned a value before the old one has been used.
    ret = -EINVAL;
        ^
   fs/notify/fanotify/fanotify_user.c:1086:6: note: Variable 'ret' is reassigned a value before the old one has been used.
    ret = -EINVAL;
        ^
   fs/notify/fanotify/fanotify_user.c:1114:6: warning: Variable 'ret' is reassigned a value before the old one has been used. [redundantAssignment]
    ret = fanotify_find_path(dfd, pathname, &path, flags,
        ^
   fs/notify/fanotify/fanotify_user.c:1086:6: note: Variable 'ret' is reassigned a value before the old one has been used.
    ret = -EINVAL;
        ^
   fs/notify/fanotify/fanotify_user.c:1114:6: note: Variable 'ret' is reassigned a value before the old one has been used.
    ret = fanotify_find_path(dfd, pathname, &path, flags,
        ^

vim +370 fs/notify/fanotify/fanotify_user.c

   301	
   302	static ssize_t copy_event_to_user(struct fsnotify_group *group,
   303					  struct fanotify_event *event,
   304					  char __user *buf, size_t count)
   305	{
   306		struct fanotify_event_metadata metadata;
   307		struct path *path = fanotify_event_path(event);
   308		struct file *f = NULL;
   309		int ret, fd = FAN_NOFD;
   310	
   311		pr_debug("%s: group=%p event=%p\n", __func__, group, event);
   312	
   313		metadata.event_len = FAN_EVENT_METADATA_LEN +
   314						fanotify_event_info_len(event);
   315		metadata.metadata_len = FAN_EVENT_METADATA_LEN;
   316		metadata.vers = FANOTIFY_METADATA_VERSION;
   317		metadata.reserved = 0;
   318		metadata.mask = event->mask & FANOTIFY_OUTGOING_EVENTS;
   319		metadata.pid = pid_vnr(event->pid);
   320	
   321		if (path && path->mnt && path->dentry) {
   322			fd = create_fd(group, path, &f);
   323			if (fd < 0)
   324				return fd;
   325		}
   326		metadata.fd = fd;
   327	
   328		ret = -EFAULT;
   329		/*
   330		 * Sanity check copy size in case get_one_event() and
   331		 * fill_event_metadata() event_len sizes ever get out of sync.
   332		 */
   333		if (WARN_ON_ONCE(metadata.event_len > count))
   334			goto out_close_fd;
   335	
   336		if (copy_to_user(buf, &metadata, FAN_EVENT_METADATA_LEN))
   337			goto out_close_fd;
   338	
   339		buf += FAN_EVENT_METADATA_LEN;
   340		count -= FAN_EVENT_METADATA_LEN;
   341	
   342		if (fanotify_is_perm_event(event->mask))
   343			FANOTIFY_PERM(event)->fd = fd;
   344	
   345		if (f)
   346			fd_install(fd, f);
   347	
   348		/* Event info records order is: dir fid + name, child fid */
   349		if (fanotify_event_name_len(event)) {
   350			struct fanotify_name_event *fne = FANOTIFY_NE(event);
   351	
   352			ret = copy_info_to_user(fanotify_event_fsid(event),
   353						fanotify_event_dir_fh(event),
   354						fne->name, fne->name_len,
   355						buf, count);
   356			if (ret < 0)
   357				return ret;
   358	
   359			buf += ret;
   360			count -= ret;
   361		}
   362	
   363		if (fanotify_event_object_fh_len(event)) {
   364			ret = copy_info_to_user(fanotify_event_fsid(event),
   365						fanotify_event_object_fh(event),
   366						NULL, 0, buf, count);
   367			if (ret < 0)
   368				return ret;
   369	
 > 370			buf += ret;
 > 371			count -= ret;
   372		}
   373	
   374		return metadata.event_len;
   375	
   376	out_close_fd:
   377		if (fd != FAN_NOFD) {
   378			put_unused_fd(fd);
   379			fput(f);
   380		}
   381		return ret;
   382	}
   383	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ