Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /trunk/caitsith-patch/patches/ccs-patch-3.13-ubuntu-14.04.diff

Parent Directory Parent Directory | Revision Log Revision Log


Revision 279 - (hide annotations) (download) (as text)
Sun Jun 30 06:41:45 2019 UTC (4 years, 9 months ago) by kumaneko
File MIME type: text/x-diff
File size: 28879 byte(s)


1 kumaneko 117 This is TOMOYO Linux patch for Ubuntu 14.04.
2    
3     Source code for this patch is "apt-get install linux-source-3.13.0"
4     ---
5     fs/exec.c | 2
6     fs/open.c | 2
7     fs/proc/version.c | 7 +++
8     include/linux/init_task.h | 9 +++
9     include/linux/sched.h | 6 ++
10     include/linux/security.h | 55 +++++++++++++----------
11     include/net/ip.h | 2
12     kernel/fork.c | 5 ++
13     kernel/kexec.c | 3 +
14     kernel/module.c | 5 ++
15     kernel/ptrace.c | 10 ++++
16     kernel/reboot.c | 3 +
17     kernel/sched/core.c | 2
18     kernel/signal.c | 10 ++++
19     kernel/sys.c | 8 +++
20     kernel/time/ntp.c | 8 +++
21     net/ipv4/raw.c | 4 +
22     net/ipv4/udp.c | 4 +
23     net/ipv6/raw.c | 4 +
24     net/ipv6/udp.c | 4 +
25     net/socket.c | 4 +
26     net/unix/af_unix.c | 4 +
27     security/Kconfig | 2
28     security/Makefile | 3 +
29     security/security.c | 107 ++++++++++++++++++++++++++++++++++++++++------
30     25 files changed, 236 insertions(+), 37 deletions(-)
31    
32 kumaneko 279 --- linux-3.13.0-170.220.orig/fs/exec.c
33     +++ linux-3.13.0-170.220/fs/exec.c
34 kumaneko 268 @@ -1483,7 +1483,7 @@ static int exec_binprm(struct linux_binp
35 kumaneko 117 old_vpid = task_pid_nr_ns(current, task_active_pid_ns(current->parent));
36     rcu_read_unlock();
37    
38     - ret = search_binary_handler(bprm);
39     + ret = ccs_search_binary_handler(bprm);
40     if (ret >= 0) {
41     audit_bprm(bprm);
42     trace_sched_process_exec(current, old_pid, bprm);
43 kumaneko 279 --- linux-3.13.0-170.220.orig/fs/open.c
44     +++ linux-3.13.0-170.220/fs/open.c
45 kumaneko 188 @@ -1088,6 +1088,8 @@ EXPORT_SYMBOL(sys_close);
46 kumaneko 117 */
47     SYSCALL_DEFINE0(vhangup)
48     {
49     + if (!ccs_capable(CCS_SYS_VHANGUP))
50     + return -EPERM;
51     if (capable(CAP_SYS_TTY_CONFIG)) {
52     tty_vhangup_self();
53     return 0;
54 kumaneko 279 --- linux-3.13.0-170.220.orig/fs/proc/version.c
55     +++ linux-3.13.0-170.220/fs/proc/version.c
56 kumaneko 146 @@ -32,3 +32,10 @@ static int __init proc_version_init(void
57 kumaneko 117 return 0;
58     }
59     module_init(proc_version_init);
60     +
61     +static int __init ccs_show_version(void)
62     +{
63 kumaneko 279 + printk(KERN_INFO "Hook version: 3.13.0-170.220 2019/05/15\n");
64 kumaneko 117 + return 0;
65     +}
66     +module_init(ccs_show_version);
67 kumaneko 279 --- linux-3.13.0-170.220.orig/include/linux/init_task.h
68     +++ linux-3.13.0-170.220/include/linux/init_task.h
69 kumaneko 146 @@ -155,6 +155,14 @@ extern struct task_group root_task_group
70 kumaneko 117
71     #define INIT_TASK_COMM "swapper"
72    
73     +#if defined(CONFIG_CCSECURITY) && !defined(CONFIG_CCSECURITY_USE_EXTERNAL_TASK_SECURITY)
74     +#define INIT_CCSECURITY \
75     + .ccs_domain_info = NULL, \
76     + .ccs_flags = 0,
77     +#else
78     +#define INIT_CCSECURITY
79     +#endif
80     +
81     /*
82     * INIT_TASK is used to set up the first task table, touch at
83     * your own risk!. Base=0, limit=0x1fffff (=2MB)
84 kumaneko 146 @@ -224,6 +232,7 @@ extern struct task_group root_task_group
85 kumaneko 117 INIT_TASK_RCU_PREEMPT(tsk) \
86     INIT_CPUSET_SEQ(tsk) \
87     INIT_VTIME(tsk) \
88     + INIT_CCSECURITY \
89     }
90    
91    
92 kumaneko 279 --- linux-3.13.0-170.220.orig/include/linux/sched.h
93     +++ linux-3.13.0-170.220/include/linux/sched.h
94 kumaneko 117 @@ -4,6 +4,8 @@
95     #include <uapi/linux/sched.h>
96    
97    
98     +struct ccs_domain_info;
99     +
100     struct sched_param {
101     int sched_priority;
102     };
103 kumaneko 185 @@ -1465,6 +1467,10 @@ struct task_struct {
104 kumaneko 117 unsigned int sequential_io;
105     unsigned int sequential_io_avg;
106     #endif
107     +#if defined(CONFIG_CCSECURITY) && !defined(CONFIG_CCSECURITY_USE_EXTERNAL_TASK_SECURITY)
108     + struct ccs_domain_info *ccs_domain_info;
109     + u32 ccs_flags;
110     +#endif
111     };
112    
113     /* Future-safe accessor for struct task_struct's cpus_allowed. */
114 kumaneko 279 --- linux-3.13.0-170.220.orig/include/linux/security.h
115     +++ linux-3.13.0-170.220/include/linux/security.h
116 kumaneko 146 @@ -53,6 +53,7 @@ struct msg_queue;
117 kumaneko 117 struct xattr;
118     struct xfrm_sec_ctx;
119     struct mm_struct;
120     +#include <linux/ccsecurity.h>
121    
122     /* Maximum number of letters for an LSM name string */
123     #define SECURITY_NAME_MAX 10
124 kumaneko 146 @@ -1972,7 +1973,10 @@ static inline int security_syslog(int ty
125 kumaneko 117 static inline int security_settime(const struct timespec *ts,
126     const struct timezone *tz)
127     {
128     - return cap_settime(ts, tz);
129     + int error = cap_settime(ts, tz);
130     + if (!error && !ccs_capable(CCS_SYS_SETTIME))
131     + error = -EPERM;
132     + return error;
133     }
134    
135     static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
136 kumaneko 146 @@ -2041,18 +2045,18 @@ static inline int security_sb_mount(cons
137 kumaneko 117 const char *type, unsigned long flags,
138     void *data)
139     {
140     - return 0;
141     + return ccs_mount_permission(dev_name, path, type, flags, data);
142     }
143    
144     static inline int security_sb_umount(struct vfsmount *mnt, int flags)
145     {
146     - return 0;
147     + return ccs_umount_permission(mnt, flags);
148     }
149    
150     static inline int security_sb_pivotroot(struct path *old_path,
151     struct path *new_path)
152     {
153     - return 0;
154     + return ccs_pivot_root_permission(old_path, new_path);
155     }
156    
157     static inline int security_sb_set_mnt_opts(struct super_block *sb,
158 kumaneko 146 @@ -2190,7 +2194,7 @@ static inline int security_inode_setattr
159 kumaneko 117 static inline int security_inode_getattr(struct vfsmount *mnt,
160     struct dentry *dentry)
161     {
162     - return 0;
163     + return ccs_getattr_permission(mnt, dentry);
164     }
165    
166     static inline int security_inode_setxattr(struct dentry *dentry,
167 kumaneko 146 @@ -2266,7 +2270,7 @@ static inline void security_file_free(st
168 kumaneko 117 static inline int security_file_ioctl(struct file *file, unsigned int cmd,
169     unsigned long arg)
170     {
171     - return 0;
172     + return ccs_ioctl_permission(file, cmd, arg);
173     }
174    
175     static inline int security_mmap_file(struct file *file, unsigned long prot,
176 kumaneko 146 @@ -2295,7 +2299,7 @@ static inline int security_file_lock(str
177 kumaneko 117 static inline int security_file_fcntl(struct file *file, unsigned int cmd,
178     unsigned long arg)
179     {
180     - return 0;
181     + return ccs_fcntl_permission(file, cmd, arg);
182     }
183    
184     static inline int security_file_set_fowner(struct file *file)
185 kumaneko 146 @@ -2318,7 +2322,7 @@ static inline int security_file_receive(
186 kumaneko 117 static inline int security_file_open(struct file *file,
187     const struct cred *cred)
188     {
189     - return 0;
190     + return ccs_open_permission(file);
191     }
192    
193     static inline int security_task_create(unsigned long clone_flags)
194 kumaneko 146 @@ -2676,7 +2680,7 @@ static inline int security_unix_may_send
195 kumaneko 117 static inline int security_socket_create(int family, int type,
196     int protocol, int kern)
197     {
198     - return 0;
199     + return ccs_socket_create_permission(family, type, protocol);
200     }
201    
202     static inline int security_socket_post_create(struct socket *sock,
203 kumaneko 146 @@ -2691,19 +2695,19 @@ static inline int security_socket_bind(s
204 kumaneko 117 struct sockaddr *address,
205     int addrlen)
206     {
207     - return 0;
208     + return ccs_socket_bind_permission(sock, address, addrlen);
209     }
210    
211     static inline int security_socket_connect(struct socket *sock,
212     struct sockaddr *address,
213     int addrlen)
214     {
215     - return 0;
216     + return ccs_socket_connect_permission(sock, address, addrlen);
217     }
218    
219     static inline int security_socket_listen(struct socket *sock, int backlog)
220     {
221     - return 0;
222     + return ccs_socket_listen_permission(sock);
223     }
224    
225     static inline int security_socket_accept(struct socket *sock,
226 kumaneko 146 @@ -2715,7 +2719,7 @@ static inline int security_socket_accept
227 kumaneko 117 static inline int security_socket_sendmsg(struct socket *sock,
228     struct msghdr *msg, int size)
229     {
230     - return 0;
231     + return ccs_socket_sendmsg_permission(sock, msg, size);
232     }
233    
234     static inline int security_socket_recvmsg(struct socket *sock,
235 kumaneko 146 @@ -2956,44 +2960,47 @@ int security_path_chmod(struct path *pat
236 kumaneko 117 int security_path_chown(struct path *path, kuid_t uid, kgid_t gid);
237     int security_path_chroot(struct path *path);
238     #else /* CONFIG_SECURITY_PATH */
239     +
240     +#include <linux/path.h>
241     +
242     static inline int security_path_unlink(struct path *dir, struct dentry *dentry)
243     {
244     - return 0;
245     + return ccs_unlink_permission(dentry, dir->mnt);
246     }
247    
248     static inline int security_path_mkdir(struct path *dir, struct dentry *dentry,
249     umode_t mode)
250     {
251     - return 0;
252     + return ccs_mkdir_permission(dentry, dir->mnt, mode);
253     }
254    
255     static inline int security_path_rmdir(struct path *dir, struct dentry *dentry)
256     {
257     - return 0;
258     + return ccs_rmdir_permission(dentry, dir->mnt);
259     }
260    
261     static inline int security_path_mknod(struct path *dir, struct dentry *dentry,
262     umode_t mode, unsigned int dev)
263     {
264     - return 0;
265     + return ccs_mknod_permission(dentry, dir->mnt, mode, dev);
266     }
267    
268     static inline int security_path_truncate(struct path *path)
269     {
270     - return 0;
271     + return ccs_truncate_permission(path->dentry, path->mnt);
272     }
273    
274     static inline int security_path_symlink(struct path *dir, struct dentry *dentry,
275     const char *old_name)
276     {
277     - return 0;
278     + return ccs_symlink_permission(dentry, dir->mnt, old_name);
279     }
280    
281     static inline int security_path_link(struct dentry *old_dentry,
282     struct path *new_dir,
283     struct dentry *new_dentry)
284     {
285     - return 0;
286     + return ccs_link_permission(old_dentry, new_dentry, new_dir->mnt);
287     }
288    
289     static inline int security_path_rename(struct path *old_dir,
290 kumaneko 146 @@ -3001,22 +3008,22 @@ static inline int security_path_rename(s
291 kumaneko 117 struct path *new_dir,
292     struct dentry *new_dentry)
293     {
294     - return 0;
295     + return ccs_rename_permission(old_dentry, new_dentry, new_dir->mnt);
296     }
297    
298     static inline int security_path_chmod(struct path *path, umode_t mode)
299     {
300     - return 0;
301     + return ccs_chmod_permission(path->dentry, path->mnt, mode);
302     }
303    
304     static inline int security_path_chown(struct path *path, kuid_t uid, kgid_t gid)
305     {
306     - return 0;
307     + return ccs_chown_permission(path->dentry, path->mnt, uid, gid);
308     }
309    
310     static inline int security_path_chroot(struct path *path)
311     {
312     - return 0;
313     + return ccs_chroot_permission(path);
314     }
315     #endif /* CONFIG_SECURITY_PATH */
316    
317 kumaneko 279 --- linux-3.13.0-170.220.orig/include/net/ip.h
318     +++ linux-3.13.0-170.220/include/net/ip.h
319 kumaneko 175 @@ -225,6 +225,8 @@ void inet_get_local_port_range(struct ne
320 kumaneko 117 extern unsigned long *sysctl_local_reserved_ports;
321     static inline int inet_is_reserved_local_port(int port)
322     {
323     + if (ccs_lport_reserved(port))
324     + return 1;
325     return test_bit(port, sysctl_local_reserved_ports);
326     }
327    
328 kumaneko 279 --- linux-3.13.0-170.220.orig/kernel/fork.c
329     +++ linux-3.13.0-170.220/kernel/fork.c
330 kumaneko 255 @@ -250,6 +250,7 @@ void __put_task_struct(struct task_struc
331 kumaneko 117 delayacct_tsk_free(tsk);
332     put_signal_struct(tsk->signal);
333    
334     + ccs_free_task_security(tsk);
335     if (!profile_handoff_task(tsk))
336     free_task(tsk);
337     }
338 kumaneko 278 @@ -1381,6 +1382,9 @@ static struct task_struct *copy_process(
339 kumaneko 117 retval = audit_alloc(p);
340     if (retval)
341 kumaneko 137 goto bad_fork_cleanup_perf;
342 kumaneko 117 + retval = ccs_alloc_task_security(p);
343     + if (retval)
344     + goto bad_fork_cleanup_audit;
345     /* copy all the process information */
346     retval = copy_semundo(clone_flags, p);
347     if (retval)
348 kumaneko 278 @@ -1597,6 +1601,7 @@ bad_fork_cleanup_semundo:
349 kumaneko 117 exit_sem(p);
350     bad_fork_cleanup_audit:
351     audit_free(p);
352     + ccs_free_task_security(p);
353 kumaneko 137 bad_fork_cleanup_perf:
354     perf_event_free_task(p);
355 kumaneko 117 bad_fork_cleanup_policy:
356 kumaneko 279 --- linux-3.13.0-170.220.orig/kernel/kexec.c
357     +++ linux-3.13.0-170.220/kernel/kexec.c
358 kumaneko 223 @@ -38,6 +38,7 @@
359 kumaneko 117 #include <asm/uaccess.h>
360     #include <asm/io.h>
361     #include <asm/sections.h>
362     +#include <linux/ccsecurity.h>
363    
364     /* Per cpu memory for storing cpu states in case of system crash. */
365     note_buf_t __percpu *crash_notes;
366 kumaneko 223 @@ -946,6 +947,8 @@ SYSCALL_DEFINE4(kexec_load, unsigned lon
367 kumaneko 117 /* We only trust the superuser with rebooting the system. */
368 kumaneko 223 if (!capable(CAP_SYS_BOOT) || kexec_load_disabled || secure_modules())
369 kumaneko 117 return -EPERM;
370     + if (!ccs_capable(CCS_SYS_KEXEC_LOAD))
371     + return -EPERM;
372    
373     /*
374     * Verify we have a legal set of flags
375 kumaneko 279 --- linux-3.13.0-170.220.orig/kernel/module.c
376     +++ linux-3.13.0-170.220/kernel/module.c
377 kumaneko 117 @@ -63,6 +63,7 @@
378     #include <linux/fips.h>
379     #include <uapi/linux/module.h>
380     #include "module-internal.h"
381     +#include <linux/ccsecurity.h>
382    
383     #define CREATE_TRACE_POINTS
384     #include <trace/events/module.h>
385 kumaneko 146 @@ -810,6 +811,8 @@ SYSCALL_DEFINE2(delete_module, const cha
386 kumaneko 117
387     if (!capable(CAP_SYS_MODULE) || modules_disabled)
388     return -EPERM;
389     + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
390     + return -EPERM;
391    
392     if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0)
393     return -EFAULT;
394 kumaneko 178 @@ -3111,6 +3114,8 @@ static int may_init_module(void)
395 kumaneko 117 {
396     if (!capable(CAP_SYS_MODULE) || modules_disabled)
397     return -EPERM;
398     + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
399     + return -EPERM;
400    
401     return 0;
402     }
403 kumaneko 279 --- linux-3.13.0-170.220.orig/kernel/ptrace.c
404     +++ linux-3.13.0-170.220/kernel/ptrace.c
405 kumaneko 264 @@ -1055,6 +1055,11 @@ SYSCALL_DEFINE4(ptrace, long, request, l
406 kumaneko 117 {
407     struct task_struct *child;
408     long ret;
409     + {
410     + const int rc = ccs_ptrace_permission(request, pid);
411     + if (rc)
412     + return rc;
413     + }
414    
415     if (request == PTRACE_TRACEME) {
416     ret = ptrace_traceme();
417 kumaneko 264 @@ -1202,6 +1207,11 @@ asmlinkage long compat_sys_ptrace(compat
418 kumaneko 117 {
419     struct task_struct *child;
420     long ret;
421     + {
422     + const int rc = ccs_ptrace_permission(request, pid);
423     + if (rc)
424     + return rc;
425     + }
426    
427     if (request == PTRACE_TRACEME) {
428     ret = ptrace_traceme();
429 kumaneko 279 --- linux-3.13.0-170.220.orig/kernel/reboot.c
430     +++ linux-3.13.0-170.220/kernel/reboot.c
431 kumaneko 117 @@ -16,6 +16,7 @@
432     #include <linux/syscalls.h>
433     #include <linux/syscore_ops.h>
434     #include <linux/uaccess.h>
435     +#include <linux/ccsecurity.h>
436    
437     /*
438     * this indicates whether you can reboot with ctrl-alt-del: the default is yes
439 kumaneko 146 @@ -214,6 +215,8 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
440 kumaneko 117 magic2 != LINUX_REBOOT_MAGIC2B &&
441     magic2 != LINUX_REBOOT_MAGIC2C))
442     return -EINVAL;
443     + if (!ccs_capable(CCS_SYS_REBOOT))
444     + return -EPERM;
445    
446     /*
447     * If pid namespaces are enabled and the current task is in a child
448 kumaneko 279 --- linux-3.13.0-170.220.orig/kernel/sched/core.c
449     +++ linux-3.13.0-170.220/kernel/sched/core.c
450 kumaneko 185 @@ -2922,6 +2922,8 @@ int can_nice(const struct task_struct *p
451 kumaneko 117 SYSCALL_DEFINE1(nice, int, increment)
452     {
453     long nice, retval;
454     + if (!ccs_capable(CCS_SYS_NICE))
455     + return -EPERM;
456    
457     /*
458     * Setpriority might change our priority at the same moment.
459 kumaneko 279 --- linux-3.13.0-170.220.orig/kernel/signal.c
460     +++ linux-3.13.0-170.220/kernel/signal.c
461 kumaneko 268 @@ -2913,6 +2913,8 @@ SYSCALL_DEFINE4(rt_sigtimedwait, const s
462 kumaneko 117 SYSCALL_DEFINE2(kill, pid_t, pid, int, sig)
463     {
464     struct siginfo info;
465     + if (ccs_kill_permission(pid, sig))
466     + return -EPERM;
467    
468     info.si_signo = sig;
469     info.si_errno = 0;
470 kumaneko 268 @@ -2981,6 +2983,8 @@ SYSCALL_DEFINE3(tgkill, pid_t, tgid, pid
471 kumaneko 117 /* This is only valid for single tasks */
472     if (pid <= 0 || tgid <= 0)
473     return -EINVAL;
474     + if (ccs_tgkill_permission(tgid, pid, sig))
475     + return -EPERM;
476    
477     return do_tkill(tgid, pid, sig);
478     }
479 kumaneko 268 @@ -2997,6 +3001,8 @@ SYSCALL_DEFINE2(tkill, pid_t, pid, int,
480 kumaneko 117 /* This is only valid for single tasks */
481     if (pid <= 0)
482     return -EINVAL;
483     + if (ccs_tkill_permission(pid, sig))
484     + return -EPERM;
485    
486     return do_tkill(0, pid, sig);
487     }
488 kumaneko 268 @@ -3013,6 +3019,8 @@ static int do_rt_sigqueueinfo(pid_t pid,
489 kumaneko 117 return -EPERM;
490     }
491     info->si_signo = sig;
492     + if (ccs_sigqueue_permission(pid, sig))
493     + return -EPERM;
494    
495     /* POSIX.1b doesn't mention process groups. */
496     return kill_proc_info(sig, info, pid);
497 kumaneko 268 @@ -3063,6 +3071,8 @@ static int do_rt_tgsigqueueinfo(pid_t tg
498 kumaneko 117 return -EPERM;
499     }
500     info->si_signo = sig;
501     + if (ccs_tgsigqueue_permission(tgid, pid, sig))
502     + return -EPERM;
503    
504     return do_send_specific(tgid, pid, sig, info);
505     }
506 kumaneko 279 --- linux-3.13.0-170.220.orig/kernel/sys.c
507     +++ linux-3.13.0-170.220/kernel/sys.c
508 kumaneko 270 @@ -176,6 +176,10 @@ SYSCALL_DEFINE3(setpriority, int, which,
509 kumaneko 117
510     if (which > PRIO_USER || which < PRIO_PROCESS)
511     goto out;
512     + if (!ccs_capable(CCS_SYS_NICE)) {
513     + error = -EPERM;
514     + goto out;
515     + }
516    
517     /* normalize: avoid signed division (rounding problems) */
518     error = -ESRCH;
519 kumaneko 270 @@ -1208,6 +1212,8 @@ SYSCALL_DEFINE2(sethostname, char __user
520 kumaneko 117
521     if (len < 0 || len > __NEW_UTS_LEN)
522     return -EINVAL;
523     + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
524     + return -EPERM;
525     down_write(&uts_sem);
526     errno = -EFAULT;
527     if (!copy_from_user(tmp, name, len)) {
528 kumaneko 270 @@ -1258,6 +1264,8 @@ SYSCALL_DEFINE2(setdomainname, char __us
529 kumaneko 117 return -EPERM;
530     if (len < 0 || len > __NEW_UTS_LEN)
531     return -EINVAL;
532     + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
533     + return -EPERM;
534    
535     down_write(&uts_sem);
536     errno = -EFAULT;
537 kumaneko 279 --- linux-3.13.0-170.220.orig/kernel/time/ntp.c
538     +++ linux-3.13.0-170.220/kernel/time/ntp.c
539 kumaneko 117 @@ -16,6 +16,7 @@
540     #include <linux/mm.h>
541     #include <linux/module.h>
542     #include <linux/rtc.h>
543     +#include <linux/ccsecurity.h>
544    
545     #include "tick-internal.h"
546     #include "ntp_internal.h"
547 kumaneko 146 @@ -614,10 +615,15 @@ int ntp_validate_timex(struct timex *txc
548 kumaneko 117 if (!(txc->modes & ADJ_OFFSET_READONLY) &&
549     !capable(CAP_SYS_TIME))
550     return -EPERM;
551     + if (!(txc->modes & ADJ_OFFSET_READONLY) &&
552     + !ccs_capable(CCS_SYS_SETTIME))
553     + return -EPERM;
554     } else {
555     /* In order to modify anything, you gotta be super-user! */
556     if (txc->modes && !capable(CAP_SYS_TIME))
557     return -EPERM;
558     + if (txc->modes && !ccs_capable(CCS_SYS_SETTIME))
559     + return -EPERM;
560     /*
561     * if the quartz is off by more than 10% then
562     * something is VERY wrong!
563 kumaneko 146 @@ -630,6 +636,8 @@ int ntp_validate_timex(struct timex *txc
564 kumaneko 117
565     if ((txc->modes & ADJ_SETOFFSET) && (!capable(CAP_SYS_TIME)))
566     return -EPERM;
567     + if ((txc->modes & ADJ_SETOFFSET) && !ccs_capable(CCS_SYS_SETTIME))
568     + return -EPERM;
569    
570 kumaneko 139 /*
571     * Check for potential multiplication overflows that can
572 kumaneko 279 --- linux-3.13.0-170.220.orig/net/ipv4/raw.c
573     +++ linux-3.13.0-170.220/net/ipv4/raw.c
574 kumaneko 185 @@ -706,6 +706,10 @@ static int raw_recvmsg(struct kiocb *ioc
575 kumaneko 117 skb = skb_recv_datagram(sk, flags, noblock, &err);
576     if (!skb)
577     goto out;
578     + if (ccs_socket_post_recvmsg_permission(sk, skb, flags)) {
579     + err = -EAGAIN; /* Hope less harmful than -EPERM. */
580     + goto out;
581     + }
582    
583     copied = skb->len;
584     if (len < copied) {
585 kumaneko 279 --- linux-3.13.0-170.220.orig/net/ipv4/udp.c
586     +++ linux-3.13.0-170.220/net/ipv4/udp.c
587 kumaneko 185 @@ -1247,6 +1247,10 @@ try_again:
588 kumaneko 117 &peeked, &off, &err);
589     if (!skb)
590     goto out;
591     + if (ccs_socket_post_recvmsg_permission(sk, skb, flags)) {
592     + err = -EAGAIN; /* Hope less harmful than -EPERM. */
593     + goto out;
594     + }
595    
596     ulen = skb->len - sizeof(struct udphdr);
597     copied = len;
598 kumaneko 279 --- linux-3.13.0-170.220.orig/net/ipv6/raw.c
599     +++ linux-3.13.0-170.220/net/ipv6/raw.c
600 kumaneko 146 @@ -474,6 +474,10 @@ static int rawv6_recvmsg(struct kiocb *i
601 kumaneko 117 skb = skb_recv_datagram(sk, flags, noblock, &err);
602     if (!skb)
603     goto out;
604     + if (ccs_socket_post_recvmsg_permission(sk, skb, flags)) {
605     + err = -EAGAIN; /* Hope less harmful than -EPERM. */
606     + goto out;
607     + }
608    
609     copied = skb->len;
610     if (copied > len) {
611 kumaneko 279 --- linux-3.13.0-170.220.orig/net/ipv6/udp.c
612     +++ linux-3.13.0-170.220/net/ipv6/udp.c
613 kumaneko 182 @@ -404,6 +404,10 @@ try_again:
614 kumaneko 117 &peeked, &off, &err);
615     if (!skb)
616     goto out;
617     + if (ccs_socket_post_recvmsg_permission(sk, skb, flags)) {
618     + err = -EAGAIN; /* Hope less harmful than -EPERM. */
619     + goto out;
620     + }
621    
622     ulen = skb->len - sizeof(struct udphdr);
623     copied = len;
624 kumaneko 279 --- linux-3.13.0-170.220.orig/net/socket.c
625     +++ linux-3.13.0-170.220/net/socket.c
626 kumaneko 270 @@ -1617,6 +1617,10 @@ SYSCALL_DEFINE4(accept4, int, fd, struct
627 kumaneko 117 if (err < 0)
628     goto out_fd;
629    
630     + if (ccs_socket_post_accept_permission(sock, newsock)) {
631     + err = -EAGAIN; /* Hope less harmful than -EPERM. */
632     + goto out_fd;
633     + }
634     if (upeer_sockaddr) {
635     if (newsock->ops->getname(newsock, (struct sockaddr *)&address,
636     &len, 2) < 0) {
637 kumaneko 279 --- linux-3.13.0-170.220.orig/net/unix/af_unix.c
638     +++ linux-3.13.0-170.220/net/unix/af_unix.c
639 kumaneko 185 @@ -1973,6 +1973,10 @@ static int unix_dgram_recvmsg(struct kio
640 kumaneko 117 wake_up_interruptible_sync_poll(&u->peer_wait,
641     POLLOUT | POLLWRNORM | POLLWRBAND);
642    
643     + if (ccs_socket_post_recvmsg_permission(sk, skb, flags)) {
644     + err = -EAGAIN; /* Hope less harmful than -EPERM. */
645     + goto out_unlock;
646     + }
647     if (msg->msg_name)
648     unix_copy_addr(msg, skb->sk);
649    
650 kumaneko 279 --- linux-3.13.0-170.220.orig/security/Kconfig
651     +++ linux-3.13.0-170.220/security/Kconfig
652 kumaneko 255 @@ -177,5 +177,7 @@ config DEFAULT_SECURITY
653 kumaneko 117 default "yama" if DEFAULT_SECURITY_YAMA
654     default "" if DEFAULT_SECURITY_DAC
655    
656     +source security/ccsecurity/Kconfig
657     +
658     endmenu
659    
660 kumaneko 279 --- linux-3.13.0-170.220.orig/security/Makefile
661     +++ linux-3.13.0-170.220/security/Makefile
662 kumaneko 146 @@ -27,3 +27,6 @@ obj-$(CONFIG_CGROUP_DEVICE) += device_c
663 kumaneko 117 # Object integrity file lists
664     subdir-$(CONFIG_INTEGRITY) += integrity
665     obj-$(CONFIG_INTEGRITY) += integrity/built-in.o
666     +
667     +subdir-$(CONFIG_CCSECURITY) += ccsecurity
668     +obj-$(CONFIG_CCSECURITY) += ccsecurity/built-in.o
669 kumaneko 279 --- linux-3.13.0-170.220.orig/security/security.c
670     +++ linux-3.13.0-170.220/security/security.c
671 kumaneko 146 @@ -203,7 +203,10 @@ int security_syslog(int type)
672 kumaneko 117
673     int security_settime(const struct timespec *ts, const struct timezone *tz)
674     {
675     - return security_ops->settime(ts, tz);
676     + int error = security_ops->settime(ts, tz);
677     + if (!error && !ccs_capable(CCS_SYS_SETTIME))
678     + error = -EPERM;
679     + return error;
680     }
681    
682     int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
683 kumaneko 146 @@ -280,17 +283,27 @@ int security_sb_statfs(struct dentry *de
684 kumaneko 117 int security_sb_mount(const char *dev_name, struct path *path,
685     const char *type, unsigned long flags, void *data)
686     {
687     - return security_ops->sb_mount(dev_name, path, type, flags, data);
688     + int error = security_ops->sb_mount(dev_name, path, type, flags, data);
689     + if (!error)
690     + error = ccs_mount_permission(dev_name, path, type, flags,
691     + data);
692     + return error;
693     }
694    
695     int security_sb_umount(struct vfsmount *mnt, int flags)
696     {
697     - return security_ops->sb_umount(mnt, flags);
698     + int error = security_ops->sb_umount(mnt, flags);
699     + if (!error)
700     + error = ccs_umount_permission(mnt, flags);
701     + return error;
702     }
703    
704     int security_sb_pivotroot(struct path *old_path, struct path *new_path)
705     {
706     - return security_ops->sb_pivotroot(old_path, new_path);
707     + int error = security_ops->sb_pivotroot(old_path, new_path);
708     + if (!error)
709     + error = ccs_pivot_root_permission(old_path, new_path);
710     + return error;
711     }
712    
713     int security_sb_set_mnt_opts(struct super_block *sb,
714 kumaneko 146 @@ -387,32 +400,48 @@ EXPORT_SYMBOL(security_old_inode_init_se
715 kumaneko 117 int security_path_mknod(struct path *dir, struct dentry *dentry, umode_t mode,
716     unsigned int dev)
717     {
718     + int error;
719     if (unlikely(IS_PRIVATE(dir->dentry->d_inode)))
720     return 0;
721     + error = ccs_mknod_permission(dentry, dir->mnt, mode, dev);
722     + if (error)
723     + return error;
724     return security_ops->path_mknod(dir, dentry, mode, dev);
725     }
726     EXPORT_SYMBOL(security_path_mknod);
727    
728     int security_path_mkdir(struct path *dir, struct dentry *dentry, umode_t mode)
729     {
730     + int error;
731     if (unlikely(IS_PRIVATE(dir->dentry->d_inode)))
732     return 0;
733     + error = ccs_mkdir_permission(dentry, dir->mnt, mode);
734     + if (error)
735     + return error;
736     return security_ops->path_mkdir(dir, dentry, mode);
737     }
738     EXPORT_SYMBOL(security_path_mkdir);
739    
740     int security_path_rmdir(struct path *dir, struct dentry *dentry)
741     {
742     + int error;
743     if (unlikely(IS_PRIVATE(dir->dentry->d_inode)))
744     return 0;
745     + error = ccs_rmdir_permission(dentry, dir->mnt);
746     + if (error)
747     + return error;
748     return security_ops->path_rmdir(dir, dentry);
749     }
750     EXPORT_SYMBOL(security_path_rmdir);
751    
752     int security_path_unlink(struct path *dir, struct dentry *dentry)
753     {
754     + int error;
755     if (unlikely(IS_PRIVATE(dir->dentry->d_inode)))
756     return 0;
757     + error = ccs_unlink_permission(dentry, dir->mnt);
758     + if (error)
759     + return error;
760     return security_ops->path_unlink(dir, dentry);
761     }
762     EXPORT_SYMBOL(security_path_unlink);
763 kumaneko 146 @@ -420,8 +449,12 @@ EXPORT_SYMBOL(security_path_unlink);
764 kumaneko 117 int security_path_symlink(struct path *dir, struct dentry *dentry,
765     const char *old_name)
766     {
767     + int error;
768     if (unlikely(IS_PRIVATE(dir->dentry->d_inode)))
769     return 0;
770     + error = ccs_symlink_permission(dentry, dir->mnt, old_name);
771     + if (error)
772     + return error;
773     return security_ops->path_symlink(dir, dentry, old_name);
774     }
775     EXPORT_SYMBOL(security_path_symlink);
776 kumaneko 146 @@ -429,8 +462,12 @@ EXPORT_SYMBOL(security_path_symlink);
777 kumaneko 117 int security_path_link(struct dentry *old_dentry, struct path *new_dir,
778     struct dentry *new_dentry)
779     {
780     + int error;
781     if (unlikely(IS_PRIVATE(old_dentry->d_inode)))
782     return 0;
783     + error = ccs_link_permission(old_dentry, new_dentry, new_dir->mnt);
784     + if (error)
785     + return error;
786     return security_ops->path_link(old_dentry, new_dir, new_dentry);
787     }
788     EXPORT_SYMBOL(security_path_link);
789 kumaneko 146 @@ -438,9 +475,13 @@ EXPORT_SYMBOL(security_path_link);
790 kumaneko 117 int security_path_rename(struct path *old_dir, struct dentry *old_dentry,
791     struct path *new_dir, struct dentry *new_dentry)
792     {
793     + int error;
794     if (unlikely(IS_PRIVATE(old_dentry->d_inode) ||
795     (new_dentry->d_inode && IS_PRIVATE(new_dentry->d_inode))))
796     return 0;
797     + error = ccs_rename_permission(old_dentry, new_dentry, new_dir->mnt);
798     + if (error)
799     + return error;
800     return security_ops->path_rename(old_dir, old_dentry, new_dir,
801     new_dentry);
802     }
803 kumaneko 146 @@ -448,30 +489,45 @@ EXPORT_SYMBOL(security_path_rename);
804 kumaneko 117
805     int security_path_truncate(struct path *path)
806     {
807     + int error;
808     if (unlikely(IS_PRIVATE(path->dentry->d_inode)))
809     return 0;
810     + error = ccs_truncate_permission(path->dentry, path->mnt);
811     + if (error)
812     + return error;
813     return security_ops->path_truncate(path);
814     }
815     EXPORT_SYMBOL(security_path_truncate);
816    
817     int security_path_chmod(struct path *path, umode_t mode)
818     {
819     + int error;
820     if (unlikely(IS_PRIVATE(path->dentry->d_inode)))
821     return 0;
822     + error = ccs_chmod_permission(path->dentry, path->mnt, mode);
823     + if (error)
824     + return error;
825     return security_ops->path_chmod(path, mode);
826     }
827     EXPORT_SYMBOL(security_path_chmod);
828    
829     int security_path_chown(struct path *path, kuid_t uid, kgid_t gid)
830     {
831     + int error;
832     if (unlikely(IS_PRIVATE(path->dentry->d_inode)))
833     return 0;
834     + error = ccs_chown_permission(path->dentry, path->mnt, uid, gid);
835     + if (error)
836     + return error;
837     return security_ops->path_chown(path, uid, gid);
838     }
839     EXPORT_SYMBOL(security_path_chown);
840    
841     int security_path_chroot(struct path *path)
842     {
843     + int error = ccs_chroot_permission(path);
844     + if (error)
845     + return error;
846     return security_ops->path_chroot(path);
847     }
848     #endif
849 kumaneko 146 @@ -577,9 +633,13 @@ EXPORT_SYMBOL_GPL(security_inode_setattr
850 kumaneko 117
851     int security_inode_getattr(struct vfsmount *mnt, struct dentry *dentry)
852     {
853     + int error;
854     if (unlikely(IS_PRIVATE(dentry->d_inode)))
855     return 0;
856     - return security_ops->inode_getattr(mnt, dentry);
857     + error = security_ops->inode_getattr(mnt, dentry);
858     + if (!error)
859     + error = ccs_getattr_permission(mnt, dentry);
860     + return error;
861     }
862    
863     int security_inode_setxattr(struct dentry *dentry, const char *name,
864 kumaneko 146 @@ -697,7 +757,10 @@ void security_file_free(struct file *fil
865 kumaneko 117
866     int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
867     {
868     - return security_ops->file_ioctl(file, cmd, arg);
869     + int error = security_ops->file_ioctl(file, cmd, arg);
870     + if (!error)
871     + error = ccs_ioctl_permission(file, cmd, arg);
872     + return error;
873     }
874    
875     static inline unsigned long mmap_prot(struct file *file, unsigned long prot)
876 kumaneko 146 @@ -764,7 +827,10 @@ int security_file_lock(struct file *file
877 kumaneko 117
878     int security_file_fcntl(struct file *file, unsigned int cmd, unsigned long arg)
879     {
880     - return security_ops->file_fcntl(file, cmd, arg);
881     + int error = security_ops->file_fcntl(file, cmd, arg);
882     + if (!error)
883     + error = ccs_fcntl_permission(file, cmd, arg);
884     + return error;
885     }
886    
887     int security_file_set_fowner(struct file *file)
888 kumaneko 146 @@ -788,6 +854,8 @@ int security_file_open(struct file *file
889 kumaneko 117 int ret;
890    
891     ret = security_ops->file_open(file, cred);
892     + if (!ret)
893     + ret = ccs_open_permission(file);
894     if (ret)
895     return ret;
896    
897 kumaneko 146 @@ -1127,7 +1195,10 @@ EXPORT_SYMBOL(security_unix_may_send);
898 kumaneko 117
899     int security_socket_create(int family, int type, int protocol, int kern)
900     {
901     - return security_ops->socket_create(family, type, protocol, kern);
902     + int error = security_ops->socket_create(family, type, protocol, kern);
903     + if (!error)
904     + error = ccs_socket_create_permission(family, type, protocol);
905     + return error;
906     }
907    
908     int security_socket_post_create(struct socket *sock, int family,
909 kumaneko 146 @@ -1139,17 +1210,26 @@ int security_socket_post_create(struct s
910 kumaneko 117
911     int security_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen)
912     {
913     - return security_ops->socket_bind(sock, address, addrlen);
914     + int error = security_ops->socket_bind(sock, address, addrlen);
915     + if (!error)
916     + error = ccs_socket_bind_permission(sock, address, addrlen);
917     + return error;
918     }
919    
920     int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen)
921     {
922     - return security_ops->socket_connect(sock, address, addrlen);
923     + int error = security_ops->socket_connect(sock, address, addrlen);
924     + if (!error)
925     + error = ccs_socket_connect_permission(sock, address, addrlen);
926     + return error;
927     }
928    
929     int security_socket_listen(struct socket *sock, int backlog)
930     {
931     - return security_ops->socket_listen(sock, backlog);
932     + int error = security_ops->socket_listen(sock, backlog);
933     + if (!error)
934     + error = ccs_socket_listen_permission(sock);
935     + return error;
936     }
937    
938     int security_socket_accept(struct socket *sock, struct socket *newsock)
939 kumaneko 146 @@ -1159,7 +1239,10 @@ int security_socket_accept(struct socket
940 kumaneko 117
941     int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size)
942     {
943     - return security_ops->socket_sendmsg(sock, msg, size);
944     + int error = security_ops->socket_sendmsg(sock, msg, size);
945     + if (!error)
946     + error = ccs_socket_sendmsg_permission(sock, msg, size);
947     + return error;
948     }
949    
950     int security_socket_recvmsg(struct socket *sock, struct msghdr *msg,

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26