Lines Matching refs:group

175 static void fanotify_unhash_event(struct fsnotify_group *group,  in fanotify_unhash_event()  argument
178 assert_spin_locked(&group->notification_lock); in fanotify_unhash_event()
181 group, event, fanotify_event_hash_bucket(group, event)); in fanotify_unhash_event()
195 static struct fanotify_event *get_one_event(struct fsnotify_group *group, in get_one_event() argument
201 unsigned int info_mode = FAN_GROUP_FLAG(group, FANOTIFY_INFO_MODES); in get_one_event()
203 pr_debug("%s: group=%p count=%zd\n", __func__, group, count); in get_one_event()
205 spin_lock(&group->notification_lock); in get_one_event()
206 fsn_event = fsnotify_peek_first_event(group); in get_one_event()
222 fsnotify_remove_first_event(group); in get_one_event()
226 fanotify_unhash_event(group, event); in get_one_event()
228 spin_unlock(&group->notification_lock); in get_one_event()
232 static int create_fd(struct fsnotify_group *group, struct path *path, in create_fd() argument
238 client_fd = get_unused_fd_flags(group->fanotify_data.f_flags); in create_fd()
247 group->fanotify_data.f_flags | FMODE_NONOTIFY, in create_fd()
270 static void finish_permission_event(struct fsnotify_group *group, in finish_permission_event() argument
273 __releases(&group->notification_lock) in finish_permission_event()
277 assert_spin_locked(&group->notification_lock); in finish_permission_event()
283 spin_unlock(&group->notification_lock); in finish_permission_event()
285 fsnotify_destroy_event(group, &event->fae.fse); in finish_permission_event()
288 static int process_access_response(struct fsnotify_group *group, in process_access_response() argument
295 pr_debug("%s: group=%p fd=%d response=%d\n", __func__, group, in process_access_response()
313 if ((response & FAN_AUDIT) && !FAN_GROUP_FLAG(group, FAN_ENABLE_AUDIT)) in process_access_response()
316 spin_lock(&group->notification_lock); in process_access_response()
317 list_for_each_entry(event, &group->fanotify_data.access_list, in process_access_response()
323 finish_permission_event(group, event, response); in process_access_response()
324 wake_up(&group->fanotify_data.access_waitq); in process_access_response()
327 spin_unlock(&group->notification_lock); in process_access_response()
572 static ssize_t copy_event_to_user(struct fsnotify_group *group, in copy_event_to_user() argument
579 unsigned int info_mode = FAN_GROUP_FLAG(group, FANOTIFY_INFO_MODES); in copy_event_to_user()
584 pr_debug("%s: group=%p event=%p\n", __func__, group, event); in copy_event_to_user()
597 if (FAN_GROUP_FLAG(group, FANOTIFY_UNPRIV) && in copy_event_to_user()
607 if (!FAN_GROUP_FLAG(group, FANOTIFY_UNPRIV) && in copy_event_to_user()
609 fd = create_fd(group, path, &f); in copy_event_to_user()
622 WARN_ON_ONCE(FAN_GROUP_FLAG(group, FAN_REPORT_TID)); in copy_event_to_user()
686 struct fsnotify_group *group = file->private_data; in fanotify_poll() local
689 poll_wait(file, &group->notification_waitq, wait); in fanotify_poll()
690 spin_lock(&group->notification_lock); in fanotify_poll()
691 if (!fsnotify_notify_queue_is_empty(group)) in fanotify_poll()
693 spin_unlock(&group->notification_lock); in fanotify_poll()
701 struct fsnotify_group *group; in fanotify_read() local
708 group = file->private_data; in fanotify_read()
710 pr_debug("%s: group=%p\n", __func__, group); in fanotify_read()
712 add_wait_queue(&group->notification_waitq, &wait); in fanotify_read()
719 event = get_one_event(group, count); in fanotify_read()
741 ret = copy_event_to_user(group, event, buf, count); in fanotify_read()
757 fsnotify_destroy_event(group, &event->fse); in fanotify_read()
760 spin_lock(&group->notification_lock); in fanotify_read()
761 finish_permission_event(group, in fanotify_read()
763 wake_up(&group->fanotify_data.access_waitq); in fanotify_read()
765 spin_lock(&group->notification_lock); in fanotify_read()
767 &group->fanotify_data.access_list); in fanotify_read()
768 spin_unlock(&group->notification_lock); in fanotify_read()
776 remove_wait_queue(&group->notification_waitq, &wait); in fanotify_read()
786 struct fsnotify_group *group; in fanotify_write() local
792 group = file->private_data; in fanotify_write()
799 pr_debug("%s: group=%p count=%zu\n", __func__, group, count); in fanotify_write()
804 ret = process_access_response(group, &response); in fanotify_write()
813 struct fsnotify_group *group = file->private_data; in fanotify_release() local
821 fsnotify_group_stop_queueing(group); in fanotify_release()
827 spin_lock(&group->notification_lock); in fanotify_release()
828 while (!list_empty(&group->fanotify_data.access_list)) { in fanotify_release()
831 event = list_first_entry(&group->fanotify_data.access_list, in fanotify_release()
834 finish_permission_event(group, event, FAN_ALLOW); in fanotify_release()
835 spin_lock(&group->notification_lock); in fanotify_release()
843 while ((fsn_event = fsnotify_remove_first_event(group))) { in fanotify_release()
847 spin_unlock(&group->notification_lock); in fanotify_release()
848 fsnotify_destroy_event(group, fsn_event); in fanotify_release()
850 finish_permission_event(group, FANOTIFY_PERM(event), in fanotify_release()
853 spin_lock(&group->notification_lock); in fanotify_release()
855 spin_unlock(&group->notification_lock); in fanotify_release()
858 wake_up(&group->fanotify_data.access_waitq); in fanotify_release()
861 fsnotify_destroy_group(group); in fanotify_release()
868 struct fsnotify_group *group; in fanotify_ioctl() local
874 group = file->private_data; in fanotify_ioctl()
880 spin_lock(&group->notification_lock); in fanotify_ioctl()
881 list_for_each_entry(fsn_event, &group->notification_list, list) in fanotify_ioctl()
883 spin_unlock(&group->notification_lock); in fanotify_ioctl()
984 static int fanotify_remove_mark(struct fsnotify_group *group, in fanotify_remove_mark() argument
992 mutex_lock(&group->mark_mutex); in fanotify_remove_mark()
993 fsn_mark = fsnotify_find_mark(connp, group); in fanotify_remove_mark()
995 mutex_unlock(&group->mark_mutex); in fanotify_remove_mark()
1005 mutex_unlock(&group->mark_mutex); in fanotify_remove_mark()
1014 static int fanotify_remove_vfsmount_mark(struct fsnotify_group *group, in fanotify_remove_vfsmount_mark() argument
1018 return fanotify_remove_mark(group, &real_mount(mnt)->mnt_fsnotify_marks, in fanotify_remove_vfsmount_mark()
1022 static int fanotify_remove_sb_mark(struct fsnotify_group *group, in fanotify_remove_sb_mark() argument
1026 return fanotify_remove_mark(group, &sb->s_fsnotify_marks, mask, in fanotify_remove_sb_mark()
1030 static int fanotify_remove_inode_mark(struct fsnotify_group *group, in fanotify_remove_inode_mark() argument
1034 return fanotify_remove_mark(group, &inode->i_fsnotify_marks, mask, in fanotify_remove_inode_mark()
1058 static struct fsnotify_mark *fanotify_add_new_mark(struct fsnotify_group *group, in fanotify_add_new_mark() argument
1063 struct ucounts *ucounts = group->fanotify_data.ucounts; in fanotify_add_new_mark()
1072 if (!FAN_GROUP_FLAG(group, FAN_UNLIMITED_MARKS) && in fanotify_add_new_mark()
1082 fsnotify_init_mark(mark, group); in fanotify_add_new_mark()
1092 if (!FAN_GROUP_FLAG(group, FAN_UNLIMITED_MARKS)) in fanotify_add_new_mark()
1097 static int fanotify_group_init_error_pool(struct fsnotify_group *group) in fanotify_group_init_error_pool() argument
1099 if (mempool_initialized(&group->fanotify_data.error_events_pool)) in fanotify_group_init_error_pool()
1102 return mempool_init_kmalloc_pool(&group->fanotify_data.error_events_pool, in fanotify_group_init_error_pool()
1107 static int fanotify_add_mark(struct fsnotify_group *group, in fanotify_add_mark() argument
1116 mutex_lock(&group->mark_mutex); in fanotify_add_mark()
1117 fsn_mark = fsnotify_find_mark(connp, group); in fanotify_add_mark()
1119 fsn_mark = fanotify_add_new_mark(group, connp, type, fsid); in fanotify_add_mark()
1121 mutex_unlock(&group->mark_mutex); in fanotify_add_mark()
1131 ret = fanotify_group_init_error_pool(group); in fanotify_add_mark()
1141 mutex_unlock(&group->mark_mutex); in fanotify_add_mark()
1147 static int fanotify_add_vfsmount_mark(struct fsnotify_group *group, in fanotify_add_vfsmount_mark() argument
1151 return fanotify_add_mark(group, &real_mount(mnt)->mnt_fsnotify_marks, in fanotify_add_vfsmount_mark()
1155 static int fanotify_add_sb_mark(struct fsnotify_group *group, in fanotify_add_sb_mark() argument
1159 return fanotify_add_mark(group, &sb->s_fsnotify_marks, in fanotify_add_sb_mark()
1163 static int fanotify_add_inode_mark(struct fsnotify_group *group, in fanotify_add_inode_mark() argument
1167 pr_debug("%s: group=%p inode=%p\n", __func__, group, inode); in fanotify_add_inode_mark()
1179 return fanotify_add_mark(group, &inode->i_fsnotify_marks, in fanotify_add_inode_mark()
1214 struct fsnotify_group *group; in SYSCALL_DEFINE2() local
1285 group = fsnotify_alloc_user_group(&fanotify_fsnotify_ops); in SYSCALL_DEFINE2()
1286 if (IS_ERR(group)) { in SYSCALL_DEFINE2()
1287 return PTR_ERR(group); in SYSCALL_DEFINE2()
1291 group->fanotify_data.ucounts = inc_ucount(current_user_ns(), in SYSCALL_DEFINE2()
1294 if (!group->fanotify_data.ucounts) { in SYSCALL_DEFINE2()
1299 group->fanotify_data.flags = flags | internal_flags; in SYSCALL_DEFINE2()
1300 group->memcg = get_mem_cgroup_from_mm(current->mm); in SYSCALL_DEFINE2()
1302 group->fanotify_data.merge_hash = fanotify_alloc_merge_hash(); in SYSCALL_DEFINE2()
1303 if (!group->fanotify_data.merge_hash) { in SYSCALL_DEFINE2()
1308 group->overflow_event = fanotify_alloc_overflow_event(); in SYSCALL_DEFINE2()
1309 if (unlikely(!group->overflow_event)) { in SYSCALL_DEFINE2()
1316 group->fanotify_data.f_flags = event_f_flags; in SYSCALL_DEFINE2()
1317 init_waitqueue_head(&group->fanotify_data.access_waitq); in SYSCALL_DEFINE2()
1318 INIT_LIST_HEAD(&group->fanotify_data.access_list); in SYSCALL_DEFINE2()
1321 group->priority = FS_PRIO_0; in SYSCALL_DEFINE2()
1324 group->priority = FS_PRIO_1; in SYSCALL_DEFINE2()
1327 group->priority = FS_PRIO_2; in SYSCALL_DEFINE2()
1338 group->max_events = UINT_MAX; in SYSCALL_DEFINE2()
1340 group->max_events = fanotify_max_queued_events; in SYSCALL_DEFINE2()
1355 fd = anon_inode_getfd("[fanotify]", &fanotify_fops, group, f_flags); in SYSCALL_DEFINE2()
1362 fsnotify_destroy_group(group); in SYSCALL_DEFINE2()
1434 struct fsnotify_group *group; in do_fanotify_mark() local
1501 group = f.file->private_data; in do_fanotify_mark()
1510 FAN_GROUP_FLAG(group, FANOTIFY_UNPRIV)) && in do_fanotify_mark()
1520 group->priority == FS_PRIO_0) in do_fanotify_mark()
1534 fid_mode = FAN_GROUP_FLAG(group, FANOTIFY_FID_BITS); in do_fanotify_mark()
1542 fsnotify_clear_vfsmount_marks_by_group(group); in do_fanotify_mark()
1544 fsnotify_clear_sb_marks_by_group(group); in do_fanotify_mark()
1546 fsnotify_clear_inode_marks_by_group(group); in do_fanotify_mark()
1596 ret = fanotify_add_vfsmount_mark(group, mnt, mask, in do_fanotify_mark()
1599 ret = fanotify_add_sb_mark(group, mnt->mnt_sb, mask, in do_fanotify_mark()
1602 ret = fanotify_add_inode_mark(group, inode, mask, in do_fanotify_mark()
1607 ret = fanotify_remove_vfsmount_mark(group, mnt, mask, in do_fanotify_mark()
1610 ret = fanotify_remove_sb_mark(group, mnt->mnt_sb, mask, in do_fanotify_mark()
1613 ret = fanotify_remove_inode_mark(group, inode, mask, in do_fanotify_mark()