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()
776 struct fsnotify_group *group = file->private_data; in fanotify_poll() local
779 poll_wait(file, &group->notification_waitq, wait); in fanotify_poll()
780 spin_lock(&group->notification_lock); in fanotify_poll()
781 if (!fsnotify_notify_queue_is_empty(group)) in fanotify_poll()
783 spin_unlock(&group->notification_lock); in fanotify_poll()
791 struct fsnotify_group *group; in fanotify_read() local
798 group = file->private_data; in fanotify_read()
800 pr_debug("%s: group=%p\n", __func__, group); in fanotify_read()
802 add_wait_queue(&group->notification_waitq, &wait); in fanotify_read()
809 event = get_one_event(group, count); in fanotify_read()
831 ret = copy_event_to_user(group, event, buf, count); in fanotify_read()
847 fsnotify_destroy_event(group, &event->fse); in fanotify_read()
850 spin_lock(&group->notification_lock); in fanotify_read()
851 finish_permission_event(group, in fanotify_read()
853 wake_up(&group->fanotify_data.access_waitq); in fanotify_read()
855 spin_lock(&group->notification_lock); in fanotify_read()
857 &group->fanotify_data.access_list); in fanotify_read()
858 spin_unlock(&group->notification_lock); in fanotify_read()
866 remove_wait_queue(&group->notification_waitq, &wait); in fanotify_read()
876 struct fsnotify_group *group; in fanotify_write() local
884 group = file->private_data; in fanotify_write()
886 pr_debug("%s: group=%p count=%zu\n", __func__, group, count); in fanotify_write()
896 ret = process_access_response(group, &response, info_buf, info_len); in fanotify_write()
907 struct fsnotify_group *group = file->private_data; in fanotify_release() local
915 fsnotify_group_stop_queueing(group); in fanotify_release()
921 spin_lock(&group->notification_lock); in fanotify_release()
922 while (!list_empty(&group->fanotify_data.access_list)) { in fanotify_release()
925 event = list_first_entry(&group->fanotify_data.access_list, in fanotify_release()
928 finish_permission_event(group, event, FAN_ALLOW, NULL); in fanotify_release()
929 spin_lock(&group->notification_lock); in fanotify_release()
937 while ((fsn_event = fsnotify_remove_first_event(group))) { in fanotify_release()
941 spin_unlock(&group->notification_lock); in fanotify_release()
942 fsnotify_destroy_event(group, fsn_event); in fanotify_release()
944 finish_permission_event(group, FANOTIFY_PERM(event), in fanotify_release()
947 spin_lock(&group->notification_lock); in fanotify_release()
949 spin_unlock(&group->notification_lock); in fanotify_release()
952 wake_up(&group->fanotify_data.access_waitq); in fanotify_release()
955 fsnotify_destroy_group(group); in fanotify_release()
962 struct fsnotify_group *group; in fanotify_ioctl() local
968 group = file->private_data; in fanotify_ioctl()
974 spin_lock(&group->notification_lock); in fanotify_ioctl()
975 list_for_each_entry(fsn_event, &group->notification_list, list) in fanotify_ioctl()
977 spin_unlock(&group->notification_lock); in fanotify_ioctl()
1079 static int fanotify_remove_mark(struct fsnotify_group *group, in fanotify_remove_mark() argument
1087 fsnotify_group_lock(group); in fanotify_remove_mark()
1088 fsn_mark = fsnotify_find_mark(connp, group); in fanotify_remove_mark()
1090 fsnotify_group_unlock(group); in fanotify_remove_mark()
1100 fsnotify_group_unlock(group); in fanotify_remove_mark()
1109 static int fanotify_remove_vfsmount_mark(struct fsnotify_group *group, in fanotify_remove_vfsmount_mark() argument
1113 return fanotify_remove_mark(group, &real_mount(mnt)->mnt_fsnotify_marks, in fanotify_remove_vfsmount_mark()
1117 static int fanotify_remove_sb_mark(struct fsnotify_group *group, in fanotify_remove_sb_mark() argument
1121 return fanotify_remove_mark(group, &sb->s_fsnotify_marks, mask, in fanotify_remove_sb_mark()
1125 static int fanotify_remove_inode_mark(struct fsnotify_group *group, in fanotify_remove_inode_mark() argument
1129 return fanotify_remove_mark(group, &inode->i_fsnotify_marks, mask, in fanotify_remove_inode_mark()
1195 static struct fsnotify_mark *fanotify_add_new_mark(struct fsnotify_group *group, in fanotify_add_new_mark() argument
1201 struct ucounts *ucounts = group->fanotify_data.ucounts; in fanotify_add_new_mark()
1210 if (!FAN_GROUP_FLAG(group, FAN_UNLIMITED_MARKS) && in fanotify_add_new_mark()
1220 fsnotify_init_mark(mark, group); in fanotify_add_new_mark()
1233 if (!FAN_GROUP_FLAG(group, FAN_UNLIMITED_MARKS)) in fanotify_add_new_mark()
1238 static int fanotify_group_init_error_pool(struct fsnotify_group *group) in fanotify_group_init_error_pool() argument
1240 if (mempool_initialized(&group->fanotify_data.error_events_pool)) in fanotify_group_init_error_pool()
1243 return mempool_init_kmalloc_pool(&group->fanotify_data.error_events_pool, in fanotify_group_init_error_pool()
1279 static int fanotify_add_mark(struct fsnotify_group *group, in fanotify_add_mark() argument
1288 fsnotify_group_lock(group); in fanotify_add_mark()
1289 fsn_mark = fsnotify_find_mark(connp, group); in fanotify_add_mark()
1291 fsn_mark = fanotify_add_new_mark(group, connp, obj_type, in fanotify_add_mark()
1294 fsnotify_group_unlock(group); in fanotify_add_mark()
1312 ret = fanotify_group_init_error_pool(group); in fanotify_add_mark()
1322 fsnotify_group_unlock(group); in fanotify_add_mark()
1328 static int fanotify_add_vfsmount_mark(struct fsnotify_group *group, in fanotify_add_vfsmount_mark() argument
1332 return fanotify_add_mark(group, &real_mount(mnt)->mnt_fsnotify_marks, in fanotify_add_vfsmount_mark()
1336 static int fanotify_add_sb_mark(struct fsnotify_group *group, in fanotify_add_sb_mark() argument
1340 return fanotify_add_mark(group, &sb->s_fsnotify_marks, in fanotify_add_sb_mark()
1344 static int fanotify_add_inode_mark(struct fsnotify_group *group, in fanotify_add_inode_mark() argument
1348 pr_debug("%s: group=%p inode=%p\n", __func__, group, inode); in fanotify_add_inode_mark()
1360 return fanotify_add_mark(group, &inode->i_fsnotify_marks, in fanotify_add_inode_mark()
1395 struct fsnotify_group *group; in SYSCALL_DEFINE2() local
1475 group = fsnotify_alloc_group(&fanotify_fsnotify_ops, in SYSCALL_DEFINE2()
1477 if (IS_ERR(group)) { in SYSCALL_DEFINE2()
1478 return PTR_ERR(group); in SYSCALL_DEFINE2()
1482 group->fanotify_data.ucounts = inc_ucount(current_user_ns(), in SYSCALL_DEFINE2()
1485 if (!group->fanotify_data.ucounts) { in SYSCALL_DEFINE2()
1490 group->fanotify_data.flags = flags | internal_flags; in SYSCALL_DEFINE2()
1491 group->memcg = get_mem_cgroup_from_mm(current->mm); in SYSCALL_DEFINE2()
1493 group->fanotify_data.merge_hash = fanotify_alloc_merge_hash(); in SYSCALL_DEFINE2()
1494 if (!group->fanotify_data.merge_hash) { in SYSCALL_DEFINE2()
1499 group->overflow_event = fanotify_alloc_overflow_event(); in SYSCALL_DEFINE2()
1500 if (unlikely(!group->overflow_event)) { in SYSCALL_DEFINE2()
1507 group->fanotify_data.f_flags = event_f_flags; in SYSCALL_DEFINE2()
1508 init_waitqueue_head(&group->fanotify_data.access_waitq); in SYSCALL_DEFINE2()
1509 INIT_LIST_HEAD(&group->fanotify_data.access_list); in SYSCALL_DEFINE2()
1512 group->priority = FS_PRIO_0; in SYSCALL_DEFINE2()
1515 group->priority = FS_PRIO_1; in SYSCALL_DEFINE2()
1518 group->priority = FS_PRIO_2; in SYSCALL_DEFINE2()
1529 group->max_events = UINT_MAX; in SYSCALL_DEFINE2()
1531 group->max_events = fanotify_max_queued_events; in SYSCALL_DEFINE2()
1546 fd = anon_inode_getfd("[fanotify]", &fanotify_fops, group, f_flags); in SYSCALL_DEFINE2()
1553 fsnotify_destroy_group(group); in SYSCALL_DEFINE2()
1612 static int fanotify_events_supported(struct fsnotify_group *group, in fanotify_events_supported() argument
1618 bool strict_dir_events = FAN_GROUP_FLAG(group, FAN_REPORT_TARGET_FID) || in fanotify_events_supported()
1665 struct fsnotify_group *group; in do_fanotify_mark() local
1743 group = f.file->private_data; in do_fanotify_mark()
1752 FAN_GROUP_FLAG(group, FANOTIFY_UNPRIV)) && in do_fanotify_mark()
1762 group->priority == FS_PRIO_0) in do_fanotify_mark()
1784 fid_mode = FAN_GROUP_FLAG(group, FANOTIFY_FID_BITS); in do_fanotify_mark()
1800 fsnotify_clear_vfsmount_marks_by_group(group); in do_fanotify_mark()
1802 fsnotify_clear_sb_marks_by_group(group); in do_fanotify_mark()
1804 fsnotify_clear_inode_marks_by_group(group); in do_fanotify_mark()
1814 ret = fanotify_events_supported(group, &path, mask, flags); in do_fanotify_mark()
1861 ret = fanotify_add_vfsmount_mark(group, mnt, mask, in do_fanotify_mark()
1864 ret = fanotify_add_sb_mark(group, mnt->mnt_sb, mask, in do_fanotify_mark()
1867 ret = fanotify_add_inode_mark(group, inode, mask, in do_fanotify_mark()
1872 ret = fanotify_remove_vfsmount_mark(group, mnt, mask, in do_fanotify_mark()
1875 ret = fanotify_remove_sb_mark(group, mnt->mnt_sb, mask, in do_fanotify_mark()
1878 ret = fanotify_remove_inode_mark(group, inode, mask, in do_fanotify_mark()