1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/fanotify.h>
3 #include <linux/fcntl.h>
4 #include <linux/file.h>
6 #include <linux/anon_inodes.h>
7 #include <linux/fsnotify_backend.h>
8 #include <linux/init.h>
9 #include <linux/mount.h>
10 #include <linux/namei.h>
11 #include <linux/poll.h>
12 #include <linux/security.h>
13 #include <linux/syscalls.h>
14 #include <linux/slab.h>
15 #include <linux/types.h>
16 #include <linux/uaccess.h>
17 #include <linux/compat.h>
18 #include <linux/sched/signal.h>
20 #include <asm/ioctls.h>
22 #include "../../mount.h"
23 #include "../fdinfo.h"
26 #define FANOTIFY_DEFAULT_MAX_EVENTS 16384
27 #define FANOTIFY_DEFAULT_MAX_MARKS 8192
28 #define FANOTIFY_DEFAULT_MAX_LISTENERS 128
31 * All flags that may be specified in parameter event_f_flags of fanotify_init.
33 * Internal and external open flags are stored together in field f_flags of
34 * struct file. Only external open flags shall be allowed in event_f_flags.
35 * Internal flags like FMODE_NONOTIFY, FMODE_EXEC, FMODE_NOCMTIME shall be
38 #define FANOTIFY_INIT_ALL_EVENT_F_BITS ( \
39 O_ACCMODE | O_APPEND | O_NONBLOCK | \
40 __O_SYNC | O_DSYNC | O_CLOEXEC | \
41 O_LARGEFILE | O_NOATIME )
43 extern const struct fsnotify_ops fanotify_fsnotify_ops;
45 struct kmem_cache *fanotify_mark_cache __read_mostly;
46 struct kmem_cache *fanotify_event_cachep __read_mostly;
47 struct kmem_cache *fanotify_perm_event_cachep __read_mostly;
50 * Get an fsnotify notification event if one exists and is small
51 * enough to fit in "count". Return an error pointer if the count
52 * is not large enough.
54 * Called with the group->notification_lock held.
56 static struct fsnotify_event *get_one_event(struct fsnotify_group *group,
59 assert_spin_locked(&group->notification_lock);
61 pr_debug("%s: group=%p count=%zd\n", __func__, group, count);
63 if (fsnotify_notify_queue_is_empty(group))
66 if (FAN_EVENT_METADATA_LEN > count)
67 return ERR_PTR(-EINVAL);
69 /* held the notification_lock the whole time, so this is the
70 * same event we peeked above */
71 return fsnotify_remove_first_event(group);
74 static int create_fd(struct fsnotify_group *group,
75 struct fanotify_event_info *event,
79 struct file *new_file;
81 pr_debug("%s: group=%p event=%p\n", __func__, group, event);
83 client_fd = get_unused_fd_flags(group->fanotify_data.f_flags);
88 * we need a new file handle for the userspace program so it can read even if it was
89 * originally opened O_WRONLY.
91 /* it's possible this event was an overflow event. in that case dentry and mnt
92 * are NULL; That's fine, just don't call dentry open */
93 if (event->path.dentry && event->path.mnt)
94 new_file = dentry_open(&event->path,
95 group->fanotify_data.f_flags | FMODE_NONOTIFY,
98 new_file = ERR_PTR(-EOVERFLOW);
99 if (IS_ERR(new_file)) {
101 * we still send an event even if we can't open the file. this
102 * can happen when say tasks are gone and we try to open their
103 * /proc files or we try to open a WRONLY file like in sysfs
104 * we just send the errno to userspace since there isn't much
107 put_unused_fd(client_fd);
108 client_fd = PTR_ERR(new_file);
116 static int fill_event_metadata(struct fsnotify_group *group,
117 struct fanotify_event_metadata *metadata,
118 struct fsnotify_event *fsn_event,
122 struct fanotify_event_info *event;
124 pr_debug("%s: group=%p metadata=%p event=%p\n", __func__,
125 group, metadata, fsn_event);
128 event = container_of(fsn_event, struct fanotify_event_info, fse);
129 metadata->event_len = FAN_EVENT_METADATA_LEN;
130 metadata->metadata_len = FAN_EVENT_METADATA_LEN;
131 metadata->vers = FANOTIFY_METADATA_VERSION;
132 metadata->reserved = 0;
133 metadata->mask = fsn_event->mask & FAN_ALL_OUTGOING_EVENTS;
134 metadata->pid = pid_vnr(event->tgid);
135 if (unlikely(fsn_event->mask & FAN_Q_OVERFLOW))
136 metadata->fd = FAN_NOFD;
138 metadata->fd = create_fd(group, event, file);
139 if (metadata->fd < 0)
146 #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
147 static struct fanotify_perm_event_info *dequeue_event(
148 struct fsnotify_group *group, int fd)
150 struct fanotify_perm_event_info *event, *return_e = NULL;
152 spin_lock(&group->notification_lock);
153 list_for_each_entry(event, &group->fanotify_data.access_list,
158 list_del_init(&event->fae.fse.list);
162 spin_unlock(&group->notification_lock);
164 pr_debug("%s: found return_re=%p\n", __func__, return_e);
169 static int process_access_response(struct fsnotify_group *group,
170 struct fanotify_response *response_struct)
172 struct fanotify_perm_event_info *event;
173 int fd = response_struct->fd;
174 int response = response_struct->response;
176 pr_debug("%s: group=%p fd=%d response=%d\n", __func__, group,
179 * make sure the response is valid, if invalid we do nothing and either
180 * userspace can send a valid response or we will clean it up after the
194 event = dequeue_event(group, fd);
198 event->response = response;
199 wake_up(&group->fanotify_data.access_waitq);
205 static ssize_t copy_event_to_user(struct fsnotify_group *group,
206 struct fsnotify_event *event,
209 struct fanotify_event_metadata fanotify_event_metadata;
213 pr_debug("%s: group=%p event=%p\n", __func__, group, event);
215 ret = fill_event_metadata(group, &fanotify_event_metadata, event, &f);
219 fd = fanotify_event_metadata.fd;
221 if (copy_to_user(buf, &fanotify_event_metadata,
222 fanotify_event_metadata.event_len))
225 #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
226 if (event->mask & FAN_ALL_PERM_EVENTS)
227 FANOTIFY_PE(event)->fd = fd;
232 return fanotify_event_metadata.event_len;
235 if (fd != FAN_NOFD) {
242 /* intofiy userspace file descriptor functions */
243 static unsigned int fanotify_poll(struct file *file, poll_table *wait)
245 struct fsnotify_group *group = file->private_data;
248 poll_wait(file, &group->notification_waitq, wait);
249 spin_lock(&group->notification_lock);
250 if (!fsnotify_notify_queue_is_empty(group))
251 ret = POLLIN | POLLRDNORM;
252 spin_unlock(&group->notification_lock);
257 static ssize_t fanotify_read(struct file *file, char __user *buf,
258 size_t count, loff_t *pos)
260 struct fsnotify_group *group;
261 struct fsnotify_event *kevent;
264 DEFINE_WAIT_FUNC(wait, woken_wake_function);
267 group = file->private_data;
269 pr_debug("%s: group=%p\n", __func__, group);
271 add_wait_queue(&group->notification_waitq, &wait);
273 spin_lock(&group->notification_lock);
274 kevent = get_one_event(group, count);
275 spin_unlock(&group->notification_lock);
277 if (IS_ERR(kevent)) {
278 ret = PTR_ERR(kevent);
284 if (file->f_flags & O_NONBLOCK)
288 if (signal_pending(current))
294 wait_woken(&wait, TASK_INTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT);
298 ret = copy_event_to_user(group, kevent, buf);
299 if (unlikely(ret == -EOPENSTALE)) {
301 * We cannot report events with stale fd so drop it.
302 * Setting ret to 0 will continue the event loop and
303 * do the right thing if there are no more events to
304 * read (i.e. return bytes read, -EAGAIN or wait).
310 * Permission events get queued to wait for response. Other
311 * events can be destroyed now.
313 if (!(kevent->mask & FAN_ALL_PERM_EVENTS)) {
314 fsnotify_destroy_event(group, kevent);
316 #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
318 FANOTIFY_PE(kevent)->response = FAN_DENY;
319 wake_up(&group->fanotify_data.access_waitq);
321 spin_lock(&group->notification_lock);
322 list_add_tail(&kevent->list,
323 &group->fanotify_data.access_list);
324 spin_unlock(&group->notification_lock);
333 remove_wait_queue(&group->notification_waitq, &wait);
335 if (start != buf && ret != -EFAULT)
340 static ssize_t fanotify_write(struct file *file, const char __user *buf, size_t count, loff_t *pos)
342 #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
343 struct fanotify_response response = { .fd = -1, .response = -1 };
344 struct fsnotify_group *group;
347 group = file->private_data;
349 if (count > sizeof(response))
350 count = sizeof(response);
352 pr_debug("%s: group=%p count=%zu\n", __func__, group, count);
354 if (copy_from_user(&response, buf, count))
357 ret = process_access_response(group, &response);
367 static int fanotify_release(struct inode *ignored, struct file *file)
369 struct fsnotify_group *group = file->private_data;
371 #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
372 struct fanotify_perm_event_info *event, *next;
373 struct fsnotify_event *fsn_event;
376 * Stop new events from arriving in the notification queue. since
377 * userspace cannot use fanotify fd anymore, no event can enter or
378 * leave access_list by now either.
380 fsnotify_group_stop_queueing(group);
383 * Process all permission events on access_list and notification queue
384 * and simulate reply from userspace.
386 spin_lock(&group->notification_lock);
387 list_for_each_entry_safe(event, next, &group->fanotify_data.access_list,
389 pr_debug("%s: found group=%p event=%p\n", __func__, group,
392 list_del_init(&event->fae.fse.list);
393 event->response = FAN_ALLOW;
397 * Destroy all non-permission events. For permission events just
398 * dequeue them and set the response. They will be freed once the
399 * response is consumed and fanotify_get_response() returns.
401 while (!fsnotify_notify_queue_is_empty(group)) {
402 fsn_event = fsnotify_remove_first_event(group);
403 if (!(fsn_event->mask & FAN_ALL_PERM_EVENTS)) {
404 spin_unlock(&group->notification_lock);
405 fsnotify_destroy_event(group, fsn_event);
406 spin_lock(&group->notification_lock);
408 FANOTIFY_PE(fsn_event)->response = FAN_ALLOW;
410 spin_unlock(&group->notification_lock);
412 /* Response for all permission events it set, wakeup waiters */
413 wake_up(&group->fanotify_data.access_waitq);
416 /* matches the fanotify_init->fsnotify_alloc_group */
417 fsnotify_destroy_group(group);
422 static long fanotify_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
424 struct fsnotify_group *group;
425 struct fsnotify_event *fsn_event;
430 group = file->private_data;
432 p = (void __user *) arg;
436 spin_lock(&group->notification_lock);
437 list_for_each_entry(fsn_event, &group->notification_list, list)
438 send_len += FAN_EVENT_METADATA_LEN;
439 spin_unlock(&group->notification_lock);
440 ret = put_user(send_len, (int __user *) p);
447 static const struct file_operations fanotify_fops = {
448 .show_fdinfo = fanotify_show_fdinfo,
449 .poll = fanotify_poll,
450 .read = fanotify_read,
451 .write = fanotify_write,
453 .release = fanotify_release,
454 .unlocked_ioctl = fanotify_ioctl,
455 .compat_ioctl = fanotify_ioctl,
456 .llseek = noop_llseek,
459 static int fanotify_find_path(int dfd, const char __user *filename,
460 struct path *path, unsigned int flags)
464 pr_debug("%s: dfd=%d filename=%p flags=%x\n", __func__,
465 dfd, filename, flags);
467 if (filename == NULL) {
468 struct fd f = fdget(dfd);
475 if ((flags & FAN_MARK_ONLYDIR) &&
476 !(S_ISDIR(file_inode(f.file)->i_mode))) {
481 *path = f.file->f_path;
485 unsigned int lookup_flags = 0;
487 if (!(flags & FAN_MARK_DONT_FOLLOW))
488 lookup_flags |= LOOKUP_FOLLOW;
489 if (flags & FAN_MARK_ONLYDIR)
490 lookup_flags |= LOOKUP_DIRECTORY;
492 ret = user_path_at(dfd, filename, lookup_flags, path);
497 /* you can only watch an inode if you have read permissions on it */
498 ret = inode_permission(path->dentry->d_inode, MAY_READ);
505 static __u32 fanotify_mark_remove_from_mask(struct fsnotify_mark *fsn_mark,
512 spin_lock(&fsn_mark->lock);
513 if (!(flags & FAN_MARK_IGNORED_MASK)) {
514 __u32 tmask = fsn_mark->mask & ~mask;
516 if (flags & FAN_MARK_ONDIR)
519 oldmask = fsn_mark->mask;
520 fsn_mark->mask = tmask;
522 __u32 tmask = fsn_mark->ignored_mask & ~mask;
523 if (flags & FAN_MARK_ONDIR)
525 fsn_mark->ignored_mask = tmask;
527 *destroy = !(fsn_mark->mask | fsn_mark->ignored_mask);
528 spin_unlock(&fsn_mark->lock);
530 return mask & oldmask;
533 static int fanotify_remove_vfsmount_mark(struct fsnotify_group *group,
534 struct vfsmount *mnt, __u32 mask,
537 struct fsnotify_mark *fsn_mark = NULL;
541 mutex_lock(&group->mark_mutex);
542 fsn_mark = fsnotify_find_mark(&real_mount(mnt)->mnt_fsnotify_marks,
545 mutex_unlock(&group->mark_mutex);
549 removed = fanotify_mark_remove_from_mask(fsn_mark, mask, flags,
551 if (removed & real_mount(mnt)->mnt_fsnotify_mask)
552 fsnotify_recalc_mask(real_mount(mnt)->mnt_fsnotify_marks);
554 fsnotify_detach_mark(fsn_mark);
555 mutex_unlock(&group->mark_mutex);
557 fsnotify_free_mark(fsn_mark);
559 fsnotify_put_mark(fsn_mark);
563 static int fanotify_remove_inode_mark(struct fsnotify_group *group,
564 struct inode *inode, __u32 mask,
567 struct fsnotify_mark *fsn_mark = NULL;
571 mutex_lock(&group->mark_mutex);
572 fsn_mark = fsnotify_find_mark(&inode->i_fsnotify_marks, group);
574 mutex_unlock(&group->mark_mutex);
578 removed = fanotify_mark_remove_from_mask(fsn_mark, mask, flags,
580 if (removed & inode->i_fsnotify_mask)
581 fsnotify_recalc_mask(inode->i_fsnotify_marks);
583 fsnotify_detach_mark(fsn_mark);
584 mutex_unlock(&group->mark_mutex);
586 fsnotify_free_mark(fsn_mark);
588 /* matches the fsnotify_find_mark() */
589 fsnotify_put_mark(fsn_mark);
594 static __u32 fanotify_mark_add_to_mask(struct fsnotify_mark *fsn_mark,
600 spin_lock(&fsn_mark->lock);
601 if (!(flags & FAN_MARK_IGNORED_MASK)) {
602 __u32 tmask = fsn_mark->mask | mask;
604 if (flags & FAN_MARK_ONDIR)
607 oldmask = fsn_mark->mask;
608 fsn_mark->mask = tmask;
610 __u32 tmask = fsn_mark->ignored_mask | mask;
611 if (flags & FAN_MARK_ONDIR)
614 fsn_mark->ignored_mask = tmask;
615 if (flags & FAN_MARK_IGNORED_SURV_MODIFY)
616 fsn_mark->flags |= FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY;
618 spin_unlock(&fsn_mark->lock);
620 return mask & ~oldmask;
623 static struct fsnotify_mark *fanotify_add_new_mark(struct fsnotify_group *group,
625 struct vfsmount *mnt)
627 struct fsnotify_mark *mark;
630 if (atomic_read(&group->num_marks) > group->fanotify_data.max_marks)
631 return ERR_PTR(-ENOSPC);
633 mark = kmem_cache_alloc(fanotify_mark_cache, GFP_KERNEL);
635 return ERR_PTR(-ENOMEM);
637 fsnotify_init_mark(mark, group);
638 ret = fsnotify_add_mark_locked(mark, inode, mnt, 0);
640 fsnotify_put_mark(mark);
648 static int fanotify_add_vfsmount_mark(struct fsnotify_group *group,
649 struct vfsmount *mnt, __u32 mask,
652 struct fsnotify_mark *fsn_mark;
655 mutex_lock(&group->mark_mutex);
656 fsn_mark = fsnotify_find_mark(&real_mount(mnt)->mnt_fsnotify_marks,
659 fsn_mark = fanotify_add_new_mark(group, NULL, mnt);
660 if (IS_ERR(fsn_mark)) {
661 mutex_unlock(&group->mark_mutex);
662 return PTR_ERR(fsn_mark);
665 added = fanotify_mark_add_to_mask(fsn_mark, mask, flags);
666 if (added & ~real_mount(mnt)->mnt_fsnotify_mask)
667 fsnotify_recalc_mask(real_mount(mnt)->mnt_fsnotify_marks);
668 mutex_unlock(&group->mark_mutex);
670 fsnotify_put_mark(fsn_mark);
674 static int fanotify_add_inode_mark(struct fsnotify_group *group,
675 struct inode *inode, __u32 mask,
678 struct fsnotify_mark *fsn_mark;
681 pr_debug("%s: group=%p inode=%p\n", __func__, group, inode);
684 * If some other task has this inode open for write we should not add
685 * an ignored mark, unless that ignored mark is supposed to survive
686 * modification changes anyway.
688 if ((flags & FAN_MARK_IGNORED_MASK) &&
689 !(flags & FAN_MARK_IGNORED_SURV_MODIFY) &&
690 (atomic_read(&inode->i_writecount) > 0))
693 mutex_lock(&group->mark_mutex);
694 fsn_mark = fsnotify_find_mark(&inode->i_fsnotify_marks, group);
696 fsn_mark = fanotify_add_new_mark(group, inode, NULL);
697 if (IS_ERR(fsn_mark)) {
698 mutex_unlock(&group->mark_mutex);
699 return PTR_ERR(fsn_mark);
702 added = fanotify_mark_add_to_mask(fsn_mark, mask, flags);
703 if (added & ~inode->i_fsnotify_mask)
704 fsnotify_recalc_mask(inode->i_fsnotify_marks);
705 mutex_unlock(&group->mark_mutex);
707 fsnotify_put_mark(fsn_mark);
711 /* fanotify syscalls */
712 SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags)
714 struct fsnotify_group *group;
716 struct user_struct *user;
717 struct fanotify_event_info *oevent;
719 pr_debug("%s: flags=%d event_f_flags=%d\n",
720 __func__, flags, event_f_flags);
722 if (!capable(CAP_SYS_ADMIN))
725 if (flags & ~FAN_ALL_INIT_FLAGS)
728 if (event_f_flags & ~FANOTIFY_INIT_ALL_EVENT_F_BITS)
731 switch (event_f_flags & O_ACCMODE) {
740 user = get_current_user();
741 if (atomic_read(&user->fanotify_listeners) > FANOTIFY_DEFAULT_MAX_LISTENERS) {
746 f_flags = O_RDWR | FMODE_NONOTIFY;
747 if (flags & FAN_CLOEXEC)
748 f_flags |= O_CLOEXEC;
749 if (flags & FAN_NONBLOCK)
750 f_flags |= O_NONBLOCK;
752 /* fsnotify_alloc_group takes a ref. Dropped in fanotify_release */
753 group = fsnotify_alloc_group(&fanotify_fsnotify_ops);
756 return PTR_ERR(group);
759 group->fanotify_data.user = user;
760 atomic_inc(&user->fanotify_listeners);
762 oevent = fanotify_alloc_event(NULL, FS_Q_OVERFLOW, NULL);
763 if (unlikely(!oevent)) {
765 goto out_destroy_group;
767 group->overflow_event = &oevent->fse;
769 if (force_o_largefile())
770 event_f_flags |= O_LARGEFILE;
771 group->fanotify_data.f_flags = event_f_flags;
772 #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
773 init_waitqueue_head(&group->fanotify_data.access_waitq);
774 INIT_LIST_HEAD(&group->fanotify_data.access_list);
776 switch (flags & FAN_ALL_CLASS_BITS) {
777 case FAN_CLASS_NOTIF:
778 group->priority = FS_PRIO_0;
780 case FAN_CLASS_CONTENT:
781 group->priority = FS_PRIO_1;
783 case FAN_CLASS_PRE_CONTENT:
784 group->priority = FS_PRIO_2;
788 goto out_destroy_group;
791 if (flags & FAN_UNLIMITED_QUEUE) {
793 if (!capable(CAP_SYS_ADMIN))
794 goto out_destroy_group;
795 group->max_events = UINT_MAX;
797 group->max_events = FANOTIFY_DEFAULT_MAX_EVENTS;
800 if (flags & FAN_UNLIMITED_MARKS) {
802 if (!capable(CAP_SYS_ADMIN))
803 goto out_destroy_group;
804 group->fanotify_data.max_marks = UINT_MAX;
806 group->fanotify_data.max_marks = FANOTIFY_DEFAULT_MAX_MARKS;
809 fd = anon_inode_getfd("[fanotify]", &fanotify_fops, group, f_flags);
811 goto out_destroy_group;
816 fsnotify_destroy_group(group);
820 SYSCALL_DEFINE5(fanotify_mark, int, fanotify_fd, unsigned int, flags,
821 __u64, mask, int, dfd,
822 const char __user *, pathname)
824 struct inode *inode = NULL;
825 struct vfsmount *mnt = NULL;
826 struct fsnotify_group *group;
831 pr_debug("%s: fanotify_fd=%d flags=%x dfd=%d pathname=%p mask=%llx\n",
832 __func__, fanotify_fd, flags, dfd, pathname, mask);
834 /* we only use the lower 32 bits as of right now. */
835 if (mask & ((__u64)0xffffffff << 32))
838 if (flags & ~FAN_ALL_MARK_FLAGS)
840 switch (flags & (FAN_MARK_ADD | FAN_MARK_REMOVE | FAN_MARK_FLUSH)) {
841 case FAN_MARK_ADD: /* fallthrough */
842 case FAN_MARK_REMOVE:
847 if (flags & ~(FAN_MARK_MOUNT | FAN_MARK_FLUSH))
854 if (mask & FAN_ONDIR) {
855 flags |= FAN_MARK_ONDIR;
859 #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
860 if (mask & ~(FAN_ALL_EVENTS | FAN_ALL_PERM_EVENTS | FAN_EVENT_ON_CHILD))
862 if (mask & ~(FAN_ALL_EVENTS | FAN_EVENT_ON_CHILD))
866 f = fdget(fanotify_fd);
867 if (unlikely(!f.file))
870 /* verify that this is indeed an fanotify instance */
872 if (unlikely(f.file->f_op != &fanotify_fops))
874 group = f.file->private_data;
877 * group->priority == FS_PRIO_0 == FAN_CLASS_NOTIF. These are not
878 * allowed to set permissions events.
881 if (mask & FAN_ALL_PERM_EVENTS &&
882 group->priority == FS_PRIO_0)
885 if (flags & FAN_MARK_FLUSH) {
887 if (flags & FAN_MARK_MOUNT)
888 fsnotify_clear_vfsmount_marks_by_group(group);
890 fsnotify_clear_inode_marks_by_group(group);
894 ret = fanotify_find_path(dfd, pathname, &path, flags);
898 /* inode held in place by reference to path; group by fget on fd */
899 if (!(flags & FAN_MARK_MOUNT))
900 inode = path.dentry->d_inode;
904 /* create/update an inode mark */
905 switch (flags & (FAN_MARK_ADD | FAN_MARK_REMOVE)) {
907 if (flags & FAN_MARK_MOUNT)
908 ret = fanotify_add_vfsmount_mark(group, mnt, mask, flags);
910 ret = fanotify_add_inode_mark(group, inode, mask, flags);
912 case FAN_MARK_REMOVE:
913 if (flags & FAN_MARK_MOUNT)
914 ret = fanotify_remove_vfsmount_mark(group, mnt, mask, flags);
916 ret = fanotify_remove_inode_mark(group, inode, mask, flags);
929 COMPAT_SYSCALL_DEFINE6(fanotify_mark,
930 int, fanotify_fd, unsigned int, flags,
931 __u32, mask0, __u32, mask1, int, dfd,
932 const char __user *, pathname)
934 return sys_fanotify_mark(fanotify_fd, flags,
936 ((__u64)mask0 << 32) | mask1,
938 ((__u64)mask1 << 32) | mask0,
945 * fanotify_user_setup - Our initialization function. Note that we cannot return
946 * error because we have compiled-in VFS hooks. So an (unlikely) failure here
947 * must result in panic().
949 static int __init fanotify_user_setup(void)
951 fanotify_mark_cache = KMEM_CACHE(fsnotify_mark, SLAB_PANIC);
952 fanotify_event_cachep = KMEM_CACHE(fanotify_event_info, SLAB_PANIC);
953 #ifdef CONFIG_FANOTIFY_ACCESS_PERMISSIONS
954 fanotify_perm_event_cachep = KMEM_CACHE(fanotify_perm_event_info,
960 device_initcall(fanotify_user_setup);