Lines Matching refs:group

195 static void fanotify_unhash_event(struct fsnotify_group *group,  in fanotify_unhash_event()  argument
198 assert_spin_locked(&group->notification_lock); in fanotify_unhash_event()
201 group, event, fanotify_event_hash_bucket(group, event)); in fanotify_unhash_event()
215 static struct fanotify_event *get_one_event(struct fsnotify_group *group, in get_one_event() argument
221 unsigned int info_mode = FAN_GROUP_FLAG(group, FANOTIFY_INFO_MODES); in get_one_event()
223 pr_debug("%s: group=%p count=%zd\n", __func__, group, count); in get_one_event()
225 spin_lock(&group->notification_lock); in get_one_event()
226 fsn_event = fsnotify_peek_first_event(group); in get_one_event()
242 fsnotify_remove_first_event(group); in get_one_event()
246 fanotify_unhash_event(group, event); in get_one_event()
248 spin_unlock(&group->notification_lock); in get_one_event()
252 static int create_fd(struct fsnotify_group *group, const struct path *path, in create_fd() argument
258 client_fd = get_unused_fd_flags(group->fanotify_data.f_flags); in create_fd()
267 group->fanotify_data.f_flags | __FMODE_NONOTIFY, in create_fd()
310 static void finish_permission_event(struct fsnotify_group *group, in finish_permission_event() argument
313 __releases(&group->notification_lock) in finish_permission_event()
317 assert_spin_locked(&group->notification_lock); in finish_permission_event()
326 spin_unlock(&group->notification_lock); in finish_permission_event()
328 fsnotify_destroy_event(group, &event->fae.fse); in finish_permission_event()
331 static int process_access_response(struct fsnotify_group *group, in process_access_response() argument
343 group, fd, response, info, info_len); in process_access_response()
360 if ((response & FAN_AUDIT) && !FAN_GROUP_FLAG(group, FAN_ENABLE_AUDIT)) in process_access_response()
376 spin_lock(&group->notification_lock); in process_access_response()
377 list_for_each_entry(event, &group->fanotify_data.access_list, in process_access_response()
383 finish_permission_event(group, event, response, &friar); in process_access_response()
384 wake_up(&group->fanotify_data.access_waitq); in process_access_response()
387 spin_unlock(&group->notification_lock); in process_access_response()
657 static ssize_t copy_event_to_user(struct fsnotify_group *group, in copy_event_to_user() argument
664 unsigned int info_mode = FAN_GROUP_FLAG(group, FANOTIFY_INFO_MODES); in copy_event_to_user()
669 pr_debug("%s: group=%p event=%p\n", __func__, group, event); in copy_event_to_user()
682 if (FAN_GROUP_FLAG(group, FANOTIFY_UNPRIV) && in copy_event_to_user()
692 if (!FAN_GROUP_FLAG(group, FANOTIFY_UNPRIV) && in copy_event_to_user()
694 fd = create_fd(group, path, &f); in copy_event_to_user()
707 WARN_ON_ONCE(FAN_GROUP_FLAG(group, FAN_REPORT_TID)); in copy_event_to_user()
771 struct fsnotify_group *group = file->private_data; in fanotify_poll() local
774 poll_wait(file, &group->notification_waitq, wait); in fanotify_poll()
775 spin_lock(&group->notification_lock); in fanotify_poll()
776 if (!fsnotify_notify_queue_is_empty(group)) in fanotify_poll()
778 spin_unlock(&group->notification_lock); in fanotify_poll()
786 struct fsnotify_group *group; in fanotify_read() local
793 group = file->private_data; in fanotify_read()
795 pr_debug("%s: group=%p\n", __func__, group); in fanotify_read()
797 add_wait_queue(&group->notification_waitq, &wait); in fanotify_read()
804 event = get_one_event(group, count); in fanotify_read()
826 ret = copy_event_to_user(group, event, buf, count); in fanotify_read()
842 fsnotify_destroy_event(group, &event->fse); in fanotify_read()
845 spin_lock(&group->notification_lock); in fanotify_read()
846 finish_permission_event(group, in fanotify_read()
848 wake_up(&group->fanotify_data.access_waitq); in fanotify_read()
850 spin_lock(&group->notification_lock); in fanotify_read()
852 &group->fanotify_data.access_list); in fanotify_read()
853 spin_unlock(&group->notification_lock); in fanotify_read()
861 remove_wait_queue(&group->notification_waitq, &wait); in fanotify_read()
871 struct fsnotify_group *group; in fanotify_write() local
879 group = file->private_data; in fanotify_write()
881 pr_debug("%s: group=%p count=%zu\n", __func__, group, count); in fanotify_write()
891 ret = process_access_response(group, &response, info_buf, info_len); in fanotify_write()
902 struct fsnotify_group *group = file->private_data; in fanotify_release() local
910 fsnotify_group_stop_queueing(group); in fanotify_release()
916 spin_lock(&group->notification_lock); in fanotify_release()
917 while (!list_empty(&group->fanotify_data.access_list)) { in fanotify_release()
920 event = list_first_entry(&group->fanotify_data.access_list, in fanotify_release()
923 finish_permission_event(group, event, FAN_ALLOW, NULL); in fanotify_release()
924 spin_lock(&group->notification_lock); in fanotify_release()
932 while ((fsn_event = fsnotify_remove_first_event(group))) { in fanotify_release()
936 spin_unlock(&group->notification_lock); in fanotify_release()
937 fsnotify_destroy_event(group, fsn_event); in fanotify_release()
939 finish_permission_event(group, FANOTIFY_PERM(event), in fanotify_release()
942 spin_lock(&group->notification_lock); in fanotify_release()
944 spin_unlock(&group->notification_lock); in fanotify_release()
947 wake_up(&group->fanotify_data.access_waitq); in fanotify_release()
950 fsnotify_destroy_group(group); in fanotify_release()
957 struct fsnotify_group *group; in fanotify_ioctl() local
963 group = file->private_data; in fanotify_ioctl()
969 spin_lock(&group->notification_lock); in fanotify_ioctl()
970 list_for_each_entry(fsn_event, &group->notification_list, list) in fanotify_ioctl()
972 spin_unlock(&group->notification_lock); in fanotify_ioctl()
1074 static int fanotify_remove_mark(struct fsnotify_group *group, in fanotify_remove_mark() argument
1082 fsnotify_group_lock(group); in fanotify_remove_mark()
1083 fsn_mark = fsnotify_find_mark(connp, group); in fanotify_remove_mark()
1085 fsnotify_group_unlock(group); in fanotify_remove_mark()
1095 fsnotify_group_unlock(group); in fanotify_remove_mark()
1104 static int fanotify_remove_vfsmount_mark(struct fsnotify_group *group, in fanotify_remove_vfsmount_mark() argument
1108 return fanotify_remove_mark(group, &real_mount(mnt)->mnt_fsnotify_marks, in fanotify_remove_vfsmount_mark()
1112 static int fanotify_remove_sb_mark(struct fsnotify_group *group, in fanotify_remove_sb_mark() argument
1116 return fanotify_remove_mark(group, &sb->s_fsnotify_marks, mask, in fanotify_remove_sb_mark()
1120 static int fanotify_remove_inode_mark(struct fsnotify_group *group, in fanotify_remove_inode_mark() argument
1124 return fanotify_remove_mark(group, &inode->i_fsnotify_marks, mask, in fanotify_remove_inode_mark()
1190 static struct fsnotify_mark *fanotify_add_new_mark(struct fsnotify_group *group, in fanotify_add_new_mark() argument
1196 struct ucounts *ucounts = group->fanotify_data.ucounts; in fanotify_add_new_mark()
1205 if (!FAN_GROUP_FLAG(group, FAN_UNLIMITED_MARKS) && in fanotify_add_new_mark()
1215 fsnotify_init_mark(mark, group); in fanotify_add_new_mark()
1228 if (!FAN_GROUP_FLAG(group, FAN_UNLIMITED_MARKS)) in fanotify_add_new_mark()
1233 static int fanotify_group_init_error_pool(struct fsnotify_group *group) in fanotify_group_init_error_pool() argument
1235 if (mempool_initialized(&group->fanotify_data.error_events_pool)) in fanotify_group_init_error_pool()
1238 return mempool_init_kmalloc_pool(&group->fanotify_data.error_events_pool, in fanotify_group_init_error_pool()
1274 static int fanotify_add_mark(struct fsnotify_group *group, in fanotify_add_mark() argument
1283 fsnotify_group_lock(group); in fanotify_add_mark()
1284 fsn_mark = fsnotify_find_mark(connp, group); in fanotify_add_mark()
1286 fsn_mark = fanotify_add_new_mark(group, connp, obj_type, in fanotify_add_mark()
1289 fsnotify_group_unlock(group); in fanotify_add_mark()
1307 ret = fanotify_group_init_error_pool(group); in fanotify_add_mark()
1317 fsnotify_group_unlock(group); in fanotify_add_mark()
1323 static int fanotify_add_vfsmount_mark(struct fsnotify_group *group, in fanotify_add_vfsmount_mark() argument
1327 return fanotify_add_mark(group, &real_mount(mnt)->mnt_fsnotify_marks, in fanotify_add_vfsmount_mark()
1331 static int fanotify_add_sb_mark(struct fsnotify_group *group, in fanotify_add_sb_mark() argument
1335 return fanotify_add_mark(group, &sb->s_fsnotify_marks, in fanotify_add_sb_mark()
1339 static int fanotify_add_inode_mark(struct fsnotify_group *group, in fanotify_add_inode_mark() argument
1343 pr_debug("%s: group=%p inode=%p\n", __func__, group, inode); in fanotify_add_inode_mark()
1355 return fanotify_add_mark(group, &inode->i_fsnotify_marks, in fanotify_add_inode_mark()
1390 struct fsnotify_group *group; in SYSCALL_DEFINE2() local
1470 group = fsnotify_alloc_group(&fanotify_fsnotify_ops, in SYSCALL_DEFINE2()
1472 if (IS_ERR(group)) { in SYSCALL_DEFINE2()
1473 return PTR_ERR(group); in SYSCALL_DEFINE2()
1477 group->fanotify_data.ucounts = inc_ucount(current_user_ns(), in SYSCALL_DEFINE2()
1480 if (!group->fanotify_data.ucounts) { in SYSCALL_DEFINE2()
1485 group->fanotify_data.flags = flags | internal_flags; in SYSCALL_DEFINE2()
1486 group->memcg = get_mem_cgroup_from_mm(current->mm); in SYSCALL_DEFINE2()
1488 group->fanotify_data.merge_hash = fanotify_alloc_merge_hash(); in SYSCALL_DEFINE2()
1489 if (!group->fanotify_data.merge_hash) { in SYSCALL_DEFINE2()
1494 group->overflow_event = fanotify_alloc_overflow_event(); in SYSCALL_DEFINE2()
1495 if (unlikely(!group->overflow_event)) { in SYSCALL_DEFINE2()
1502 group->fanotify_data.f_flags = event_f_flags; in SYSCALL_DEFINE2()
1503 init_waitqueue_head(&group->fanotify_data.access_waitq); in SYSCALL_DEFINE2()
1504 INIT_LIST_HEAD(&group->fanotify_data.access_list); in SYSCALL_DEFINE2()
1507 group->priority = FS_PRIO_0; in SYSCALL_DEFINE2()
1510 group->priority = FS_PRIO_1; in SYSCALL_DEFINE2()
1513 group->priority = FS_PRIO_2; in SYSCALL_DEFINE2()
1524 group->max_events = UINT_MAX; in SYSCALL_DEFINE2()
1526 group->max_events = fanotify_max_queued_events; in SYSCALL_DEFINE2()
1541 fd = anon_inode_getfd("[fanotify]", &fanotify_fops, group, f_flags); in SYSCALL_DEFINE2()
1548 fsnotify_destroy_group(group); in SYSCALL_DEFINE2()
1599 static int fanotify_events_supported(struct fsnotify_group *group, in fanotify_events_supported() argument
1605 bool strict_dir_events = FAN_GROUP_FLAG(group, FAN_REPORT_TARGET_FID) || in fanotify_events_supported()
1638 struct fsnotify_group *group; in do_fanotify_mark() local
1716 group = f.file->private_data; in do_fanotify_mark()
1725 FAN_GROUP_FLAG(group, FANOTIFY_UNPRIV)) && in do_fanotify_mark()
1735 group->priority == FS_PRIO_0) in do_fanotify_mark()
1757 fid_mode = FAN_GROUP_FLAG(group, FANOTIFY_FID_BITS); in do_fanotify_mark()
1773 fsnotify_clear_vfsmount_marks_by_group(group); in do_fanotify_mark()
1775 fsnotify_clear_sb_marks_by_group(group); in do_fanotify_mark()
1777 fsnotify_clear_inode_marks_by_group(group); in do_fanotify_mark()
1787 ret = fanotify_events_supported(group, &path, mask, flags); in do_fanotify_mark()
1834 ret = fanotify_add_vfsmount_mark(group, mnt, mask, in do_fanotify_mark()
1837 ret = fanotify_add_sb_mark(group, mnt->mnt_sb, mask, in do_fanotify_mark()
1840 ret = fanotify_add_inode_mark(group, inode, mask, in do_fanotify_mark()
1845 ret = fanotify_remove_vfsmount_mark(group, mnt, mask, in do_fanotify_mark()
1848 ret = fanotify_remove_sb_mark(group, mnt->mnt_sb, mask, in do_fanotify_mark()
1851 ret = fanotify_remove_inode_mark(group, inode, mask, in do_fanotify_mark()