All of lore.kernel.org
 help / color / mirror / Atom feed
* fs/notify/fanotify/fanotify_user.c:374:4-13: second lock on line 374
@ 2024-12-01  9:29 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2024-12-01  9:29 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Julia Lawall

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Jan Kara <jack@suse.cz>
CC: Amir Goldstein <amir73il@gmail.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   bcc8eda6d34934d80b96adb8dc4ff5dfc632a53a
commit: 40873284d7106fc0f0f4d2deae74b38fb18342cc fanotify: Track permission event state
date:   6 years ago
:::::: branch date: 7 hours ago
:::::: commit date: 6 years ago
config: i386-randconfig-054-20241118 (https://download.01.org/0day-ci/archive/20241201/202412011707.RghBKABb-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0

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@intel.com>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202412011707.RghBKABb-lkp@intel.com/

cocci warnings: (new ones prefixed by >>)
>> fs/notify/fanotify/fanotify_user.c:374:4-13: second lock on line 374
   fs/notify/fanotify/fanotify_user.c:374:4-13: second lock on line 379
   fs/notify/fanotify/fanotify_user.c:440:1-10: second lock on line 446
   fs/notify/fanotify/fanotify_user.c:440:1-10: second lock on line 463
   fs/notify/fanotify/fanotify_user.c:446:2-11: second lock on line 446
   fs/notify/fanotify/fanotify_user.c:446:2-11: second lock on line 463
   fs/notify/fanotify/fanotify_user.c:463:2-11: second lock on line 463

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

a1014f10232239 Eric Paris      2009-12-17  316  
a1014f10232239 Eric Paris      2009-12-17  317  static ssize_t fanotify_read(struct file *file, char __user *buf,
a1014f10232239 Eric Paris      2009-12-17  318  			     size_t count, loff_t *pos)
a1014f10232239 Eric Paris      2009-12-17  319  {
a1014f10232239 Eric Paris      2009-12-17  320  	struct fsnotify_group *group;
a1014f10232239 Eric Paris      2009-12-17  321  	struct fsnotify_event *kevent;
a1014f10232239 Eric Paris      2009-12-17  322  	char __user *start;
a1014f10232239 Eric Paris      2009-12-17  323  	int ret;
536ebe9ca999f6 Peter Zijlstra  2014-12-16  324  	DEFINE_WAIT_FUNC(wait, woken_wake_function);
a1014f10232239 Eric Paris      2009-12-17  325  
a1014f10232239 Eric Paris      2009-12-17  326  	start = buf;
a1014f10232239 Eric Paris      2009-12-17  327  	group = file->private_data;
a1014f10232239 Eric Paris      2009-12-17  328  
a1014f10232239 Eric Paris      2009-12-17  329  	pr_debug("%s: group=%p\n", __func__, group);
a1014f10232239 Eric Paris      2009-12-17  330  
536ebe9ca999f6 Peter Zijlstra  2014-12-16  331  	add_wait_queue(&group->notification_waitq, &wait);
a1014f10232239 Eric Paris      2009-12-17  332  	while (1) {
a1014f10232239 Eric Paris      2009-12-17  333  		kevent = get_one_event(group, count);
d8aaab4f619acf Jan Kara        2014-04-03  334  		if (IS_ERR(kevent)) {
a1014f10232239 Eric Paris      2009-12-17  335  			ret = PTR_ERR(kevent);
a1014f10232239 Eric Paris      2009-12-17  336  			break;
a1014f10232239 Eric Paris      2009-12-17  337  		}
a1014f10232239 Eric Paris      2009-12-17  338  
d8aaab4f619acf Jan Kara        2014-04-03  339  		if (!kevent) {
a1014f10232239 Eric Paris      2009-12-17  340  			ret = -EAGAIN;
a1014f10232239 Eric Paris      2009-12-17  341  			if (file->f_flags & O_NONBLOCK)
a1014f10232239 Eric Paris      2009-12-17  342  				break;
d8aaab4f619acf Jan Kara        2014-04-03  343  
1a5cea7215f7c6 Lino Sanfilippo 2010-10-29  344  			ret = -ERESTARTSYS;
a1014f10232239 Eric Paris      2009-12-17  345  			if (signal_pending(current))
a1014f10232239 Eric Paris      2009-12-17  346  				break;
a1014f10232239 Eric Paris      2009-12-17  347  
a1014f10232239 Eric Paris      2009-12-17  348  			if (start != buf)
a1014f10232239 Eric Paris      2009-12-17  349  				break;
536ebe9ca999f6 Peter Zijlstra  2014-12-16  350  
536ebe9ca999f6 Peter Zijlstra  2014-12-16  351  			wait_woken(&wait, TASK_INTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT);
d8aaab4f619acf Jan Kara        2014-04-03  352  			continue;
d8aaab4f619acf Jan Kara        2014-04-03  353  		}
d8aaab4f619acf Jan Kara        2014-04-03  354  
5b03a472b4e39c Kees Cook       2018-12-04  355  		ret = copy_event_to_user(group, kevent, buf, count);
4ff33aafd32e08 Amir Goldstein  2017-04-25  356  		if (unlikely(ret == -EOPENSTALE)) {
4ff33aafd32e08 Amir Goldstein  2017-04-25  357  			/*
4ff33aafd32e08 Amir Goldstein  2017-04-25  358  			 * We cannot report events with stale fd so drop it.
4ff33aafd32e08 Amir Goldstein  2017-04-25  359  			 * Setting ret to 0 will continue the event loop and
4ff33aafd32e08 Amir Goldstein  2017-04-25  360  			 * do the right thing if there are no more events to
4ff33aafd32e08 Amir Goldstein  2017-04-25  361  			 * read (i.e. return bytes read, -EAGAIN or wait).
4ff33aafd32e08 Amir Goldstein  2017-04-25  362  			 */
4ff33aafd32e08 Amir Goldstein  2017-04-25  363  			ret = 0;
4ff33aafd32e08 Amir Goldstein  2017-04-25  364  		}
4ff33aafd32e08 Amir Goldstein  2017-04-25  365  
d8aaab4f619acf Jan Kara        2014-04-03  366  		/*
d8aaab4f619acf Jan Kara        2014-04-03  367  		 * Permission events get queued to wait for response.  Other
d8aaab4f619acf Jan Kara        2014-04-03  368  		 * events can be destroyed now.
d8aaab4f619acf Jan Kara        2014-04-03  369  		 */
a0a92d261f2922 Amir Goldstein  2019-01-10  370  		if (!fanotify_is_perm_event(FANOTIFY_E(kevent)->mask)) {
d8aaab4f619acf Jan Kara        2014-04-03  371  			fsnotify_destroy_event(group, kevent);
d507816b58bebc Jan Kara        2014-04-03  372  		} else {
4ff33aafd32e08 Amir Goldstein  2017-04-25  373  			if (ret <= 0) {
40873284d7106f Jan Kara        2019-01-08 @374  				spin_lock(&group->notification_lock);
40873284d7106f Jan Kara        2019-01-08  375  				finish_permission_event(group,
40873284d7106f Jan Kara        2019-01-08  376  					FANOTIFY_PE(kevent), FAN_DENY);
d507816b58bebc Jan Kara        2014-04-03  377  				wake_up(&group->fanotify_data.access_waitq);
4ff33aafd32e08 Amir Goldstein  2017-04-25  378  			} else {
073f65522aeb23 Jan Kara        2016-10-07  379  				spin_lock(&group->notification_lock);
d507816b58bebc Jan Kara        2014-04-03  380  				list_add_tail(&kevent->list,
d507816b58bebc Jan Kara        2014-04-03  381  					&group->fanotify_data.access_list);
073f65522aeb23 Jan Kara        2016-10-07  382  				spin_unlock(&group->notification_lock);
4ff33aafd32e08 Amir Goldstein  2017-04-25  383  			}
d507816b58bebc Jan Kara        2014-04-03  384  		}
4ff33aafd32e08 Amir Goldstein  2017-04-25  385  		if (ret < 0)
4ff33aafd32e08 Amir Goldstein  2017-04-25  386  			break;
d8aaab4f619acf Jan Kara        2014-04-03  387  		buf += ret;
d8aaab4f619acf Jan Kara        2014-04-03  388  		count -= ret;
a1014f10232239 Eric Paris      2009-12-17  389  	}
536ebe9ca999f6 Peter Zijlstra  2014-12-16  390  	remove_wait_queue(&group->notification_waitq, &wait);
a1014f10232239 Eric Paris      2009-12-17  391  
a1014f10232239 Eric Paris      2009-12-17  392  	if (start != buf && ret != -EFAULT)
a1014f10232239 Eric Paris      2009-12-17  393  		ret = buf - start;
a1014f10232239 Eric Paris      2009-12-17  394  	return ret;
a1014f10232239 Eric Paris      2009-12-17  395  }
a1014f10232239 Eric Paris      2009-12-17  396  

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-12-01  9:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-01  9:29 fs/notify/fanotify/fanotify_user.c:374:4-13: second lock on line 374 kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.