Re: [PATCH v3 fanotify 1/2] fanotify: Introduce fanotify filter

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Song,

kernel test robot noticed the following build warnings:

[auto build test WARNING on jack-fs/fsnotify]
[also build test WARNING on linus/master v6.12 next-20241125]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Song-Liu/fanotify-Introduce-fanotify-filter/20241125-110818
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs.git fsnotify
patch link:    https://lore.kernel.org/r/20241122225958.1775625-2-song%40kernel.org
patch subject: [PATCH v3 fanotify 1/2] fanotify: Introduce fanotify filter
config: i386-randconfig-001-20241125 (https://download.01.org/0day-ci/archive/20241125/202411251801.nLqLjFGW-lkp@xxxxxxxxx/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241125/202411251801.nLqLjFGW-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202411251801.nLqLjFGW-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

   fs/notify/fanotify/fanotify_filter.c: In function 'fanotify_filter_add':
>> fs/notify/fanotify/fanotify_filter.c:226:55: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
     226 |                         if (copy_from_user(init_args, (void __user *)args.init_args,
         |                                                       ^


vim +226 fs/notify/fanotify/fanotify_filter.c

   156	
   157	/*
   158	 * fanotify_filter_add - Add a filter to fsnotify_group.
   159	 *
   160	 * Add a filter from filter_list to a fsnotify_group.
   161	 *
   162	 * @group:	fsnotify_group that will have add
   163	 * @argp:	fanotify_filter_args that specifies the filter
   164	 *		and the init arguments of the filter.
   165	 *
   166	 * Returns:
   167	 *	0	- on success;
   168	 *	-EEXIST	- filter of the same name already exists.
   169	 */
   170	int fanotify_filter_add(struct fsnotify_group *group,
   171				struct fanotify_filter_args __user *argp)
   172	{
   173		struct fanotify_filter_hook *filter_hook;
   174		struct fanotify_filter_ops *filter_ops;
   175		struct fanotify_filter_args args;
   176		void *init_args = NULL;
   177		int ret = 0;
   178	
   179		ret = copy_from_user(&args, argp, sizeof(args));
   180		if (ret)
   181			return -EFAULT;
   182	
   183		if (args.init_args_size > FAN_FILTER_ARGS_MAX)
   184			return -EINVAL;
   185	
   186		args.name[FAN_FILTER_NAME_MAX - 1] = '\0';
   187	
   188		fsnotify_group_lock(group);
   189	
   190		if (rcu_access_pointer(group->fanotify_data.filter_hook)) {
   191			fsnotify_group_unlock(group);
   192			return -EBUSY;
   193		}
   194	
   195		filter_hook = kzalloc(sizeof(*filter_hook), GFP_KERNEL);
   196		if (!filter_hook) {
   197			ret = -ENOMEM;
   198			goto out;
   199		}
   200	
   201		spin_lock(&filter_list_lock);
   202		filter_ops = fanotify_filter_find(args.name);
   203		if (!filter_ops || !try_module_get(filter_ops->owner)) {
   204			spin_unlock(&filter_list_lock);
   205			ret = -ENOENT;
   206			goto err_free_hook;
   207		}
   208		spin_unlock(&filter_list_lock);
   209	
   210		if (!capable(CAP_SYS_ADMIN) && (filter_ops->flags & FAN_FILTER_F_SYS_ADMIN_ONLY)) {
   211			ret = -EPERM;
   212			goto err_module_put;
   213		}
   214	
   215		if (filter_ops->filter_init) {
   216			if (args.init_args_size != filter_ops->init_args_size) {
   217				ret = -EINVAL;
   218				goto err_module_put;
   219			}
   220			if (args.init_args_size) {
   221				init_args = kzalloc(args.init_args_size, GFP_KERNEL);
   222				if (!init_args) {
   223					ret = -ENOMEM;
   224					goto err_module_put;
   225				}
 > 226				if (copy_from_user(init_args, (void __user *)args.init_args,
   227						   args.init_args_size)) {
   228					ret = -EFAULT;
   229					goto err_free_args;
   230				}
   231	
   232			}
   233			ret = filter_ops->filter_init(group, filter_hook, init_args);
   234			if (ret)
   235				goto err_free_args;
   236			kfree(init_args);
   237		}
   238		filter_hook->ops = filter_ops;
   239		rcu_assign_pointer(group->fanotify_data.filter_hook, filter_hook);
   240	
   241	out:
   242		fsnotify_group_unlock(group);
   243		return ret;
   244	
   245	err_free_args:
   246		kfree(init_args);
   247	err_module_put:
   248		module_put(filter_ops->owner);
   249	err_free_hook:
   250		kfree(filter_hook);
   251		goto out;
   252	}
   253	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux