[FIX] ARM: add mandatory lr check on uretprobes disarming
[kernel/swap-modules.git] / ks_features / features_data.c
1 /*
2  *  SWAP kernel features
3  *  modules/ks_features/features_data.c
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  *
19  * Copyright (C) Samsung Electronics, 2013
20  *
21  * 2013  Vyacheslav Cherkashin: SWAP ks_features implement
22  *
23  */
24
25
26 #include "syscall_list.h"
27 #include <linux/mutex.h>
28
29 struct feature {
30         size_t cnt;
31         enum syscall_id *feature_list;
32         int sub_type;
33
34         unsigned enable:1;
35 };
36
37 #define X(name, args) id_##name
38 enum syscall_id {
39         SYSCALL_LIST
40 };
41 #undef X
42
43 static enum syscall_id id_none[] = {};
44
45 static enum syscall_id id_file[] = {
46         id_sys_acct,
47         id_sys_mount,
48         id_sys_umount,
49         id_sys_truncate,
50 /* TODO:
51  *      id_sys_stat,
52  */
53         id_sys_statfs,
54         id_sys_statfs64,
55 /* TODO:
56  *      id_sys_lstat,
57  */
58         id_sys_stat64,
59         id_sys_fstat64,
60         id_sys_lstat64,
61         id_sys_truncate64,
62         id_sys_ftruncate64,
63         id_sys_setxattr,
64         id_sys_getxattr,
65         id_sys_listxattr,
66         id_sys_removexattr,
67         id_sys_chroot,
68         id_sys_mknod,
69         id_sys_link,
70         id_sys_symlink,
71         id_sys_unlink,
72         id_sys_rename,
73         id_sys_chmod,
74         id_sys_readlink,
75         id_sys_creat,
76         id_sys_open,
77         id_sys_access,
78         id_sys_chown,
79         id_sys_chown16,
80         id_sys_utime,
81         id_sys_utimes,
82         id_sys_pread64,
83         id_sys_pwrite64,
84         id_sys_preadv,
85         id_sys_pwritev,
86         id_sys_getcwd,
87         id_sys_mkdir,
88         id_sys_chdir,
89         id_sys_rmdir,
90         id_sys_swapon,
91         id_sys_swapoff,
92         id_sys_uselib,
93         id_sys_mknodat,
94         id_sys_mkdirat,
95         id_sys_unlinkat,
96         id_sys_symlinkat,
97         id_sys_linkat,
98         id_sys_renameat,
99         id_sys_futimesat,
100         id_sys_faccessat,
101         id_sys_fchmodat,
102         id_sys_fchownat,
103         id_sys_openat,
104 /* TODO:
105  *      id_sys_newfstatat,
106  */
107         id_sys_readlinkat,
108         id_sys_utimensat,
109         id_sys_fanotify_mark,
110         id_sys_execve,
111         id_sys_name_to_handle_at,
112         id_sys_open_by_handle_at
113 };
114
115 static enum syscall_id id_ipc[] = {
116         id_sys_msgget,
117         id_sys_msgsnd,
118         id_sys_msgrcv,
119         id_sys_msgctl,
120         id_sys_semget,
121         id_sys_semop,
122         id_sys_semctl,
123         id_sys_semtimedop,
124         id_sys_shmat,
125         id_sys_shmget,
126         id_sys_shmdt,
127         id_sys_shmctl,
128         id_sys_ipc
129 };
130
131 static enum syscall_id id_net[] = {
132         id_sys_shutdown,
133         id_sys_sendfile,
134         id_sys_sendfile64,
135         id_sys_setsockopt,
136         id_sys_getsockopt,
137         id_sys_bind,
138         id_sys_connect,
139         id_sys_accept,
140         id_sys_accept4,
141         id_sys_getsockname,
142         id_sys_getpeername,
143         id_sys_send,
144         id_sys_sendto,
145         id_sys_sendmsg,
146         id_sys_sendmmsg,
147         id_sys_recv,
148         id_sys_recvfrom,
149         id_sys_recvmsg,
150         id_sys_recvmmsg,
151         id_sys_socket,
152         id_sys_socketpair,
153         id_sys_socketcall,
154         id_sys_listen
155 };
156
157 static enum syscall_id id_process[] = {
158         id_sys_exit,
159         id_sys_exit_group,
160         id_sys_wait4,
161         id_sys_waitid,
162 /* TODO:
163  *      id_sys_waitpid,
164  */
165         id_sys_rt_tgsigqueueinfo,
166         id_sys_unshare,
167         id_sys_fork,
168         id_sys_vfork,
169 /* TODO: add support CONFIG_CLONE_BACKWARDS
170  *      id_sys_clone,
171  *      id_sys_clone,
172  */
173     id_sys_execve
174 };
175
176 static enum syscall_id id_signal[] = {
177         id_sys_sigpending,
178         id_sys_sigprocmask,
179 /* TODO:
180  *      id_sys_sigaltstack,
181  */
182 /* TODO: add support CONFIG_OLD_SIGSUSPEND and CONFIG_OLD_SIGSUSPEND3
183  *      id_sys_sigsuspend,
184  *      id_sys_sigsuspend,
185  */
186         id_sys_rt_sigsuspend,
187         id_sys_sigaction,
188         id_sys_rt_sigaction,
189         id_sys_rt_sigprocmask,
190         id_sys_rt_sigtimedwait,
191         id_sys_rt_tgsigqueueinfo,
192         id_sys_kill,
193         id_sys_tgkill,
194 /* TODO:
195  *      id_sys_signal,
196  */
197         id_sys_pause,
198         id_sys_signalfd,
199         id_sys_signalfd4
200 };
201
202 static enum syscall_id id_desc[] = {
203         id_sys_fgetxattr,
204         id_sys_flistxattr,
205         id_sys_fremovexattr,
206         id_sys_fadvise64_64,
207         id_sys_pipe2,
208         id_sys_dup3,
209         id_sys_sendfile,
210         id_sys_sendfile64,
211         id_sys_preadv,
212         id_sys_pwritev,
213         id_sys_epoll_create1,
214         id_sys_epoll_ctl,
215         id_sys_epoll_wait,
216         id_sys_epoll_pwait,
217         id_sys_inotify_init,
218         id_sys_inotify_init1,
219         id_sys_inotify_add_watch,
220         id_sys_inotify_rm_watch,
221         id_sys_mknodat,
222         id_sys_mkdirat,
223         id_sys_unlinkat,
224         id_sys_symlinkat,
225         id_sys_linkat,
226         id_sys_renameat,
227         id_sys_futimesat,
228         id_sys_faccessat,
229         id_sys_fchmodat,
230         id_sys_fchownat,
231         id_sys_openat,
232 /* TODO:
233  *      id_sys_newfstatat,
234  */
235         id_sys_readlinkat,
236         id_sys_utimensat,
237         id_sys_splice,
238         id_sys_vmsplice,
239         id_sys_tee,
240         id_sys_signalfd,
241         id_sys_signalfd4,
242         id_sys_timerfd_create,
243         id_sys_timerfd_settime,
244         id_sys_timerfd_gettime,
245         id_sys_eventfd,
246         id_sys_eventfd2,
247         id_sys_fallocate,
248         id_sys_pselect6,
249         id_sys_ppoll,
250         id_sys_fanotify_init,
251         id_sys_fanotify_mark,
252         id_sys_syncfs,
253         id_sys_mmap_pgoff,
254         id_sys_old_mmap,
255         id_sys_name_to_handle_at,
256         id_sys_setns
257 };
258
259 #define CREATE_FEATURE(x, subtype)                              \
260 {                                                               \
261         .cnt = sizeof(x) / sizeof(enum syscall_id),             \
262         .feature_list = x,                                      \
263         .sub_type = subtype,                                    \
264         .enable = 0                                             \
265 }
266
267 static struct feature features[] = {
268         CREATE_FEATURE(id_none, PST_NONE),
269         CREATE_FEATURE(id_file, PST_KS_FILE),
270         CREATE_FEATURE(id_ipc, PST_KS_IPC),
271         CREATE_FEATURE(id_process, PST_KS_PROCESS),
272         CREATE_FEATURE(id_signal, PST_KS_SIGNAL),
273         CREATE_FEATURE(id_net, PST_KS_NETWORK),
274         CREATE_FEATURE(id_desc, PST_KS_DESC)
275 };
276
277 enum {
278         feature_cnt = sizeof(features) / sizeof(struct feature)
279 };
280
281 static int feature_index(struct feature *f)
282 {
283         return f - features;
284 }