Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /trunk/caitsith-patch/patches/ccs-patch-4.4.diff

Parent Directory Parent Directory | Revision Log Revision Log


Revision 363 - (hide annotations) (download) (as text)
Tue Feb 22 13:23:01 2022 UTC (2 years, 1 month ago) by kumaneko
File MIME type: text/x-diff
File size: 19672 byte(s)


1 kumaneko 363 This is TOMOYO Linux patch for kernel 4.4.302.
2 kumaneko 175
3 kumaneko 363 Source code for this patch is https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.4.302.tar.xz
4 kumaneko 175 ---
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 | 62 ++++++++++++++++++++++++++++------------------
11     include/net/ip.h | 4 ++
12     kernel/fork.c | 5 +++
13     kernel/kexec.c | 4 ++
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     24 files changed, 150 insertions(+), 26 deletions(-)
30    
31 kumaneko 363 --- linux-4.4.302.orig/fs/exec.c
32     +++ linux-4.4.302/fs/exec.c
33 kumaneko 309 @@ -1514,7 +1514,7 @@ static int exec_binprm(struct linux_binp
34 kumaneko 175 old_vpid = task_pid_nr_ns(current, task_active_pid_ns(current->parent));
35     rcu_read_unlock();
36    
37     - ret = search_binary_handler(bprm);
38     + ret = ccs_search_binary_handler(bprm);
39     if (ret >= 0) {
40     audit_bprm(bprm);
41     trace_sched_process_exec(current, old_pid, bprm);
42 kumaneko 363 --- linux-4.4.302.orig/fs/open.c
43     +++ linux-4.4.302/fs/open.c
44 kumaneko 284 @@ -1136,6 +1136,8 @@ EXPORT_SYMBOL(sys_close);
45 kumaneko 175 */
46     SYSCALL_DEFINE0(vhangup)
47     {
48     + if (!ccs_capable(CCS_SYS_VHANGUP))
49     + return -EPERM;
50     if (capable(CAP_SYS_TTY_CONFIG)) {
51     tty_vhangup_self();
52     return 0;
53 kumaneko 363 --- linux-4.4.302.orig/fs/proc/version.c
54     +++ linux-4.4.302/fs/proc/version.c
55 kumaneko 175 @@ -32,3 +32,10 @@ static int __init proc_version_init(void
56     return 0;
57     }
58     fs_initcall(proc_version_init);
59     +
60     +static int __init ccs_show_version(void)
61     +{
62 kumaneko 363 + printk(KERN_INFO "Hook version: 4.4.302 2022/02/12\n");
63 kumaneko 175 + return 0;
64     +}
65     +fs_initcall(ccs_show_version);
66 kumaneko 363 --- linux-4.4.302.orig/include/linux/init_task.h
67     +++ linux-4.4.302/include/linux/init_task.h
68 kumaneko 291 @@ -191,6 +191,14 @@ extern struct task_group root_task_group
69     # define INIT_TASK_TI(tsk)
70 kumaneko 175 #endif
71    
72     +#if defined(CONFIG_CCSECURITY) && !defined(CONFIG_CCSECURITY_USE_EXTERNAL_TASK_SECURITY)
73     +#define INIT_CCSECURITY \
74     + .ccs_domain_info = NULL, \
75     + .ccs_flags = 0,
76     +#else
77     +#define INIT_CCSECURITY
78     +#endif
79     +
80     /*
81     * INIT_TASK is used to set up the first task table, touch at
82     * your own risk!. Base=0, limit=0x1fffff (=2MB)
83 kumaneko 291 @@ -269,6 +277,7 @@ extern struct task_group root_task_group
84 kumaneko 175 INIT_VTIME(tsk) \
85     INIT_NUMA_BALANCING(tsk) \
86     INIT_KASAN(tsk) \
87     + INIT_CCSECURITY \
88     }
89    
90    
91 kumaneko 363 --- linux-4.4.302.orig/include/linux/sched.h
92     +++ linux-4.4.302/include/linux/sched.h
93 kumaneko 175 @@ -6,6 +6,8 @@
94     #include <linux/sched/prio.h>
95    
96    
97     +struct ccs_domain_info;
98     +
99     struct sched_param {
100     int sched_priority;
101     };
102 kumaneko 335 @@ -1843,6 +1845,10 @@ struct task_struct {
103 kumaneko 175 unsigned long task_state_change;
104     #endif
105     int pagefault_disabled;
106     +#if defined(CONFIG_CCSECURITY) && !defined(CONFIG_CCSECURITY_USE_EXTERNAL_TASK_SECURITY)
107     + struct ccs_domain_info *ccs_domain_info;
108     + u32 ccs_flags;
109     +#endif
110     /* CPU-specific state of this task */
111     struct thread_struct thread;
112     /*
113 kumaneko 363 --- linux-4.4.302.orig/include/linux/security.h
114     +++ linux-4.4.302/include/linux/security.h
115 kumaneko 175 @@ -53,6 +53,7 @@ struct msg_queue;
116     struct xattr;
117     struct xfrm_sec_ctx;
118     struct mm_struct;
119     +#include <linux/ccsecurity.h>
120    
121     /* If capable should audit the security request */
122     #define SECURITY_CAP_NOAUDIT 0
123     @@ -460,7 +461,10 @@ static inline int security_syslog(int ty
124     static inline int security_settime(const struct timespec *ts,
125     const struct timezone *tz)
126     {
127     - return cap_settime(ts, tz);
128     + int error = cap_settime(ts, tz);
129     + if (!error)
130     + error = ccs_settime(ts, tz);
131     + return error;
132     }
133    
134     static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
135     @@ -529,18 +533,18 @@ static inline int security_sb_mount(cons
136     const char *type, unsigned long flags,
137     void *data)
138     {
139     - return 0;
140     + return ccs_sb_mount(dev_name, path, type, flags, data);
141     }
142    
143     static inline int security_sb_umount(struct vfsmount *mnt, int flags)
144     {
145     - return 0;
146     + return ccs_sb_umount(mnt, flags);
147     }
148    
149     static inline int security_sb_pivotroot(struct path *old_path,
150     struct path *new_path)
151     {
152     - return 0;
153     + return ccs_sb_pivotroot(old_path, new_path);
154     }
155    
156     static inline int security_sb_set_mnt_opts(struct super_block *sb,
157     @@ -679,7 +683,7 @@ static inline int security_inode_setattr
158    
159     static inline int security_inode_getattr(const struct path *path)
160     {
161     - return 0;
162     + return ccs_inode_getattr(path);
163     }
164    
165     static inline int security_inode_setxattr(struct dentry *dentry,
166     @@ -755,7 +759,7 @@ static inline void security_file_free(st
167     static inline int security_file_ioctl(struct file *file, unsigned int cmd,
168     unsigned long arg)
169     {
170     - return 0;
171     + return ccs_file_ioctl(file, cmd, arg);
172     }
173    
174     static inline int security_mmap_file(struct file *file, unsigned long prot,
175     @@ -784,7 +788,7 @@ static inline int security_file_lock(str
176     static inline int security_file_fcntl(struct file *file, unsigned int cmd,
177     unsigned long arg)
178     {
179     - return 0;
180     + return ccs_file_fcntl(file, cmd, arg);
181     }
182    
183     static inline void security_file_set_fowner(struct file *file)
184     @@ -807,7 +811,7 @@ static inline int security_file_receive(
185     static inline int security_file_open(struct file *file,
186     const struct cred *cred)
187     {
188     - return 0;
189     + return ccs_file_open(file, cred);
190     }
191    
192     static inline int security_task_create(unsigned long clone_flags)
193     @@ -1169,7 +1173,7 @@ static inline int security_unix_may_send
194     static inline int security_socket_create(int family, int type,
195     int protocol, int kern)
196     {
197     - return 0;
198     + return ccs_socket_create(family, type, protocol, kern);
199     }
200    
201     static inline int security_socket_post_create(struct socket *sock,
202     @@ -1184,19 +1188,19 @@ static inline int security_socket_bind(s
203     struct sockaddr *address,
204     int addrlen)
205     {
206     - return 0;
207     + return ccs_socket_bind(sock, address, addrlen);
208     }
209    
210     static inline int security_socket_connect(struct socket *sock,
211     struct sockaddr *address,
212     int addrlen)
213     {
214     - return 0;
215     + return ccs_socket_connect(sock, address, addrlen);
216     }
217    
218     static inline int security_socket_listen(struct socket *sock, int backlog)
219     {
220     - return 0;
221     + return ccs_socket_listen(sock, backlog);
222     }
223    
224     static inline int security_socket_accept(struct socket *sock,
225     @@ -1208,7 +1212,7 @@ static inline int security_socket_accept
226     static inline int security_socket_sendmsg(struct socket *sock,
227     struct msghdr *msg, int size)
228     {
229     - return 0;
230     + return ccs_socket_sendmsg(sock, msg, size);
231     }
232    
233     static inline int security_socket_recvmsg(struct socket *sock,
234     @@ -1450,42 +1454,42 @@ int security_path_chroot(struct path *pa
235     #else /* CONFIG_SECURITY_PATH */
236     static inline int security_path_unlink(struct path *dir, struct dentry *dentry)
237     {
238     - return 0;
239     + return ccs_path_unlink(dir, dentry);
240     }
241    
242     static inline int security_path_mkdir(struct path *dir, struct dentry *dentry,
243     umode_t mode)
244     {
245     - return 0;
246     + return ccs_path_mkdir(dir, dentry, mode);
247     }
248    
249     static inline int security_path_rmdir(struct path *dir, struct dentry *dentry)
250     {
251     - return 0;
252     + return ccs_path_rmdir(dir, dentry);
253     }
254    
255     static inline int security_path_mknod(struct path *dir, struct dentry *dentry,
256     umode_t mode, unsigned int dev)
257     {
258     - return 0;
259     + return ccs_path_mknod(dir, dentry, mode, dev);
260     }
261    
262     static inline int security_path_truncate(struct path *path)
263     {
264     - return 0;
265     + return ccs_path_truncate(path);
266     }
267    
268     static inline int security_path_symlink(struct path *dir, struct dentry *dentry,
269     const char *old_name)
270     {
271     - return 0;
272     + return ccs_path_symlink(dir, dentry, old_name);
273     }
274    
275     static inline int security_path_link(struct dentry *old_dentry,
276     struct path *new_dir,
277     struct dentry *new_dentry)
278     {
279     - return 0;
280     + return ccs_path_link(old_dentry, new_dir, new_dentry);
281     }
282    
283     static inline int security_path_rename(struct path *old_dir,
284     @@ -1494,22 +1498,32 @@ static inline int security_path_rename(s
285     struct dentry *new_dentry,
286     unsigned int flags)
287     {
288     - return 0;
289     + /*
290     + * Not using RENAME_EXCHANGE here in order to avoid KABI breakage
291     + * by doing "#include <uapi/linux/fs.h>" .
292     + */
293     + if (flags & (1 << 1)) {
294     + int err = ccs_path_rename(new_dir, new_dentry, old_dir,
295     + old_dentry);
296     + if (err)
297     + return err;
298     + }
299     + return ccs_path_rename(old_dir, old_dentry, new_dir, new_dentry);
300     }
301    
302     static inline int security_path_chmod(struct path *path, umode_t mode)
303     {
304     - return 0;
305     + return ccs_path_chmod(path, mode);
306     }
307    
308     static inline int security_path_chown(struct path *path, kuid_t uid, kgid_t gid)
309     {
310     - return 0;
311     + return ccs_path_chown(path, uid, gid);
312     }
313    
314     static inline int security_path_chroot(struct path *path)
315     {
316     - return 0;
317     + return ccs_path_chroot(path);
318     }
319     #endif /* CONFIG_SECURITY_PATH */
320    
321 kumaneko 363 --- linux-4.4.302.orig/include/net/ip.h
322     +++ linux-4.4.302/include/net/ip.h
323 kumaneko 255 @@ -225,6 +225,8 @@ void inet_get_local_port_range(struct ne
324 kumaneko 175 #ifdef CONFIG_SYSCTL
325     static inline int inet_is_local_reserved_port(struct net *net, int port)
326     {
327     + if (ccs_lport_reserved(port))
328     + return 1;
329     if (!net->ipv4.sysctl_local_reserved_ports)
330     return 0;
331     return test_bit(port, net->ipv4.sysctl_local_reserved_ports);
332 kumaneko 255 @@ -238,6 +240,8 @@ static inline bool sysctl_dev_name_is_al
333 kumaneko 175 #else
334     static inline int inet_is_local_reserved_port(struct net *net, int port)
335     {
336     + if (ccs_lport_reserved(port))
337     + return 1;
338     return 0;
339     }
340     #endif
341 kumaneko 363 --- linux-4.4.302.orig/kernel/fork.c
342     +++ linux-4.4.302/kernel/fork.c
343 kumaneko 255 @@ -260,6 +260,7 @@ void __put_task_struct(struct task_struc
344 kumaneko 175 delayacct_tsk_free(tsk);
345     put_signal_struct(tsk->signal);
346    
347     + ccs_free_task_security(tsk);
348     if (!profile_handoff_task(tsk))
349     free_task(tsk);
350     }
351 kumaneko 335 @@ -1468,6 +1469,9 @@ static struct task_struct *copy_process(
352 kumaneko 175 goto bad_fork_cleanup_perf;
353     /* copy all the process information */
354     shm_init_task(p);
355     + retval = ccs_alloc_task_security(p);
356     + if (retval)
357     + goto bad_fork_cleanup_audit;
358     retval = copy_semundo(clone_flags, p);
359     if (retval)
360     goto bad_fork_cleanup_audit;
361 kumaneko 335 @@ -1689,6 +1693,7 @@ bad_fork_cleanup_semundo:
362 kumaneko 175 exit_sem(p);
363     bad_fork_cleanup_audit:
364     audit_free(p);
365     + ccs_free_task_security(p);
366     bad_fork_cleanup_perf:
367     perf_event_free_task(p);
368     bad_fork_cleanup_policy:
369 kumaneko 363 --- linux-4.4.302.orig/kernel/kexec.c
370     +++ linux-4.4.302/kernel/kexec.c
371 kumaneko 175 @@ -17,7 +17,7 @@
372     #include <linux/syscalls.h>
373     #include <linux/vmalloc.h>
374     #include <linux/slab.h>
375     -
376     +#include <linux/ccsecurity.h>
377     #include "kexec_internal.h"
378    
379     static int copy_user_segment_list(struct kimage *image,
380     @@ -133,6 +133,8 @@ SYSCALL_DEFINE4(kexec_load, unsigned lon
381     /* We only trust the superuser with rebooting the system. */
382     if (!capable(CAP_SYS_BOOT) || kexec_load_disabled)
383     return -EPERM;
384     + if (!ccs_capable(CCS_SYS_KEXEC_LOAD))
385     + return -EPERM;
386    
387     /*
388     * Verify we have a legal set of flags
389 kumaneko 363 --- linux-4.4.302.orig/kernel/module.c
390     +++ linux-4.4.302/kernel/module.c
391 kumaneko 175 @@ -61,6 +61,7 @@
392     #include <linux/bsearch.h>
393     #include <uapi/linux/module.h>
394     #include "module-internal.h"
395     +#include <linux/ccsecurity.h>
396    
397     #define CREATE_TRACE_POINTS
398     #include <trace/events/module.h>
399 kumaneko 182 @@ -959,6 +960,8 @@ SYSCALL_DEFINE2(delete_module, const cha
400 kumaneko 175
401     if (!capable(CAP_SYS_MODULE) || modules_disabled)
402     return -EPERM;
403     + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
404     + return -EPERM;
405    
406     if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0)
407     return -EFAULT;
408 kumaneko 339 @@ -3384,6 +3387,8 @@ static int may_init_module(void)
409 kumaneko 175 {
410     if (!capable(CAP_SYS_MODULE) || modules_disabled)
411     return -EPERM;
412     + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
413     + return -EPERM;
414    
415     return 0;
416     }
417 kumaneko 363 --- linux-4.4.302.orig/kernel/ptrace.c
418     +++ linux-4.4.302/kernel/ptrace.c
419 kumaneko 343 @@ -1125,6 +1125,11 @@ SYSCALL_DEFINE4(ptrace, long, request, l
420 kumaneko 175 {
421     struct task_struct *child;
422     long ret;
423     + {
424     + const int rc = ccs_ptrace_permission(request, pid);
425     + if (rc)
426     + return rc;
427     + }
428    
429     if (request == PTRACE_TRACEME) {
430     ret = ptrace_traceme();
431 kumaneko 343 @@ -1271,6 +1276,11 @@ COMPAT_SYSCALL_DEFINE4(ptrace, compat_lo
432 kumaneko 175 {
433     struct task_struct *child;
434     long ret;
435     + {
436     + const int rc = ccs_ptrace_permission(request, pid);
437     + if (rc)
438     + return rc;
439     + }
440    
441     if (request == PTRACE_TRACEME) {
442     ret = ptrace_traceme();
443 kumaneko 363 --- linux-4.4.302.orig/kernel/reboot.c
444     +++ linux-4.4.302/kernel/reboot.c
445 kumaneko 175 @@ -16,6 +16,7 @@
446     #include <linux/syscalls.h>
447     #include <linux/syscore_ops.h>
448     #include <linux/uaccess.h>
449     +#include <linux/ccsecurity.h>
450    
451     /*
452     * this indicates whether you can reboot with ctrl-alt-del: the default is yes
453     @@ -295,6 +296,8 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
454     magic2 != LINUX_REBOOT_MAGIC2B &&
455     magic2 != LINUX_REBOOT_MAGIC2C))
456     return -EINVAL;
457     + if (!ccs_capable(CCS_SYS_REBOOT))
458     + return -EPERM;
459    
460     /*
461     * If pid namespaces are enabled and the current task is in a child
462 kumaneko 363 --- linux-4.4.302.orig/kernel/sched/core.c
463     +++ linux-4.4.302/kernel/sched/core.c
464 kumaneko 362 @@ -3553,6 +3553,8 @@ int can_nice(const struct task_struct *p
465 kumaneko 175 SYSCALL_DEFINE1(nice, int, increment)
466     {
467     long nice, retval;
468     + if (!ccs_capable(CCS_SYS_NICE))
469     + return -EPERM;
470    
471     /*
472     * Setpriority might change our priority at the same moment.
473 kumaneko 363 --- linux-4.4.302.orig/kernel/signal.c
474     +++ linux-4.4.302/kernel/signal.c
475 kumaneko 362 @@ -2930,6 +2930,8 @@ SYSCALL_DEFINE4(rt_sigtimedwait, const s
476 kumaneko 175 SYSCALL_DEFINE2(kill, pid_t, pid, int, sig)
477     {
478     struct siginfo info;
479     + if (ccs_kill_permission(pid, sig))
480     + return -EPERM;
481    
482     info.si_signo = sig;
483     info.si_errno = 0;
484 kumaneko 362 @@ -2998,6 +3000,8 @@ SYSCALL_DEFINE3(tgkill, pid_t, tgid, pid
485 kumaneko 175 /* This is only valid for single tasks */
486     if (pid <= 0 || tgid <= 0)
487     return -EINVAL;
488     + if (ccs_tgkill_permission(tgid, pid, sig))
489     + return -EPERM;
490    
491     return do_tkill(tgid, pid, sig);
492     }
493 kumaneko 362 @@ -3014,6 +3018,8 @@ SYSCALL_DEFINE2(tkill, pid_t, pid, int,
494 kumaneko 175 /* This is only valid for single tasks */
495     if (pid <= 0)
496     return -EINVAL;
497     + if (ccs_tkill_permission(pid, sig))
498     + return -EPERM;
499    
500     return do_tkill(0, pid, sig);
501     }
502 kumaneko 362 @@ -3028,6 +3034,8 @@ static int do_rt_sigqueueinfo(pid_t pid,
503 kumaneko 175 return -EPERM;
504    
505     info->si_signo = sig;
506     + if (ccs_sigqueue_permission(pid, sig))
507     + return -EPERM;
508    
509     /* POSIX.1b doesn't mention process groups. */
510     return kill_proc_info(sig, info, pid);
511 kumaneko 362 @@ -3076,6 +3084,8 @@ static int do_rt_tgsigqueueinfo(pid_t tg
512 kumaneko 175 return -EPERM;
513    
514     info->si_signo = sig;
515     + if (ccs_tgsigqueue_permission(tgid, pid, sig))
516     + return -EPERM;
517    
518     return do_send_specific(tgid, pid, sig, info);
519     }
520 kumaneko 363 --- linux-4.4.302.orig/kernel/sys.c
521     +++ linux-4.4.302/kernel/sys.c
522 kumaneko 266 @@ -185,6 +185,10 @@ SYSCALL_DEFINE3(setpriority, int, which,
523 kumaneko 175
524     if (which > PRIO_USER || which < PRIO_PROCESS)
525     goto out;
526     + if (!ccs_capable(CCS_SYS_NICE)) {
527     + error = -EPERM;
528     + goto out;
529     + }
530    
531     /* normalize: avoid signed division (rounding problems) */
532     error = -ESRCH;
533 kumaneko 324 @@ -1218,6 +1222,8 @@ SYSCALL_DEFINE2(sethostname, char __user
534 kumaneko 175
535     if (len < 0 || len > __NEW_UTS_LEN)
536     return -EINVAL;
537     + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
538     + return -EPERM;
539     errno = -EFAULT;
540     if (!copy_from_user(tmp, name, len)) {
541 kumaneko 268 struct new_utsname *u;
542 kumaneko 324 @@ -1270,6 +1276,8 @@ SYSCALL_DEFINE2(setdomainname, char __us
543 kumaneko 175 return -EPERM;
544     if (len < 0 || len > __NEW_UTS_LEN)
545     return -EINVAL;
546     + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
547     + return -EPERM;
548    
549     errno = -EFAULT;
550 kumaneko 268 if (!copy_from_user(tmp, name, len)) {
551 kumaneko 363 --- linux-4.4.302.orig/kernel/time/ntp.c
552     +++ linux-4.4.302/kernel/time/ntp.c
553 kumaneko 175 @@ -16,6 +16,7 @@
554     #include <linux/mm.h>
555     #include <linux/module.h>
556     #include <linux/rtc.h>
557     +#include <linux/ccsecurity.h>
558    
559     #include "ntp_internal.h"
560    
561 kumaneko 284 @@ -662,10 +663,15 @@ int ntp_validate_timex(struct timex *txc
562 kumaneko 175 if (!(txc->modes & ADJ_OFFSET_READONLY) &&
563     !capable(CAP_SYS_TIME))
564     return -EPERM;
565     + if (!(txc->modes & ADJ_OFFSET_READONLY) &&
566     + !ccs_capable(CCS_SYS_SETTIME))
567     + return -EPERM;
568     } else {
569     /* In order to modify anything, you gotta be super-user! */
570     if (txc->modes && !capable(CAP_SYS_TIME))
571     return -EPERM;
572     + if (txc->modes && !ccs_capable(CCS_SYS_SETTIME))
573     + return -EPERM;
574     /*
575     * if the quartz is off by more than 10% then
576     * something is VERY wrong!
577 kumaneko 284 @@ -680,6 +686,8 @@ int ntp_validate_timex(struct timex *txc
578 kumaneko 198 /* In order to inject time, you gotta be super-user! */
579     if (!capable(CAP_SYS_TIME))
580     return -EPERM;
581     + if (!ccs_capable(CCS_SYS_SETTIME))
582     + return -EPERM;
583 kumaneko 175
584 kumaneko 198 if (txc->modes & ADJ_NANO) {
585     struct timespec ts;
586 kumaneko 363 --- linux-4.4.302.orig/net/ipv4/raw.c
587     +++ linux-4.4.302/net/ipv4/raw.c
588     @@ -752,6 +752,10 @@ static int raw_recvmsg(struct sock *sk,
589 kumaneko 175 skb = skb_recv_datagram(sk, flags, noblock, &err);
590     if (!skb)
591     goto out;
592     + if (ccs_socket_post_recvmsg_permission(sk, skb, flags)) {
593     + err = -EAGAIN; /* Hope less harmful than -EPERM. */
594     + goto out;
595     + }
596    
597     copied = skb->len;
598     if (len < copied) {
599 kumaneko 363 --- linux-4.4.302.orig/net/ipv4/udp.c
600     +++ linux-4.4.302/net/ipv4/udp.c
601 kumaneko 266 @@ -1289,6 +1289,10 @@ try_again:
602 kumaneko 175 &peeked, &off, &err);
603     if (!skb)
604     goto out;
605     + if (ccs_socket_post_recvmsg_permission(sk, skb, flags)) {
606     + err = -EAGAIN; /* Hope less harmful than -EPERM. */
607     + goto out;
608     + }
609    
610     ulen = skb->len - sizeof(struct udphdr);
611     copied = len;
612 kumaneko 363 --- linux-4.4.302.orig/net/ipv6/raw.c
613     +++ linux-4.4.302/net/ipv6/raw.c
614 kumaneko 279 @@ -480,6 +480,10 @@ static int rawv6_recvmsg(struct sock *sk
615 kumaneko 175 skb = skb_recv_datagram(sk, flags, noblock, &err);
616     if (!skb)
617     goto out;
618     + if (ccs_socket_post_recvmsg_permission(sk, skb, flags)) {
619     + err = -EAGAIN; /* Hope less harmful than -EPERM. */
620     + goto out;
621     + }
622    
623     copied = skb->len;
624     if (copied > len) {
625 kumaneko 363 --- linux-4.4.302.orig/net/ipv6/udp.c
626     +++ linux-4.4.302/net/ipv6/udp.c
627 kumaneko 198 @@ -417,6 +417,10 @@ try_again:
628 kumaneko 175 &peeked, &off, &err);
629     if (!skb)
630     goto out;
631     + if (ccs_socket_post_recvmsg_permission(sk, skb, flags)) {
632     + err = -EAGAIN; /* Hope less harmful than -EPERM. */
633     + goto out;
634     + }
635    
636     ulen = skb->len - sizeof(struct udphdr);
637     copied = len;
638 kumaneko 363 --- linux-4.4.302.orig/net/socket.c
639     +++ linux-4.4.302/net/socket.c
640 kumaneko 278 @@ -1465,6 +1465,10 @@ SYSCALL_DEFINE4(accept4, int, fd, struct
641 kumaneko 175 if (err < 0)
642     goto out_fd;
643    
644     + if (ccs_socket_post_accept_permission(sock, newsock)) {
645     + err = -EAGAIN; /* Hope less harmful than -EPERM. */
646     + goto out_fd;
647     + }
648     if (upeer_sockaddr) {
649     if (newsock->ops->getname(newsock, (struct sockaddr *)&address,
650     &len, 2) < 0) {
651 kumaneko 363 --- linux-4.4.302.orig/net/unix/af_unix.c
652     +++ linux-4.4.302/net/unix/af_unix.c
653 kumaneko 361 @@ -2158,6 +2158,10 @@ static int unix_dgram_recvmsg(struct soc
654 kumaneko 175 wake_up_interruptible_sync_poll(&u->peer_wait,
655     POLLOUT | POLLWRNORM | POLLWRBAND);
656    
657     + if (ccs_socket_post_recvmsg_permission(sk, skb, flags)) {
658     + err = -EAGAIN; /* Hope less harmful than -EPERM. */
659     + goto out_unlock;
660     + }
661     if (msg->msg_name)
662     unix_copy_addr(msg, skb->sk);
663    
664 kumaneko 363 --- linux-4.4.302.orig/security/Kconfig
665     +++ linux-4.4.302/security/Kconfig
666 kumaneko 255 @@ -173,5 +173,7 @@ config DEFAULT_SECURITY
667 kumaneko 175 default "apparmor" if DEFAULT_SECURITY_APPARMOR
668     default "" if DEFAULT_SECURITY_DAC
669    
670     +source security/ccsecurity/Kconfig
671     +
672     endmenu
673    
674 kumaneko 363 --- linux-4.4.302.orig/security/Makefile
675     +++ linux-4.4.302/security/Makefile
676 kumaneko 175 @@ -27,3 +27,6 @@ obj-$(CONFIG_CGROUP_DEVICE) += device_c
677     # Object integrity file lists
678     subdir-$(CONFIG_INTEGRITY) += integrity
679     obj-$(CONFIG_INTEGRITY) += integrity/
680     +
681     +subdir-$(CONFIG_CCSECURITY) += ccsecurity
682     +obj-$(CONFIG_CCSECURITY) += ccsecurity/

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