Develop and Download Open Source Software

Browse Subversion Repository

Contents of /trunk/caitsith-patch/patches/ccs-patch-4.9.diff

Parent Directory Parent Directory | Revision Log Revision Log


Revision 267 - (show annotations) (download) (as text)
Mon Aug 27 10:15:55 2018 UTC (5 years, 7 months ago) by kumaneko
File MIME type: text/x-diff
File size: 19811 byte(s)


1 This is TOMOYO Linux patch for kernel 4.9.124.
2
3 Source code for this patch is https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.9.124.tar.xz
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 | 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 | 2 +
23 net/ipv6/raw.c | 4 ++
24 net/ipv6/udp.c | 2 +
25 net/socket.c | 4 ++
26 net/unix/af_unix.c | 5 +++
27 security/Kconfig | 2 +
28 security/Makefile | 3 ++
29 24 files changed, 147 insertions(+), 26 deletions(-)
30
31 --- linux-4.9.124.orig/fs/exec.c
32 +++ linux-4.9.124/fs/exec.c
33 @@ -1660,7 +1660,7 @@ static int exec_binprm(struct linux_binp
34 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 --- linux-4.9.124.orig/fs/open.c
43 +++ linux-4.9.124/fs/open.c
44 @@ -1151,6 +1151,8 @@ EXPORT_SYMBOL(sys_close);
45 */
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 --- linux-4.9.124.orig/fs/proc/version.c
54 +++ linux-4.9.124/fs/proc/version.c
55 @@ -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 + printk(KERN_INFO "Hook version: 4.9.124 2018/08/25\n");
63 + return 0;
64 +}
65 +fs_initcall(ccs_show_version);
66 --- linux-4.9.124.orig/include/linux/init_task.h
67 +++ linux-4.9.124/include/linux/init_task.h
68 @@ -193,6 +193,14 @@ extern struct task_group root_task_group
69 # define INIT_TASK_TI(tsk)
70 #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 @@ -271,6 +279,7 @@ extern struct task_group root_task_group
84 INIT_VTIME(tsk) \
85 INIT_NUMA_BALANCING(tsk) \
86 INIT_KASAN(tsk) \
87 + INIT_CCSECURITY \
88 }
89
90
91 --- linux-4.9.124.orig/include/linux/sched.h
92 +++ linux-4.9.124/include/linux/sched.h
93 @@ -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 @@ -1971,6 +1973,10 @@ struct task_struct {
103 /* A live task holds one reference. */
104 atomic_t stack_refcount;
105 #endif
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 --- linux-4.9.124.orig/include/linux/security.h
114 +++ linux-4.9.124/include/linux/security.h
115 @@ -55,6 +55,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 @@ -476,7 +477,10 @@ static inline int security_syslog(int ty
124 static inline int security_settime64(const struct timespec64 *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_settime(const struct timespec *ts,
135 @@ -553,18 +557,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(const struct path *old_path,
150 const 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 @@ -711,7 +715,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 @@ -797,7 +801,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 @@ -826,7 +830,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 @@ -849,7 +853,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 @@ -1217,7 +1221,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 @@ -1232,19 +1236,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 @@ -1256,7 +1260,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 @@ -1498,42 +1502,42 @@ int security_path_chroot(const struct pa
235 #else /* CONFIG_SECURITY_PATH */
236 static inline int security_path_unlink(const 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(const 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(const 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(const 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(const struct path *path)
263 {
264 - return 0;
265 + return ccs_path_truncate(path);
266 }
267
268 static inline int security_path_symlink(const 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 const 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(const struct path *old_dir,
284 @@ -1542,22 +1546,32 @@ static inline int security_path_rename(c
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(const 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(const 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(const struct path *path)
315 {
316 - return 0;
317 + return ccs_path_chroot(path);
318 }
319 #endif /* CONFIG_SECURITY_PATH */
320
321 --- linux-4.9.124.orig/include/net/ip.h
322 +++ linux-4.9.124/include/net/ip.h
323 @@ -254,6 +254,8 @@ void inet_get_local_port_range(struct ne
324 #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 @@ -267,6 +269,8 @@ static inline bool sysctl_dev_name_is_al
333 #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 --- linux-4.9.124.orig/kernel/fork.c
342 +++ linux-4.9.124/kernel/fork.c
343 @@ -395,6 +395,7 @@ void __put_task_struct(struct task_struc
344 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 @@ -1655,6 +1656,9 @@ static __latent_entropy struct task_stru
352 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 @@ -1878,6 +1882,7 @@ bad_fork_cleanup_semundo:
362 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 --- linux-4.9.124.orig/kernel/kexec.c
370 +++ linux-4.9.124/kernel/kexec.c
371 @@ -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 @@ -192,6 +192,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 --- linux-4.9.124.orig/kernel/module.c
390 +++ linux-4.9.124/kernel/module.c
391 @@ -63,6 +63,7 @@
392 #include <linux/dynamic_debug.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 @@ -937,6 +938,8 @@ SYSCALL_DEFINE2(delete_module, const cha
400
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 @@ -3495,6 +3498,8 @@ static int may_init_module(void)
409 {
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 --- linux-4.9.124.orig/kernel/ptrace.c
418 +++ linux-4.9.124/kernel/ptrace.c
419 @@ -1122,6 +1122,11 @@ SYSCALL_DEFINE4(ptrace, long, request, l
420 {
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 @@ -1271,6 +1276,11 @@ COMPAT_SYSCALL_DEFINE4(ptrace, compat_lo
432 {
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 --- linux-4.9.124.orig/kernel/reboot.c
444 +++ linux-4.9.124/kernel/reboot.c
445 @@ -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 --- linux-4.9.124.orig/kernel/sched/core.c
463 +++ linux-4.9.124/kernel/sched/core.c
464 @@ -3813,6 +3813,8 @@ int can_nice(const struct task_struct *p
465 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 --- linux-4.9.124.orig/kernel/signal.c
474 +++ linux-4.9.124/kernel/signal.c
475 @@ -2868,6 +2868,8 @@ SYSCALL_DEFINE4(rt_sigtimedwait, const s
476 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 @@ -2936,6 +2938,8 @@ SYSCALL_DEFINE3(tgkill, pid_t, tgid, pid
485 /* 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 @@ -2952,6 +2956,8 @@ SYSCALL_DEFINE2(tkill, pid_t, pid, int,
494 /* 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 @@ -2966,6 +2972,8 @@ static int do_rt_sigqueueinfo(pid_t pid,
503 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 @@ -3014,6 +3022,8 @@ static int do_rt_tgsigqueueinfo(pid_t tg
512 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 --- linux-4.9.124.orig/kernel/sys.c
521 +++ linux-4.9.124/kernel/sys.c
522 @@ -185,6 +185,10 @@ SYSCALL_DEFINE3(setpriority, int, which,
523
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 @@ -1224,6 +1228,8 @@ SYSCALL_DEFINE2(sethostname, char __user
534
535 if (len < 0 || len > __NEW_UTS_LEN)
536 return -EINVAL;
537 + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
538 + return -EPERM;
539 down_write(&uts_sem);
540 errno = -EFAULT;
541 if (!copy_from_user(tmp, name, len)) {
542 @@ -1274,6 +1280,8 @@ SYSCALL_DEFINE2(setdomainname, char __us
543 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 down_write(&uts_sem);
550 errno = -EFAULT;
551 --- linux-4.9.124.orig/kernel/time/ntp.c
552 +++ linux-4.9.124/kernel/time/ntp.c
553 @@ -17,6 +17,7 @@
554 #include <linux/module.h>
555 #include <linux/rtc.h>
556 #include <linux/math64.h>
557 +#include <linux/ccsecurity.h>
558
559 #include "ntp_internal.h"
560 #include "timekeeping_internal.h"
561 @@ -666,10 +667,15 @@ int ntp_validate_timex(struct timex *txc
562 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 @@ -684,6 +690,8 @@ int ntp_validate_timex(struct timex *txc
578 /* 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
584 if (txc->modes & ADJ_NANO) {
585 struct timespec ts;
586 --- linux-4.9.124.orig/net/ipv4/raw.c
587 +++ linux-4.9.124/net/ipv4/raw.c
588 @@ -744,6 +744,10 @@ static int raw_recvmsg(struct sock *sk,
589 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 --- linux-4.9.124.orig/net/ipv4/udp.c
600 +++ linux-4.9.124/net/ipv4/udp.c
601 @@ -1267,6 +1267,8 @@ try_again:
602 &peeked, &off, &err);
603 if (!skb)
604 return err;
605 + if (ccs_socket_post_recvmsg_permission(sk, skb, flags))
606 + return -EAGAIN; /* Hope less harmful than -EPERM. */
607
608 ulen = skb->len;
609 copied = len;
610 --- linux-4.9.124.orig/net/ipv6/raw.c
611 +++ linux-4.9.124/net/ipv6/raw.c
612 @@ -478,6 +478,10 @@ static int rawv6_recvmsg(struct sock *sk
613 skb = skb_recv_datagram(sk, flags, noblock, &err);
614 if (!skb)
615 goto out;
616 + if (ccs_socket_post_recvmsg_permission(sk, skb, flags)) {
617 + err = -EAGAIN; /* Hope less harmful than -EPERM. */
618 + goto out;
619 + }
620
621 copied = skb->len;
622 if (copied > len) {
623 --- linux-4.9.124.orig/net/ipv6/udp.c
624 +++ linux-4.9.124/net/ipv6/udp.c
625 @@ -348,6 +348,8 @@ try_again:
626 &peeked, &off, &err);
627 if (!skb)
628 return err;
629 + if (ccs_socket_post_recvmsg_permission(sk, skb, flags))
630 + return -EAGAIN; /* Hope less harmful than -EPERM. */
631
632 ulen = skb->len;
633 copied = len;
634 --- linux-4.9.124.orig/net/socket.c
635 +++ linux-4.9.124/net/socket.c
636 @@ -1482,6 +1482,10 @@ SYSCALL_DEFINE4(accept4, int, fd, struct
637 if (err < 0)
638 goto out_fd;
639
640 + if (ccs_socket_post_accept_permission(sock, newsock)) {
641 + err = -EAGAIN; /* Hope less harmful than -EPERM. */
642 + goto out_fd;
643 + }
644 if (upeer_sockaddr) {
645 if (newsock->ops->getname(newsock, (struct sockaddr *)&address,
646 &len, 2) < 0) {
647 --- linux-4.9.124.orig/net/unix/af_unix.c
648 +++ linux-4.9.124/net/unix/af_unix.c
649 @@ -2150,6 +2150,10 @@ static int unix_dgram_recvmsg(struct soc
650 POLLOUT | POLLWRNORM |
651 POLLWRBAND);
652
653 + if (ccs_socket_post_recvmsg_permission(sk, skb, flags)) {
654 + err = -EAGAIN; /* Hope less harmful than -EPERM. */
655 + goto out_unlock;
656 + }
657 if (msg->msg_name)
658 unix_copy_addr(msg, skb->sk);
659
660 @@ -2200,6 +2204,7 @@ static int unix_dgram_recvmsg(struct soc
661
662 out_free:
663 skb_free_datagram(sk, skb);
664 +out_unlock:
665 mutex_unlock(&u->iolock);
666 out:
667 return err;
668 --- linux-4.9.124.orig/security/Kconfig
669 +++ linux-4.9.124/security/Kconfig
670 @@ -214,5 +214,7 @@ config DEFAULT_SECURITY
671 default "apparmor" if DEFAULT_SECURITY_APPARMOR
672 default "" if DEFAULT_SECURITY_DAC
673
674 +source security/ccsecurity/Kconfig
675 +
676 endmenu
677
678 --- linux-4.9.124.orig/security/Makefile
679 +++ linux-4.9.124/security/Makefile
680 @@ -29,3 +29,6 @@ obj-$(CONFIG_CGROUP_DEVICE) += device_c
681 # Object integrity file lists
682 subdir-$(CONFIG_INTEGRITY) += integrity
683 obj-$(CONFIG_INTEGRITY) += integrity/
684 +
685 +subdir-$(CONFIG_CCSECURITY) += ccsecurity
686 +obj-$(CONFIG_CCSECURITY) += ccsecurity/

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