Lines Matching defs:group

36  * Legacy fanotify marks limits (8192) is per group and we introduced a tunable
38 * of fanotify marks per user is <max marks per group> * <max groups per user>.
175 * With group flag FAN_REPORT_NAME, if name was not recorded in
195 static void fanotify_unhash_event(struct fsnotify_group *group,
198 assert_spin_locked(&group->notification_lock);
200 pr_debug("%s: group=%p event=%p bucket=%u\n", __func__,
201 group, event, fanotify_event_hash_bucket(group, event));
215 static struct fanotify_event *get_one_event(struct fsnotify_group *group,
221 unsigned int info_mode = FAN_GROUP_FLAG(group, FANOTIFY_INFO_MODES);
223 pr_debug("%s: group=%p count=%zd\n", __func__, group, count);
225 spin_lock(&group->notification_lock);
226 fsn_event = fsnotify_peek_first_event(group);
242 fsnotify_remove_first_event(group);
246 fanotify_unhash_event(group, event);
248 spin_unlock(&group->notification_lock);
252 static int create_fd(struct fsnotify_group *group, const struct path *path,
258 client_fd = get_unused_fd_flags(group->fanotify_data.f_flags);
267 group->fanotify_data.f_flags | __FMODE_NONOTIFY,
308 * drop group->notification_lock.
310 static void finish_permission_event(struct fsnotify_group *group,
313 __releases(&group->notification_lock)
317 assert_spin_locked(&group->notification_lock);
326 spin_unlock(&group->notification_lock);
328 fsnotify_destroy_event(group, &event->fae.fse);
331 static int process_access_response(struct fsnotify_group *group,
342 pr_debug("%s: group=%p fd=%d response=%u buf=%p size=%zu\n", __func__,
343 group, fd, response, info, info_len);
360 if ((response & FAN_AUDIT) && !FAN_GROUP_FLAG(group, FAN_ENABLE_AUDIT))
376 spin_lock(&group->notification_lock);
377 list_for_each_entry(event, &group->fanotify_data.access_list,
383 finish_permission_event(group, event, response, &friar);
384 wake_up(&group->fanotify_data.access_waitq);
387 spin_unlock(&group->notification_lock);
591 * With only group flag FAN_REPORT_FID only type FID is
598 * With group flag FAN_REPORT_NAME, if name was not
608 * With group flag FAN_REPORT_DIR_FID, a single info
615 * With group flags FAN_REPORT_DIR_FID|FAN_REPORT_FID,
657 static ssize_t copy_event_to_user(struct fsnotify_group *group,
664 unsigned int info_mode = FAN_GROUP_FLAG(group, FANOTIFY_INFO_MODES);
669 pr_debug("%s: group=%p event=%p\n", __func__, group, event);
682 if (FAN_GROUP_FLAG(group, FANOTIFY_UNPRIV) &&
692 if (!FAN_GROUP_FLAG(group, FANOTIFY_UNPRIV) &&
694 fd = create_fd(group, path, &f);
705 * creation of pidfds for thread-group leaders.
707 WARN_ON_ONCE(FAN_GROUP_FLAG(group, FAN_REPORT_TID));
776 struct fsnotify_group *group = file->private_data;
779 poll_wait(file, &group->notification_waitq, wait);
780 spin_lock(&group->notification_lock);
781 if (!fsnotify_notify_queue_is_empty(group))
783 spin_unlock(&group->notification_lock);
791 struct fsnotify_group *group;
798 group = file->private_data;
800 pr_debug("%s: group=%p\n", __func__, group);
802 add_wait_queue(&group->notification_waitq, &wait);
809 event = get_one_event(group, count);
831 ret = copy_event_to_user(group, event, buf, count);
847 fsnotify_destroy_event(group, &event->fse);
850 spin_lock(&group->notification_lock);
851 finish_permission_event(group,
853 wake_up(&group->fanotify_data.access_waitq);
855 spin_lock(&group->notification_lock);
857 &group->fanotify_data.access_list);
858 spin_unlock(&group->notification_lock);
866 remove_wait_queue(&group->notification_waitq, &wait);
876 struct fsnotify_group *group;
884 group = file->private_data;
886 pr_debug("%s: group=%p count=%zu\n", __func__, group, count);
896 ret = process_access_response(group, &response, info_buf, info_len);
907 struct fsnotify_group *group = file->private_data;
915 fsnotify_group_stop_queueing(group);
921 spin_lock(&group->notification_lock);
922 while (!list_empty(&group->fanotify_data.access_list)) {
925 event = list_first_entry(&group->fanotify_data.access_list,
928 finish_permission_event(group, event, FAN_ALLOW, NULL);
929 spin_lock(&group->notification_lock);
937 while ((fsn_event = fsnotify_remove_first_event(group))) {
941 spin_unlock(&group->notification_lock);
942 fsnotify_destroy_event(group, fsn_event);
944 finish_permission_event(group, FANOTIFY_PERM(event),
947 spin_lock(&group->notification_lock);
949 spin_unlock(&group->notification_lock);
952 wake_up(&group->fanotify_data.access_waitq);
955 fsnotify_destroy_group(group);
962 struct fsnotify_group *group;
968 group = file->private_data;
974 spin_lock(&group->notification_lock);
975 list_for_each_entry(fsn_event, &group->notification_list, list)
977 spin_unlock(&group->notification_lock);
1079 static int fanotify_remove_mark(struct fsnotify_group *group,
1087 fsnotify_group_lock(group);
1088 fsn_mark = fsnotify_find_mark(connp, group);
1090 fsnotify_group_unlock(group);
1100 fsnotify_group_unlock(group);
1109 static int fanotify_remove_vfsmount_mark(struct fsnotify_group *group,
1113 return fanotify_remove_mark(group, &real_mount(mnt)->mnt_fsnotify_marks,
1117 static int fanotify_remove_sb_mark(struct fsnotify_group *group,
1121 return fanotify_remove_mark(group, &sb->s_fsnotify_marks, mask,
1125 static int fanotify_remove_inode_mark(struct fsnotify_group *group,
1129 return fanotify_remove_mark(group, &inode->i_fsnotify_marks, mask,
1195 static struct fsnotify_mark *fanotify_add_new_mark(struct fsnotify_group *group,
1201 struct ucounts *ucounts = group->fanotify_data.ucounts;
1207 * A group with FAN_UNLIMITED_MARKS does not contribute to mark count
1210 if (!FAN_GROUP_FLAG(group, FAN_UNLIMITED_MARKS) &&
1220 fsnotify_init_mark(mark, group);
1233 if (!FAN_GROUP_FLAG(group, FAN_UNLIMITED_MARKS))
1238 static int fanotify_group_init_error_pool(struct fsnotify_group *group)
1240 if (mempool_initialized(&group->fanotify_data.error_events_pool))
1243 return mempool_init_kmalloc_pool(&group->fanotify_data.error_events_pool,
1279 static int fanotify_add_mark(struct fsnotify_group *group,
1288 fsnotify_group_lock(group);
1289 fsn_mark = fsnotify_find_mark(connp, group);
1291 fsn_mark = fanotify_add_new_mark(group, connp, obj_type,
1294 fsnotify_group_unlock(group);
1307 * Error events are pre-allocated per group, only if strictly
1312 ret = fanotify_group_init_error_pool(group);
1322 fsnotify_group_unlock(group);
1328 static int fanotify_add_vfsmount_mark(struct fsnotify_group *group,
1332 return fanotify_add_mark(group, &real_mount(mnt)->mnt_fsnotify_marks,
1336 static int fanotify_add_sb_mark(struct fsnotify_group *group,
1340 return fanotify_add_mark(group, &sb->s_fsnotify_marks,
1344 static int fanotify_add_inode_mark(struct fsnotify_group *group,
1348 pr_debug("%s: group=%p inode=%p\n", __func__, group, inode);
1360 return fanotify_add_mark(group, &inode->i_fsnotify_marks,
1395 struct fsnotify_group *group;
1406 * An unprivileged user can setup an fanotify group with
1407 * limited functionality - an unprivileged group is limited to
1415 * Setting the internal flag FANOTIFY_UNPRIV on the group
1416 * prevents setting mount/filesystem marks on this group and
1430 * A pidfd can only be returned for a thread-group leader; thus
1475 group = fsnotify_alloc_group(&fanotify_fsnotify_ops,
1477 if (IS_ERR(group)) {
1478 return PTR_ERR(group);
1482 group->fanotify_data.ucounts = inc_ucount(current_user_ns(),
1485 if (!group->fanotify_data.ucounts) {
1490 group->fanotify_data.flags = flags | internal_flags;
1491 group->memcg = get_mem_cgroup_from_mm(current->mm);
1493 group->fanotify_data.merge_hash = fanotify_alloc_merge_hash();
1494 if (!group->fanotify_data.merge_hash) {
1499 group->overflow_event = fanotify_alloc_overflow_event();
1500 if (unlikely(!group->overflow_event)) {
1507 group->fanotify_data.f_flags = event_f_flags;
1508 init_waitqueue_head(&group->fanotify_data.access_waitq);
1509 INIT_LIST_HEAD(&group->fanotify_data.access_list);
1512 group->priority = FS_PRIO_0;
1515 group->priority = FS_PRIO_1;
1518 group->priority = FS_PRIO_2;
1529 group->max_events = UINT_MAX;
1531 group->max_events = fanotify_max_queued_events;
1546 fd = anon_inode_getfd("[fanotify]", &fanotify_fops, group, f_flags);
1553 fsnotify_destroy_group(group);
1612 static int fanotify_events_supported(struct fsnotify_group *group,
1618 bool strict_dir_events = FAN_GROUP_FLAG(group, FAN_REPORT_TARGET_FID) ||
1665 struct fsnotify_group *group;
1743 group = f.file->private_data;
1747 * marks. This also includes setting up such marks by a group that
1752 FAN_GROUP_FLAG(group, FANOTIFY_UNPRIV)) &&
1757 * group->priority == FS_PRIO_0 == FAN_CLASS_NOTIF. These are not
1762 group->priority == FS_PRIO_0)
1779 * event->fd require a group that supports reporting fid. Those
1784 fid_mode = FAN_GROUP_FLAG(group, FANOTIFY_FID_BITS);
1800 fsnotify_clear_vfsmount_marks_by_group(group);
1802 fsnotify_clear_sb_marks_by_group(group);
1804 fsnotify_clear_inode_marks_by_group(group);
1814 ret = fanotify_events_supported(group, &path, mask, flags);
1831 /* inode held in place by reference to path; group by fget on fd */
1849 * If group needs to report parent fid, register for getting
1861 ret = fanotify_add_vfsmount_mark(group, mnt, mask,
1864 ret = fanotify_add_sb_mark(group, mnt->mnt_sb, mask,
1867 ret = fanotify_add_inode_mark(group, inode, mask,
1872 ret = fanotify_remove_vfsmount_mark(group, mnt, mask,
1875 ret = fanotify_remove_sb_mark(group, mnt->mnt_sb, mask,
1878 ret = fanotify_remove_inode_mark(group, inode, mask,