]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
ff0b16a9 EP |
2 | #ifndef _LINUX_FANOTIFY_H |
3 | #define _LINUX_FANOTIFY_H | |
4 | ||
5b8fea65 | 5 | #include <linux/sysctl.h> |
607ca46e | 6 | #include <uapi/linux/fanotify.h> |
ff0b16a9 | 7 | |
5b8fea65 AG |
8 | extern struct ctl_table fanotify_table[]; /* for sysctl */ |
9 | ||
96a71f21 AG |
10 | #define FAN_GROUP_FLAG(group, flag) \ |
11 | ((group)->fanotify_data.flags & (flag)) | |
12 | ||
23c9deeb AG |
13 | /* |
14 | * Flags allowed to be passed from/to userspace. | |
15 | * | |
16 | * We intentionally do not add new bits to the old FAN_ALL_* constants, because | |
17 | * they are uapi exposed constants. If there are programs out there using | |
18 | * these constant, the programs may break if re-compiled with new uapi headers | |
19 | * and then run on an old kernel. | |
20 | */ | |
7cea2a3c AG |
21 | |
22 | /* Group classes where permission events are allowed */ | |
23 | #define FANOTIFY_PERM_CLASSES (FAN_CLASS_CONTENT | \ | |
23c9deeb AG |
24 | FAN_CLASS_PRE_CONTENT) |
25 | ||
7cea2a3c AG |
26 | #define FANOTIFY_CLASS_BITS (FAN_CLASS_NOTIF | FANOTIFY_PERM_CLASSES) |
27 | ||
929943b3 | 28 | #define FANOTIFY_FID_BITS (FAN_REPORT_FID | FAN_REPORT_DFID_NAME) |
d809daf1 | 29 | |
af579beb | 30 | #define FANOTIFY_INFO_MODES (FANOTIFY_FID_BITS | FAN_REPORT_PIDFD) |
0aca67bb | 31 | |
7cea2a3c AG |
32 | /* |
33 | * fanotify_init() flags that require CAP_SYS_ADMIN. | |
34 | * We do not allow unprivileged groups to request permission events. | |
35 | * We do not allow unprivileged groups to get other process pid in events. | |
36 | * We do not allow unprivileged groups to use unlimited resources. | |
37 | */ | |
38 | #define FANOTIFY_ADMIN_INIT_FLAGS (FANOTIFY_PERM_CLASSES | \ | |
39 | FAN_REPORT_TID | \ | |
af579beb | 40 | FAN_REPORT_PIDFD | \ |
7cea2a3c AG |
41 | FAN_UNLIMITED_QUEUE | \ |
42 | FAN_UNLIMITED_MARKS) | |
43 | ||
44 | /* | |
45 | * fanotify_init() flags that are allowed for user without CAP_SYS_ADMIN. | |
46 | * FAN_CLASS_NOTIF is the only class we allow for unprivileged group. | |
47 | * We do not allow unprivileged groups to get file descriptors in events, | |
48 | * so one of the flags for reporting file handles is required. | |
49 | */ | |
50 | #define FANOTIFY_USER_INIT_FLAGS (FAN_CLASS_NOTIF | \ | |
51 | FANOTIFY_FID_BITS | \ | |
52 | FAN_CLOEXEC | FAN_NONBLOCK) | |
53 | ||
54 | #define FANOTIFY_INIT_FLAGS (FANOTIFY_ADMIN_INIT_FLAGS | \ | |
55 | FANOTIFY_USER_INIT_FLAGS) | |
23c9deeb | 56 | |
a8b98c80 AG |
57 | /* Internal group flags */ |
58 | #define FANOTIFY_UNPRIV 0x80000000 | |
59 | #define FANOTIFY_INTERNAL_GROUP_FLAGS (FANOTIFY_UNPRIV) | |
60 | ||
23c9deeb AG |
61 | #define FANOTIFY_MARK_TYPE_BITS (FAN_MARK_INODE | FAN_MARK_MOUNT | \ |
62 | FAN_MARK_FILESYSTEM) | |
63 | ||
64 | #define FANOTIFY_MARK_FLAGS (FANOTIFY_MARK_TYPE_BITS | \ | |
65 | FAN_MARK_ADD | \ | |
66 | FAN_MARK_REMOVE | \ | |
67 | FAN_MARK_DONT_FOLLOW | \ | |
68 | FAN_MARK_ONLYDIR | \ | |
69 | FAN_MARK_IGNORED_MASK | \ | |
70 | FAN_MARK_IGNORED_SURV_MODIFY | \ | |
71 | FAN_MARK_FLUSH) | |
72 | ||
235328d1 AG |
73 | /* |
74 | * Events that can be reported with data type FSNOTIFY_EVENT_PATH. | |
75 | * Note that FAN_MODIFY can also be reported with data type | |
76 | * FSNOTIFY_EVENT_INODE. | |
77 | */ | |
78 | #define FANOTIFY_PATH_EVENTS (FAN_ACCESS | FAN_MODIFY | \ | |
9b076f1c | 79 | FAN_CLOSE | FAN_OPEN | FAN_OPEN_EXEC) |
23c9deeb | 80 | |
235328d1 AG |
81 | /* |
82 | * Directory entry modification events - reported only to directory | |
83 | * where entry is modified and not to a watching parent. | |
84 | */ | |
f1793699 | 85 | #define FANOTIFY_DIRENT_EVENTS (FAN_MOVE | FAN_CREATE | FAN_DELETE) |
235328d1 AG |
86 | |
87 | /* Events that can only be reported with data type FSNOTIFY_EVENT_INODE */ | |
88 | #define FANOTIFY_INODE_EVENTS (FANOTIFY_DIRENT_EVENTS | \ | |
89 | FAN_ATTRIB | FAN_MOVE_SELF | FAN_DELETE_SELF) | |
90 | ||
91 | /* Events that user can request to be notified on */ | |
92 | #define FANOTIFY_EVENTS (FANOTIFY_PATH_EVENTS | \ | |
93 | FANOTIFY_INODE_EVENTS) | |
94 | ||
23c9deeb | 95 | /* Events that require a permission response from user */ |
66917a31 MB |
96 | #define FANOTIFY_PERM_EVENTS (FAN_OPEN_PERM | FAN_ACCESS_PERM | \ |
97 | FAN_OPEN_EXEC_PERM) | |
23c9deeb | 98 | |
bdd5a46f AG |
99 | /* Extra flags that may be reported with event or control handling of events */ |
100 | #define FANOTIFY_EVENT_FLAGS (FAN_EVENT_ON_CHILD | FAN_ONDIR) | |
101 | ||
23c9deeb AG |
102 | /* Events that may be reported to user */ |
103 | #define FANOTIFY_OUTGOING_EVENTS (FANOTIFY_EVENTS | \ | |
104 | FANOTIFY_PERM_EVENTS | \ | |
e7fce6d9 | 105 | FAN_Q_OVERFLOW | FAN_ONDIR) |
23c9deeb | 106 | |
bdd5a46f AG |
107 | #define ALL_FANOTIFY_EVENT_BITS (FANOTIFY_OUTGOING_EVENTS | \ |
108 | FANOTIFY_EVENT_FLAGS) | |
109 | ||
23c9deeb AG |
110 | /* Do not use these old uapi constants internally */ |
111 | #undef FAN_ALL_CLASS_BITS | |
112 | #undef FAN_ALL_INIT_FLAGS | |
113 | #undef FAN_ALL_MARK_FLAGS | |
114 | #undef FAN_ALL_EVENTS | |
115 | #undef FAN_ALL_PERM_EVENTS | |
116 | #undef FAN_ALL_OUTGOING_EVENTS | |
117 | ||
ff0b16a9 | 118 | #endif /* _LINUX_FANOTIFY_H */ |