Lines Matching +full:wait +full:- +full:monitoring +full:- +full:ns
1 // SPDX-License-Identifier: GPL-2.0
134 if (list_empty(&group->fanotify_data.access_list)) in perm_group_watchdog()
137 spin_lock(&group->notification_lock); in perm_group_watchdog()
138 list_for_each_entry(event, &group->fanotify_data.access_list, in perm_group_watchdog()
140 if (likely(event->watchdog_cnt == 0)) { in perm_group_watchdog()
141 event->watchdog_cnt = 1; in perm_group_watchdog()
142 } else if (event->watchdog_cnt == 1) { in perm_group_watchdog()
144 event->watchdog_cnt = 2; in perm_group_watchdog()
147 if (event->recv_pid == failed_pid) in perm_group_watchdog()
150 failed_pid = event->recv_pid; in perm_group_watchdog()
152 task = find_task_by_pid_ns(event->recv_pid, in perm_group_watchdog()
156 event->recv_pid, in perm_group_watchdog()
157 task ? task->comm : NULL, in perm_group_watchdog()
162 spin_unlock(&group->notification_lock); in perm_group_watchdog()
169 if (!list_empty(&group->fanotify_data.perm_grp_list)) { in fanotify_perm_watchdog_group_remove()
172 list_del_init(&group->fanotify_data.perm_grp_list); in fanotify_perm_watchdog_group_remove()
183 if (list_empty(&group->fanotify_data.perm_grp_list)) { in fanotify_perm_watchdog_group_add()
184 /* Add to perm_group_list for monitoring by watchdog. */ in fanotify_perm_watchdog_group_add()
187 list_add_tail(&group->fanotify_data.perm_grp_list, &perm_group_list); in fanotify_perm_watchdog_group_add()
245 info->name_len); in fanotify_dir_name_info_len()
248 info->name2_len); in fanotify_dir_name_info_len()
260 if (fanotify_is_error_event(event->mask)) in fanotify_event_len()
266 (event->mask & FAN_ONDIR)) { in fanotify_event_len()
278 if (fanotify_is_mnt_event(event->mask)) in fanotify_event_len()
296 assert_spin_locked(&group->notification_lock); in fanotify_unhash_event()
301 if (WARN_ON_ONCE(hlist_unhashed(&event->merge_list))) in fanotify_unhash_event()
304 hlist_del_init(&event->merge_list); in fanotify_unhash_event()
323 spin_lock(&group->notification_lock); in get_one_event()
332 event = ERR_PTR(-EINVAL); in get_one_event()
341 if (fanotify_is_perm_event(event->mask)) in get_one_event()
342 FANOTIFY_PERM(event)->state = FAN_EVENT_REPORTED; in get_one_event()
343 if (fanotify_is_hashed_event(event->mask)) in get_one_event()
346 spin_unlock(&group->notification_lock); in get_one_event()
356 client_fd = get_unused_fd_flags(group->fanotify_data.f_flags); in create_fd()
364 new_file = dentry_open_nonotify(path, group->fanotify_data.f_flags, in create_fd()
381 return -EINVAL; in process_access_response_info()
384 return -EFAULT; in process_access_response_info()
386 if (friar->hdr.type != FAN_RESPONSE_INFO_AUDIT_RULE) in process_access_response_info()
387 return -EINVAL; in process_access_response_info()
388 if (friar->hdr.pad != 0) in process_access_response_info()
389 return -EINVAL; in process_access_response_info()
390 if (friar->hdr.len != sizeof(*friar)) in process_access_response_info()
391 return -EINVAL; in process_access_response_info()
398 * drop group->notification_lock.
403 __releases(&group->notification_lock) in finish_permission_event()
407 assert_spin_locked(&group->notification_lock); in finish_permission_event()
408 event->response = response & ~FAN_INFO; in finish_permission_event()
410 memcpy(&event->audit_rule, friar, sizeof(*friar)); in finish_permission_event()
412 if (event->state == FAN_EVENT_CANCELED) in finish_permission_event()
415 event->state = FAN_EVENT_ANSWERED; in finish_permission_event()
416 spin_unlock(&group->notification_lock); in finish_permission_event()
418 fsnotify_destroy_event(group, &event->fae.fse); in finish_permission_event()
427 int fd = response_struct->fd; in process_access_response()
428 u32 response = response_struct->response; in process_access_response()
441 return -EINVAL; in process_access_response()
446 return -EINVAL; in process_access_response()
449 /* Custom errno is supported only for pre-content groups */ in process_access_response()
450 if (errno && group->priority != FSNOTIFY_PRIO_PRE_CONTENT) in process_access_response()
451 return -EINVAL; in process_access_response()
468 return -EINVAL; in process_access_response()
472 return -EINVAL; in process_access_response()
476 return -EINVAL; in process_access_response()
489 return -EINVAL; in process_access_response()
491 spin_lock(&group->notification_lock); in process_access_response()
492 list_for_each_entry(event, &group->fanotify_data.access_list, in process_access_response()
494 if (event->fd != fd) in process_access_response()
497 list_del_init(&event->fae.fse.list); in process_access_response()
499 wake_up(&group->fanotify_data.access_waitq); in process_access_response()
502 spin_unlock(&group->notification_lock); in process_access_response()
504 return -ENOENT; in process_access_response()
516 return -EFAULT; in copy_mnt_info_to_user()
518 info.mnt_id = FANOTIFY_ME(event)->mnt_id; in copy_mnt_info_to_user()
521 return -EFAULT; in copy_mnt_info_to_user()
536 return -EFAULT; in copy_error_info_to_user()
538 info.error = fee->error; in copy_error_info_to_user()
539 info.error_count = fee->err_count; in copy_error_info_to_user()
542 return -EFAULT; in copy_error_info_to_user()
555 size_t fh_len = fh ? fh->len : 0; in copy_fid_info_to_user()
563 return -EFAULT; in copy_fid_info_to_user()
573 return -EFAULT; in copy_fid_info_to_user()
579 return -EFAULT; in copy_fid_info_to_user()
582 return -EFAULT; in copy_fid_info_to_user()
589 return -EFAULT; in copy_fid_info_to_user()
592 len -= sizeof(info); in copy_fid_info_to_user()
594 return -EFAULT; in copy_fid_info_to_user()
596 handle.handle_type = fh->type; in copy_fid_info_to_user()
604 return -EFAULT; in copy_fid_info_to_user()
607 len -= sizeof(handle); in copy_fid_info_to_user()
609 return -EFAULT; in copy_fid_info_to_user()
621 return -EFAULT; in copy_fid_info_to_user()
624 len -= fh_len; in copy_fid_info_to_user()
630 return -EFAULT; in copy_fid_info_to_user()
633 return -EFAULT; in copy_fid_info_to_user()
636 len -= name_len; in copy_fid_info_to_user()
642 return -EFAULT; in copy_fid_info_to_user()
655 return -EFAULT; in copy_pidfd_info_to_user()
662 return -EFAULT; in copy_pidfd_info_to_user()
675 return -EFAULT; in copy_range_info_to_user()
677 if (WARN_ON_ONCE(!pevent->ppos)) in copy_range_info_to_user()
678 return -EINVAL; in copy_range_info_to_user()
682 info.offset = *(pevent->ppos); in copy_range_info_to_user()
683 info.count = pevent->count; in copy_range_info_to_user()
686 return -EFAULT; in copy_range_info_to_user()
707 info_type = info->name_len ? FAN_EVENT_INFO_TYPE_DFID_NAME : in copy_info_records_to_user()
711 if (event->mask & FAN_RENAME) in copy_info_records_to_user()
718 info->name_len, buf, count); in copy_info_records_to_user()
723 count -= ret; in copy_info_records_to_user()
734 info->name2_len, buf, count); in copy_info_records_to_user()
739 count -= ret; in copy_info_records_to_user()
754 (event->mask & FAN_ONDIR)) { in copy_info_records_to_user()
763 } else if ((event->mask & ALL_FSNOTIFY_DIRENT_EVENTS) || in copy_info_records_to_user()
764 (event->mask & FAN_ONDIR)) { in copy_info_records_to_user()
775 * non-directory, when there is no directory to report. in copy_info_records_to_user()
789 count -= ret; in copy_info_records_to_user()
799 count -= ret; in copy_info_records_to_user()
803 if (fanotify_is_error_event(event->mask)) { in copy_info_records_to_user()
808 count -= ret; in copy_info_records_to_user()
817 count -= ret; in copy_info_records_to_user()
821 if (fanotify_is_mnt_event(event->mask)) { in copy_info_records_to_user()
826 count -= ret; in copy_info_records_to_user()
843 int ret, pidfd = -ESRCH, fd = -EBADF; in copy_event_to_user()
851 metadata.mask = event->mask & FANOTIFY_OUTGOING_EVENTS; in copy_event_to_user()
852 metadata.pid = pid_vnr(event->pid); in copy_event_to_user()
854 * For an unprivileged listener, event->pid can be used to identify the in copy_event_to_user()
859 task_tgid(current) != event->pid) in copy_event_to_user()
869 path && path->mnt && path->dentry) { in copy_event_to_user()
886 path->dentry, fd); in copy_event_to_user()
894 if (fd == -EOPENSTALE) in copy_event_to_user()
910 * creation of pidfds for thread-group leaders. in copy_event_to_user()
915 * The PIDTYPE_TGID check for an event->pid is performed in copy_event_to_user()
919 * report either -ESRCH or FAN_NOPIDFD to the event listener in in copy_event_to_user()
923 if (metadata.pid && pid_has_task(event->pid, PIDTYPE_TGID)) in copy_event_to_user()
924 pidfd = pidfd_prepare(event->pid, 0, &pidfd_file); in copy_event_to_user()
927 pidfd = pidfd == -ESRCH ? FAN_NOPIDFD : FAN_EPIDFD; in copy_event_to_user()
930 ret = -EFAULT; in copy_event_to_user()
942 count -= FAN_EVENT_METADATA_LEN; in copy_event_to_user()
955 if (fanotify_is_perm_event(event->mask)) in copy_event_to_user()
956 FANOTIFY_PERM(event)->fd = fd; in copy_event_to_user()
975 static __poll_t fanotify_poll(struct file *file, poll_table *wait) in fanotify_poll() argument
977 struct fsnotify_group *group = file->private_data; in fanotify_poll()
980 poll_wait(file, &group->notification_waitq, wait); in fanotify_poll()
981 spin_lock(&group->notification_lock); in fanotify_poll()
984 spin_unlock(&group->notification_lock); in fanotify_poll()
996 DEFINE_WAIT_FUNC(wait, woken_wake_function); in fanotify_read()
999 group = file->private_data; in fanotify_read()
1003 add_wait_queue(&group->notification_waitq, &wait); in fanotify_read()
1017 ret = -EAGAIN; in fanotify_read()
1018 if (file->f_flags & O_NONBLOCK) in fanotify_read()
1021 ret = -ERESTARTSYS; in fanotify_read()
1028 wait_woken(&wait, TASK_INTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT); in fanotify_read()
1035 * Permission events get queued to wait for response. Other in fanotify_read()
1038 if (!fanotify_is_perm_event(event->mask)) { in fanotify_read()
1039 fsnotify_destroy_event(group, &event->fse); in fanotify_read()
1041 if (ret <= 0 || FANOTIFY_PERM(event)->fd < 0) { in fanotify_read()
1042 spin_lock(&group->notification_lock); in fanotify_read()
1045 wake_up(&group->fanotify_data.access_waitq); in fanotify_read()
1047 spin_lock(&group->notification_lock); in fanotify_read()
1048 list_add_tail(&event->fse.list, in fanotify_read()
1049 &group->fanotify_data.access_list); in fanotify_read()
1050 FANOTIFY_PERM(event)->recv_pid = current->pid; in fanotify_read()
1051 spin_unlock(&group->notification_lock); in fanotify_read()
1057 count -= ret; in fanotify_read()
1059 remove_wait_queue(&group->notification_waitq, &wait); in fanotify_read()
1061 if (start != buf && ret != -EFAULT) in fanotify_read()
1062 ret = buf - start; in fanotify_read()
1075 return -EINVAL; in fanotify_write()
1077 group = file->private_data; in fanotify_write()
1082 return -EINVAL; in fanotify_write()
1085 return -EFAULT; in fanotify_write()
1087 info_len = count - sizeof(response); in fanotify_write()
1100 struct fsnotify_group *group = file->private_data; in fanotify_release()
1116 spin_lock(&group->notification_lock); in fanotify_release()
1117 while (!list_empty(&group->fanotify_data.access_list)) { in fanotify_release()
1120 event = list_first_entry(&group->fanotify_data.access_list, in fanotify_release()
1122 list_del_init(&event->fae.fse.list); in fanotify_release()
1124 spin_lock(&group->notification_lock); in fanotify_release()
1128 * Destroy all non-permission events. For permission events just in fanotify_release()
1135 if (!(event->mask & FANOTIFY_PERM_EVENTS)) { in fanotify_release()
1136 spin_unlock(&group->notification_lock); in fanotify_release()
1142 spin_lock(&group->notification_lock); in fanotify_release()
1144 spin_unlock(&group->notification_lock); in fanotify_release()
1147 wake_up(&group->fanotify_data.access_waitq); in fanotify_release()
1149 /* matches the fanotify_init->fsnotify_alloc_group */ in fanotify_release()
1160 int ret = -ENOTTY; in fanotify_ioctl()
1163 group = file->private_data; in fanotify_ioctl()
1169 spin_lock(&group->notification_lock); in fanotify_ioctl()
1170 list_for_each_entry(fsn_event, &group->notification_list, list) in fanotify_ioctl()
1172 spin_unlock(&group->notification_lock); in fanotify_ioctl()
1205 return -EBADF; in fanotify_find_path()
1208 !(S_ISDIR(file_inode(fd_file(f))->i_mode))) in fanotify_find_path()
1209 return -ENOTDIR; in fanotify_find_path()
1211 *path = fd_file(f)->f_path; in fanotify_find_path()
1249 spin_lock(&fsn_mark->lock); in fanotify_mark_remove_from_mask()
1252 fsn_mark->mask &= ~mask; in fanotify_mark_remove_from_mask()
1254 fsn_mark->ignore_mask &= ~mask; in fanotify_mark_remove_from_mask()
1263 *destroy = !((fsn_mark->mask | fsn_mark->ignore_mask) & ~umask); in fanotify_mark_remove_from_mask()
1264 spin_unlock(&fsn_mark->lock); in fanotify_mark_remove_from_mask()
1281 return -ENOENT; in fanotify_remove_mark()
1286 if (removed & fsnotify_conn_mask(fsn_mark->connector)) in fanotify_remove_mark()
1287 fsnotify_recalc_mask(fsn_mark->connector); in fanotify_remove_mark()
1313 fsn_mark->flags |= FSNOTIFY_MARK_FLAG_HAS_IGNORE_FLAGS; in fanotify_mark_update_flags()
1321 !(fsn_mark->flags & FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY)) { in fanotify_mark_update_flags()
1322 fsn_mark->flags |= FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY; in fanotify_mark_update_flags()
1323 if (!(fsn_mark->mask & FS_MODIFY)) in fanotify_mark_update_flags()
1327 if (fsn_mark->connector->type != FSNOTIFY_OBJ_TYPE_INODE || in fanotify_mark_update_flags()
1328 want_iref == !(fsn_mark->flags & FSNOTIFY_MARK_FLAG_NO_IREF)) in fanotify_mark_update_flags()
1336 fsn_mark->flags &= ~FSNOTIFY_MARK_FLAG_NO_IREF; in fanotify_mark_update_flags()
1346 spin_lock(&fsn_mark->lock); in fanotify_mark_add_to_mask()
1348 fsn_mark->mask |= mask; in fanotify_mark_add_to_mask()
1350 fsn_mark->ignore_mask |= mask; in fanotify_mark_add_to_mask()
1353 ~fsnotify_conn_mask(fsn_mark->connector); in fanotify_mark_add_to_mask()
1356 spin_unlock(&fsn_mark->lock); in fanotify_mark_add_to_mask()
1375 FANOTIFY_MARK(mark)->fsid = fsid->id; in fanotify_set_mark_fsid()
1376 mark->flags |= FSNOTIFY_MARK_FLAG_HAS_FSID; in fanotify_set_mark_fsid()
1377 if (fsid->weak) in fanotify_set_mark_fsid()
1378 mark->flags |= FSNOTIFY_MARK_FLAG_WEAK_FSID; in fanotify_set_mark_fsid()
1381 if (list_empty(&group->marks_list)) in fanotify_set_mark_fsid()
1385 list_for_each_entry(old, &group->marks_list, g_list) { in fanotify_set_mark_fsid()
1386 conn = READ_ONCE(old->connector); in fanotify_set_mark_fsid()
1399 if ((mark->flags ^ old->flags) & FSNOTIFY_MARK_FLAG_WEAK_FSID) in fanotify_set_mark_fsid()
1400 return -EXDEV; in fanotify_set_mark_fsid()
1403 if (!fsid->weak) in fanotify_set_mark_fsid()
1407 if (old_sb != fsid->sb) in fanotify_set_mark_fsid()
1408 return -EXDEV; in fanotify_set_mark_fsid()
1410 /* Do not allow mixing marks from different btrfs sub-volumes */ in fanotify_set_mark_fsid()
1411 if (!fanotify_fsid_equal(&FANOTIFY_MARK(old)->fsid, in fanotify_set_mark_fsid()
1412 &FANOTIFY_MARK(mark)->fsid)) in fanotify_set_mark_fsid()
1413 return -EXDEV; in fanotify_set_mark_fsid()
1424 struct ucounts *ucounts = group->fanotify_data.ucounts; in fanotify_add_new_mark()
1430 * Enforce per user marks limits per user in all containing user ns. in fanotify_add_new_mark()
1436 !inc_ucount(ucounts->ns, ucounts->uid, UCOUNT_FANOTIFY_MARKS)) in fanotify_add_new_mark()
1437 return ERR_PTR(-ENOSPC); in fanotify_add_new_mark()
1441 ret = -ENOMEM; in fanotify_add_new_mark()
1445 mark = &fan_mark->fsn_mark; in fanotify_add_new_mark()
1448 mark->flags |= FSNOTIFY_MARK_FLAG_NO_IREF; in fanotify_add_new_mark()
1456 fan_mark->fsid.val[0] = fan_mark->fsid.val[1] = 0; in fanotify_add_new_mark()
1475 if (mempool_initialized(&group->fanotify_data.error_events_pool)) in fanotify_group_init_error_pool()
1478 return mempool_init_kmalloc_pool(&group->fanotify_data.error_events_pool, in fanotify_group_init_error_pool()
1490 !(fsn_mark->flags & FSNOTIFY_MARK_FLAG_NO_IREF)) in fanotify_may_update_existing_mark()
1491 return -EEXIST; in fanotify_may_update_existing_mark()
1497 fsn_mark->flags & FSNOTIFY_MARK_FLAG_HAS_IGNORE_FLAGS) in fanotify_may_update_existing_mark()
1498 return -EEXIST; in fanotify_may_update_existing_mark()
1508 fsn_mark->flags & FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY) in fanotify_may_update_existing_mark()
1509 return -EEXIST; in fanotify_may_update_existing_mark()
1511 /* For now pre-content events are not generated for directories */ in fanotify_may_update_existing_mark()
1512 mask |= fsn_mark->mask; in fanotify_may_update_existing_mark()
1514 return -EEXIST; in fanotify_may_update_existing_mark()
1547 * Error events are pre-allocated per group, only if strictly in fanotify_add_mark()
1559 fsnotify_recalc_mask(fsn_mark->connector); in fanotify_add_mark()
1581 oevent->type = FANOTIFY_EVENT_TYPE_OVERFLOW; in fanotify_alloc_overflow_event()
1583 return &oevent->fse; in fanotify_alloc_overflow_event()
1617 * limited functionality - an unprivileged group is limited to in SYSCALL_DEFINE2()
1623 return -EPERM; in SYSCALL_DEFINE2()
1638 return -EINVAL; in SYSCALL_DEFINE2()
1641 * A pidfd can only be returned for a thread-group leader; thus in SYSCALL_DEFINE2()
1646 return -EINVAL; in SYSCALL_DEFINE2()
1651 return -EINVAL; in SYSCALL_DEFINE2()
1653 return -EINVAL; in SYSCALL_DEFINE2()
1657 return -EINVAL; in SYSCALL_DEFINE2()
1665 return -EINVAL; in SYSCALL_DEFINE2()
1669 return -EINVAL; in SYSCALL_DEFINE2()
1676 return -EINVAL; in SYSCALL_DEFINE2()
1685 return -EINVAL; in SYSCALL_DEFINE2()
1700 /* Enforce groups limits per user in all containing user ns */ in SYSCALL_DEFINE2()
1701 group->fanotify_data.ucounts = inc_ucount(user_ns, current_euid(), in SYSCALL_DEFINE2()
1703 if (!group->fanotify_data.ucounts) { in SYSCALL_DEFINE2()
1704 fd = -EMFILE; in SYSCALL_DEFINE2()
1708 group->fanotify_data.flags = flags | internal_flags; in SYSCALL_DEFINE2()
1709 group->memcg = get_mem_cgroup_from_mm(current->mm); in SYSCALL_DEFINE2()
1710 group->user_ns = get_user_ns(user_ns); in SYSCALL_DEFINE2()
1712 group->fanotify_data.merge_hash = fanotify_alloc_merge_hash(); in SYSCALL_DEFINE2()
1713 if (!group->fanotify_data.merge_hash) { in SYSCALL_DEFINE2()
1714 fd = -ENOMEM; in SYSCALL_DEFINE2()
1718 group->overflow_event = fanotify_alloc_overflow_event(); in SYSCALL_DEFINE2()
1719 if (unlikely(!group->overflow_event)) { in SYSCALL_DEFINE2()
1720 fd = -ENOMEM; in SYSCALL_DEFINE2()
1726 group->fanotify_data.f_flags = event_f_flags; in SYSCALL_DEFINE2()
1727 init_waitqueue_head(&group->fanotify_data.access_waitq); in SYSCALL_DEFINE2()
1728 INIT_LIST_HEAD(&group->fanotify_data.access_list); in SYSCALL_DEFINE2()
1729 INIT_LIST_HEAD(&group->fanotify_data.perm_grp_list); in SYSCALL_DEFINE2()
1732 group->priority = FSNOTIFY_PRIO_NORMAL; in SYSCALL_DEFINE2()
1735 group->priority = FSNOTIFY_PRIO_CONTENT; in SYSCALL_DEFINE2()
1738 group->priority = FSNOTIFY_PRIO_PRE_CONTENT; in SYSCALL_DEFINE2()
1741 fd = -EINVAL; in SYSCALL_DEFINE2()
1747 group->max_events = UINT_MAX; in SYSCALL_DEFINE2()
1749 group->max_events = fanotify_max_queued_events; in SYSCALL_DEFINE2()
1753 fd = -EPERM; in SYSCALL_DEFINE2()
1787 err = vfs_get_fsid(dentry, &fsid->id); in fanotify_test_fsid()
1791 fsid->sb = dentry->d_sb; in fanotify_test_fsid()
1792 if (!fsid->id.val[0] && !fsid->id.val[1]) { in fanotify_test_fsid()
1793 err = -ENODEV; in fanotify_test_fsid()
1801 err = vfs_get_fsid(dentry->d_sb->s_root, &root_fsid); in fanotify_test_fsid()
1805 if (!fanotify_fsid_equal(&root_fsid, &fsid->id)) { in fanotify_test_fsid()
1806 err = -EXDEV; in fanotify_test_fsid()
1810 fsid->weak = false; in fanotify_test_fsid()
1815 fsid->weak = true; in fanotify_test_fsid()
1823 const struct export_operations *nop = dentry->d_sb->s_export_op; in fanotify_test_fid()
1831 return -EOPNOTSUPP; in fanotify_test_fid()
1839 return -EOPNOTSUPP; in fanotify_test_fid()
1849 bool is_dir = d_is_dir(path->dentry); in fanotify_events_supported()
1850 /* Strict validation of events in non-dir inode mask with v5.17+ APIs */ in fanotify_events_supported()
1856 * Filesystems need to opt-into pre-content evnets (a.k.a HSM) in fanotify_events_supported()
1860 if (!(path->mnt->mnt_sb->s_iflags & SB_I_ALLOW_HSM)) in fanotify_events_supported()
1861 return -EOPNOTSUPP; in fanotify_events_supported()
1862 if (!is_dir && !d_is_reg(path->dentry)) in fanotify_events_supported()
1863 return -EINVAL; in fanotify_events_supported()
1869 * deadlocking the system - open done when reporting fanotify event in fanotify_events_supported()
1875 path->mnt->mnt_sb->s_type->fs_flags & FS_DISALLOW_NOTIFY_PERM) in fanotify_events_supported()
1876 return -EINVAL; in fanotify_events_supported()
1889 path->mnt->mnt_sb->s_flags & SB_NOUSER) in fanotify_events_supported()
1890 return -EINVAL; in fanotify_events_supported()
1894 * flags FAN_ONDIR and FAN_EVENT_ON_CHILD in mask of non-dir inode, in fanotify_events_supported()
1899 return -ENOTDIR; in fanotify_events_supported()
1927 return -EINVAL; in do_fanotify_mark()
1930 return -EINVAL; in do_fanotify_mark()
1946 return -EINVAL; in do_fanotify_mark()
1953 return -EINVAL; in do_fanotify_mark()
1957 return -EINVAL; in do_fanotify_mark()
1960 return -EINVAL; in do_fanotify_mark()
1967 return -EINVAL; in do_fanotify_mark()
1972 return -EINVAL; in do_fanotify_mark()
1985 return -EBADF; in do_fanotify_mark()
1988 if (unlikely(fd_file(f)->f_op != &fanotify_fops)) in do_fanotify_mark()
1989 return -EINVAL; in do_fanotify_mark()
1990 group = fd_file(f)->private_data; in do_fanotify_mark()
1995 return -EINVAL; in do_fanotify_mark()
1997 return -EINVAL; in do_fanotify_mark()
2000 return -EINVAL; in do_fanotify_mark()
2002 return -EINVAL; in do_fanotify_mark()
2007 * capable in the user ns where the group was created. in do_fanotify_mark()
2009 if (!ns_capable(group->user_ns, CAP_SYS_ADMIN) && in do_fanotify_mark()
2011 return -EPERM; in do_fanotify_mark()
2015 * Pre-content permission events are not allowed for FAN_CLASS_CONTENT. in do_fanotify_mark()
2018 group->priority == FSNOTIFY_PRIO_NORMAL) in do_fanotify_mark()
2019 return -EINVAL; in do_fanotify_mark()
2021 group->priority == FSNOTIFY_PRIO_CONTENT) in do_fanotify_mark()
2022 return -EINVAL; in do_fanotify_mark()
2026 return -EINVAL; in do_fanotify_mark()
2034 return -EINVAL; in do_fanotify_mark()
2038 * event->fd require a group that supports reporting fid. Those in do_fanotify_mark()
2046 return -EINVAL; in do_fanotify_mark()
2054 return -EINVAL; in do_fanotify_mark()
2056 /* Pre-content events are not currently generated for directories. */ in do_fanotify_mark()
2058 return -EINVAL; in do_fanotify_mark()
2089 * In addition to being capable in the user ns where group was created, in do_fanotify_mark()
2090 * the user also needs to be capable in the user ns associated with in do_fanotify_mark()
2091 * the filesystem or in the user ns associated with the mntns in do_fanotify_mark()
2095 inode = path.dentry->d_inode; in do_fanotify_mark()
2098 user_ns = path.mnt->mnt_sb->s_user_ns; in do_fanotify_mark()
2101 user_ns = path.mnt->mnt_sb->s_user_ns; in do_fanotify_mark()
2102 obj = path.mnt->mnt_sb; in do_fanotify_mark()
2104 ret = -EINVAL; in do_fanotify_mark()
2108 user_ns = mntns->user_ns; in do_fanotify_mark()
2112 ret = -EPERM; in do_fanotify_mark()
2116 ret = -EINVAL; in do_fanotify_mark()
2127 ret = !inode ? -EINVAL : -EISDIR; in do_fanotify_mark()
2130 (!inode || S_ISDIR(inode->i_mode))) in do_fanotify_mark()
2138 /* Mask out FAN_EVENT_ON_CHILD flag for sb/mount/non-dir marks */ in do_fanotify_mark()
2139 if (!inode || !S_ISDIR(inode->i_mode)) { in do_fanotify_mark()
2144 * events with parent/name info for non-directory. in do_fanotify_mark()
2162 ret = -EINVAL; in do_fanotify_mark()
2191 * fanotify_user_setup - Our initialization function. Note that we cannot return
2192 * error because we have compiled-in VFS hooks. So an (unlikely) failure here
2207 max_marks = (((si.totalram - si.totalhigh) / 100) << PAGE_SHIFT) / in fanotify_user_setup()