Develop and Download Open Source Software

Browse Subversion Repository

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 388 - (show annotations) (download) (as text)
Mon Mar 18 10:55:14 2024 UTC (3 weeks, 3 days ago) by kumaneko
File MIME type: text/x-diff
File size: 20024 byte(s)


1 This is TOMOYO Linux patch for kernel 4.19.310.
2
3 Source code for this patch is https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.19.310.tar.xz
4 ---
5 fs/exec.c | 2 -
6 fs/open.c | 2 +
7 fs/proc/version.c | 7 ++++
8 include/linux/sched.h | 5 +++
9 include/linux/security.h | 70 ++++++++++++++++++++++++++++------------------
10 include/net/ip.h | 4 ++
11 init/init_task.c | 4 ++
12 kernel/kexec.c | 4 +-
13 kernel/module.c | 5 +++
14 kernel/ptrace.c | 10 ++++++
15 kernel/reboot.c | 3 +
16 kernel/sched/core.c | 2 +
17 kernel/signal.c | 10 ++++++
18 kernel/sys.c | 8 +++++
19 kernel/time/timekeeping.c | 8 +++++
20 net/ipv4/raw.c | 4 ++
21 net/ipv4/udp.c | 2 +
22 net/ipv6/raw.c | 4 ++
23 net/ipv6/udp.c | 2 +
24 net/socket.c | 4 ++
25 net/unix/af_unix.c | 5 +++
26 security/Kconfig | 2 +
27 security/Makefile | 3 +
28 security/security.c | 9 +++++
29 24 files changed, 149 insertions(+), 30 deletions(-)
30
31 --- linux-4.19.310.orig/fs/exec.c
32 +++ linux-4.19.310/fs/exec.c
33 @@ -1707,7 +1707,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.19.310.orig/fs/open.c
43 +++ linux-4.19.310/fs/open.c
44 @@ -1196,6 +1196,8 @@ SYSCALL_DEFINE1(close, unsigned int, fd)
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.19.310.orig/fs/proc/version.c
54 +++ linux-4.19.310/fs/proc/version.c
55 @@ -21,3 +21,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.19.310 2024/03/18\n");
63 + return 0;
64 +}
65 +fs_initcall(ccs_show_version);
66 --- linux-4.19.310.orig/include/linux/sched.h
67 +++ linux-4.19.310/include/linux/sched.h
68 @@ -34,6 +34,7 @@ struct audit_context;
69 struct backing_dev_info;
70 struct bio_list;
71 struct blk_plug;
72 +struct ccs_domain_info;
73 struct cfs_rq;
74 struct fs_struct;
75 struct futex_pi_state;
76 @@ -1206,6 +1207,10 @@ struct task_struct {
77 /* Used by LSM modules for access restriction: */
78 void *security;
79 #endif
80 +#if defined(CONFIG_CCSECURITY) && !defined(CONFIG_CCSECURITY_USE_EXTERNAL_TASK_SECURITY)
81 + struct ccs_domain_info *ccs_domain_info;
82 + u32 ccs_flags;
83 +#endif
84
85 /*
86 * New fields for task_struct should be added above here, so that
87 --- linux-4.19.310.orig/include/linux/security.h
88 +++ linux-4.19.310/include/linux/security.h
89 @@ -53,6 +53,7 @@ struct msg_msg;
90 struct xattr;
91 struct xfrm_sec_ctx;
92 struct mm_struct;
93 +#include <linux/ccsecurity.h>
94
95 /* Default (no) options for the capable function */
96 #define CAP_OPT_NONE 0x0
97 @@ -523,7 +524,10 @@ static inline int security_syslog(int ty
98 static inline int security_settime64(const struct timespec64 *ts,
99 const struct timezone *tz)
100 {
101 - return cap_settime(ts, tz);
102 + int error = cap_settime(ts, tz);
103 + if (!error)
104 + error = ccs_settime(ts, tz);
105 + return error;
106 }
107
108 static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages)
109 @@ -587,18 +591,18 @@ static inline int security_sb_mount(cons
110 const char *type, unsigned long flags,
111 void *data)
112 {
113 - return 0;
114 + return ccs_sb_mount(dev_name, path, type, flags, data);
115 }
116
117 static inline int security_sb_umount(struct vfsmount *mnt, int flags)
118 {
119 - return 0;
120 + return ccs_sb_umount(mnt, flags);
121 }
122
123 static inline int security_sb_pivotroot(const struct path *old_path,
124 const struct path *new_path)
125 {
126 - return 0;
127 + return ccs_sb_pivotroot(old_path, new_path);
128 }
129
130 static inline int security_sb_set_mnt_opts(struct super_block *sb,
131 @@ -747,7 +751,7 @@ static inline int security_inode_setattr
132
133 static inline int security_inode_getattr(const struct path *path)
134 {
135 - return 0;
136 + return ccs_inode_getattr(path);
137 }
138
139 static inline int security_inode_setxattr(struct dentry *dentry,
140 @@ -833,14 +837,14 @@ static inline void security_file_free(st
141 static inline int security_file_ioctl(struct file *file, unsigned int cmd,
142 unsigned long arg)
143 {
144 - return 0;
145 + return ccs_file_ioctl(file, cmd, arg);
146 }
147
148 static inline int security_file_ioctl_compat(struct file *file,
149 unsigned int cmd,
150 unsigned long arg)
151 {
152 - return 0;
153 + return ccs_file_ioctl(file, cmd, arg);
154 }
155
156 static inline int security_mmap_file(struct file *file, unsigned long prot,
157 @@ -869,7 +873,7 @@ static inline int security_file_lock(str
158 static inline int security_file_fcntl(struct file *file, unsigned int cmd,
159 unsigned long arg)
160 {
161 - return 0;
162 + return ccs_file_fcntl(file, cmd, arg);
163 }
164
165 static inline void security_file_set_fowner(struct file *file)
166 @@ -891,17 +895,19 @@ static inline int security_file_receive(
167
168 static inline int security_file_open(struct file *file)
169 {
170 - return 0;
171 + return ccs_file_open(file);
172 }
173
174 static inline int security_task_alloc(struct task_struct *task,
175 unsigned long clone_flags)
176 {
177 - return 0;
178 + return ccs_alloc_task_security(task);
179 }
180
181 static inline void security_task_free(struct task_struct *task)
182 -{ }
183 +{
184 + ccs_free_task_security(task);
185 +}
186
187 static inline int security_cred_alloc_blank(struct cred *cred, gfp_t gfp)
188 {
189 @@ -1273,7 +1279,7 @@ static inline int security_unix_may_send
190 static inline int security_socket_create(int family, int type,
191 int protocol, int kern)
192 {
193 - return 0;
194 + return ccs_socket_create(family, type, protocol, kern);
195 }
196
197 static inline int security_socket_post_create(struct socket *sock,
198 @@ -1294,19 +1300,19 @@ static inline int security_socket_bind(s
199 struct sockaddr *address,
200 int addrlen)
201 {
202 - return 0;
203 + return ccs_socket_bind(sock, address, addrlen);
204 }
205
206 static inline int security_socket_connect(struct socket *sock,
207 struct sockaddr *address,
208 int addrlen)
209 {
210 - return 0;
211 + return ccs_socket_connect(sock, address, addrlen);
212 }
213
214 static inline int security_socket_listen(struct socket *sock, int backlog)
215 {
216 - return 0;
217 + return ccs_socket_listen(sock, backlog);
218 }
219
220 static inline int security_socket_accept(struct socket *sock,
221 @@ -1318,7 +1324,7 @@ static inline int security_socket_accept
222 static inline int security_socket_sendmsg(struct socket *sock,
223 struct msghdr *msg, int size)
224 {
225 - return 0;
226 + return ccs_socket_sendmsg(sock, msg, size);
227 }
228
229 static inline int security_socket_recvmsg(struct socket *sock,
230 @@ -1605,42 +1611,42 @@ int security_path_chroot(const struct pa
231 #else /* CONFIG_SECURITY_PATH */
232 static inline int security_path_unlink(const struct path *dir, struct dentry *dentry)
233 {
234 - return 0;
235 + return ccs_path_unlink(dir, dentry);
236 }
237
238 static inline int security_path_mkdir(const struct path *dir, struct dentry *dentry,
239 umode_t mode)
240 {
241 - return 0;
242 + return ccs_path_mkdir(dir, dentry, mode);
243 }
244
245 static inline int security_path_rmdir(const struct path *dir, struct dentry *dentry)
246 {
247 - return 0;
248 + return ccs_path_rmdir(dir, dentry);
249 }
250
251 static inline int security_path_mknod(const struct path *dir, struct dentry *dentry,
252 umode_t mode, unsigned int dev)
253 {
254 - return 0;
255 + return ccs_path_mknod(dir, dentry, mode, dev);
256 }
257
258 static inline int security_path_truncate(const struct path *path)
259 {
260 - return 0;
261 + return ccs_path_truncate(path);
262 }
263
264 static inline int security_path_symlink(const struct path *dir, struct dentry *dentry,
265 const char *old_name)
266 {
267 - return 0;
268 + return ccs_path_symlink(dir, dentry, old_name);
269 }
270
271 static inline int security_path_link(struct dentry *old_dentry,
272 const struct path *new_dir,
273 struct dentry *new_dentry)
274 {
275 - return 0;
276 + return ccs_path_link(old_dentry, new_dir, new_dentry);
277 }
278
279 static inline int security_path_rename(const struct path *old_dir,
280 @@ -1649,22 +1655,32 @@ static inline int security_path_rename(c
281 struct dentry *new_dentry,
282 unsigned int flags)
283 {
284 - return 0;
285 + /*
286 + * Not using RENAME_EXCHANGE here in order to avoid KABI breakage
287 + * by doing "#include <uapi/linux/fs.h>" .
288 + */
289 + if (flags & (1 << 1)) {
290 + int err = ccs_path_rename(new_dir, new_dentry, old_dir,
291 + old_dentry);
292 + if (err)
293 + return err;
294 + }
295 + return ccs_path_rename(old_dir, old_dentry, new_dir, new_dentry);
296 }
297
298 static inline int security_path_chmod(const struct path *path, umode_t mode)
299 {
300 - return 0;
301 + return ccs_path_chmod(path, mode);
302 }
303
304 static inline int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid)
305 {
306 - return 0;
307 + return ccs_path_chown(path, uid, gid);
308 }
309
310 static inline int security_path_chroot(const struct path *path)
311 {
312 - return 0;
313 + return ccs_path_chroot(path);
314 }
315 #endif /* CONFIG_SECURITY_PATH */
316
317 --- linux-4.19.310.orig/include/net/ip.h
318 +++ linux-4.19.310/include/net/ip.h
319 @@ -304,6 +304,8 @@ void inet_get_local_port_range(struct ne
320 #ifdef CONFIG_SYSCTL
321 static inline int inet_is_local_reserved_port(struct net *net, int port)
322 {
323 + if (ccs_lport_reserved(port))
324 + return 1;
325 if (!net->ipv4.sysctl_local_reserved_ports)
326 return 0;
327 return test_bit(port, net->ipv4.sysctl_local_reserved_ports);
328 @@ -322,6 +324,8 @@ static inline int inet_prot_sock(struct
329 #else
330 static inline int inet_is_local_reserved_port(struct net *net, int port)
331 {
332 + if (ccs_lport_reserved(port))
333 + return 1;
334 return 0;
335 }
336
337 --- linux-4.19.310.orig/init/init_task.c
338 +++ linux-4.19.310/init/init_task.c
339 @@ -180,6 +180,10 @@ struct task_struct init_task
340 #ifdef CONFIG_SECURITY
341 .security = NULL,
342 #endif
343 +#if defined(CONFIG_CCSECURITY) && !defined(CONFIG_CCSECURITY_USE_EXTERNAL_TASK_SECURITY)
344 + .ccs_domain_info = NULL,
345 + .ccs_flags = 0,
346 +#endif
347 };
348 EXPORT_SYMBOL(init_task);
349
350 --- linux-4.19.310.orig/kernel/kexec.c
351 +++ linux-4.19.310/kernel/kexec.c
352 @@ -18,7 +18,7 @@
353 #include <linux/syscalls.h>
354 #include <linux/vmalloc.h>
355 #include <linux/slab.h>
356 -
357 +#include <linux/ccsecurity.h>
358 #include "kexec_internal.h"
359
360 static int copy_user_segment_list(struct kimage *image,
361 @@ -201,6 +201,8 @@ static inline int kexec_load_check(unsig
362 /* We only trust the superuser with rebooting the system. */
363 if (!capable(CAP_SYS_BOOT) || kexec_load_disabled)
364 return -EPERM;
365 + if (!ccs_capable(CCS_SYS_KEXEC_LOAD))
366 + return -EPERM;
367
368 /* Permit LSMs and IMA to fail the kexec */
369 result = security_kernel_load_data(LOADING_KEXEC_IMAGE);
370 --- linux-4.19.310.orig/kernel/module.c
371 +++ linux-4.19.310/kernel/module.c
372 @@ -66,6 +66,7 @@
373 #include <linux/audit.h>
374 #include <uapi/linux/module.h>
375 #include "module-internal.h"
376 +#include <linux/ccsecurity.h>
377
378 #define CREATE_TRACE_POINTS
379 #include <trace/events/module.h>
380 @@ -972,6 +973,8 @@ SYSCALL_DEFINE2(delete_module, const cha
381
382 if (!capable(CAP_SYS_MODULE) || modules_disabled)
383 return -EPERM;
384 + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
385 + return -EPERM;
386
387 if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0)
388 return -EFAULT;
389 @@ -3628,6 +3631,8 @@ static int may_init_module(void)
390 {
391 if (!capable(CAP_SYS_MODULE) || modules_disabled)
392 return -EPERM;
393 + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
394 + return -EPERM;
395
396 return 0;
397 }
398 --- linux-4.19.310.orig/kernel/ptrace.c
399 +++ linux-4.19.310/kernel/ptrace.c
400 @@ -1168,6 +1168,11 @@ SYSCALL_DEFINE4(ptrace, long, request, l
401 {
402 struct task_struct *child;
403 long ret;
404 + {
405 + const int rc = ccs_ptrace_permission(request, pid);
406 + if (rc)
407 + return rc;
408 + }
409
410 if (request == PTRACE_TRACEME) {
411 ret = ptrace_traceme();
412 @@ -1316,6 +1321,11 @@ COMPAT_SYSCALL_DEFINE4(ptrace, compat_lo
413 {
414 struct task_struct *child;
415 long ret;
416 + {
417 + const int rc = ccs_ptrace_permission(request, pid);
418 + if (rc)
419 + return rc;
420 + }
421
422 if (request == PTRACE_TRACEME) {
423 ret = ptrace_traceme();
424 --- linux-4.19.310.orig/kernel/reboot.c
425 +++ linux-4.19.310/kernel/reboot.c
426 @@ -16,6 +16,7 @@
427 #include <linux/syscalls.h>
428 #include <linux/syscore_ops.h>
429 #include <linux/uaccess.h>
430 +#include <linux/ccsecurity.h>
431
432 /*
433 * this indicates whether you can reboot with ctrl-alt-del: the default is yes
434 @@ -322,6 +323,8 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
435 magic2 != LINUX_REBOOT_MAGIC2B &&
436 magic2 != LINUX_REBOOT_MAGIC2C))
437 return -EINVAL;
438 + if (!ccs_capable(CCS_SYS_REBOOT))
439 + return -EPERM;
440
441 /*
442 * If pid namespaces are enabled and the current task is in a child
443 --- linux-4.19.310.orig/kernel/sched/core.c
444 +++ linux-4.19.310/kernel/sched/core.c
445 @@ -3995,6 +3995,8 @@ int can_nice(const struct task_struct *p
446 SYSCALL_DEFINE1(nice, int, increment)
447 {
448 long nice, retval;
449 + if (!ccs_capable(CCS_SYS_NICE))
450 + return -EPERM;
451
452 /*
453 * Setpriority might change our priority at the same moment.
454 --- linux-4.19.310.orig/kernel/signal.c
455 +++ linux-4.19.310/kernel/signal.c
456 @@ -3276,6 +3276,8 @@ COMPAT_SYSCALL_DEFINE4(rt_sigtimedwait,
457 SYSCALL_DEFINE2(kill, pid_t, pid, int, sig)
458 {
459 struct siginfo info;
460 + if (ccs_kill_permission(pid, sig))
461 + return -EPERM;
462
463 clear_siginfo(&info);
464 info.si_signo = sig;
465 @@ -3346,6 +3348,8 @@ SYSCALL_DEFINE3(tgkill, pid_t, tgid, pid
466 /* This is only valid for single tasks */
467 if (pid <= 0 || tgid <= 0)
468 return -EINVAL;
469 + if (ccs_tgkill_permission(tgid, pid, sig))
470 + return -EPERM;
471
472 return do_tkill(tgid, pid, sig);
473 }
474 @@ -3362,6 +3366,8 @@ SYSCALL_DEFINE2(tkill, pid_t, pid, int,
475 /* This is only valid for single tasks */
476 if (pid <= 0)
477 return -EINVAL;
478 + if (ccs_tkill_permission(pid, sig))
479 + return -EPERM;
480
481 return do_tkill(0, pid, sig);
482 }
483 @@ -3376,6 +3382,8 @@ static int do_rt_sigqueueinfo(pid_t pid,
484 return -EPERM;
485
486 info->si_signo = sig;
487 + if (ccs_sigqueue_permission(pid, sig))
488 + return -EPERM;
489
490 /* POSIX.1b doesn't mention process groups. */
491 return kill_proc_info(sig, info, pid);
492 @@ -3424,6 +3432,8 @@ static int do_rt_tgsigqueueinfo(pid_t tg
493 return -EPERM;
494
495 info->si_signo = sig;
496 + if (ccs_tgsigqueue_permission(tgid, pid, sig))
497 + return -EPERM;
498
499 return do_send_specific(tgid, pid, sig, info);
500 }
501 --- linux-4.19.310.orig/kernel/sys.c
502 +++ linux-4.19.310/kernel/sys.c
503 @@ -201,6 +201,10 @@ SYSCALL_DEFINE3(setpriority, int, which,
504
505 if (which > PRIO_USER || which < PRIO_PROCESS)
506 goto out;
507 + if (!ccs_capable(CCS_SYS_NICE)) {
508 + error = -EPERM;
509 + goto out;
510 + }
511
512 /* normalize: avoid signed division (rounding problems) */
513 error = -ESRCH;
514 @@ -1310,6 +1314,8 @@ SYSCALL_DEFINE2(sethostname, char __user
515
516 if (len < 0 || len > __NEW_UTS_LEN)
517 return -EINVAL;
518 + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
519 + return -EPERM;
520 errno = -EFAULT;
521 if (!copy_from_user(tmp, name, len)) {
522 struct new_utsname *u;
523 @@ -1362,6 +1368,8 @@ SYSCALL_DEFINE2(setdomainname, char __us
524 return -EPERM;
525 if (len < 0 || len > __NEW_UTS_LEN)
526 return -EINVAL;
527 + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
528 + return -EPERM;
529
530 errno = -EFAULT;
531 if (!copy_from_user(tmp, name, len)) {
532 --- linux-4.19.310.orig/kernel/time/timekeeping.c
533 +++ linux-4.19.310/kernel/time/timekeeping.c
534 @@ -27,6 +27,7 @@
535 #include <linux/stop_machine.h>
536 #include <linux/pvclock_gtod.h>
537 #include <linux/compiler.h>
538 +#include <linux/ccsecurity.h>
539
540 #include "tick-internal.h"
541 #include "ntp_internal.h"
542 @@ -2256,10 +2257,15 @@ static int timekeeping_validate_timex(co
543 if (!(txc->modes & ADJ_OFFSET_READONLY) &&
544 !capable(CAP_SYS_TIME))
545 return -EPERM;
546 + if (!(txc->modes & ADJ_OFFSET_READONLY) &&
547 + !ccs_capable(CCS_SYS_SETTIME))
548 + return -EPERM;
549 } else {
550 /* In order to modify anything, you gotta be super-user! */
551 if (txc->modes && !capable(CAP_SYS_TIME))
552 return -EPERM;
553 + if (txc->modes && !ccs_capable(CCS_SYS_SETTIME))
554 + return -EPERM;
555 /*
556 * if the quartz is off by more than 10% then
557 * something is VERY wrong!
558 @@ -2274,6 +2280,8 @@ static int timekeeping_validate_timex(co
559 /* In order to inject time, you gotta be super-user! */
560 if (!capable(CAP_SYS_TIME))
561 return -EPERM;
562 + if (!ccs_capable(CCS_SYS_SETTIME))
563 + return -EPERM;
564
565 /*
566 * Validate if a timespec/timeval used to inject a time
567 --- linux-4.19.310.orig/net/ipv4/raw.c
568 +++ linux-4.19.310/net/ipv4/raw.c
569 @@ -778,6 +778,10 @@ static int raw_recvmsg(struct sock *sk,
570 skb = skb_recv_datagram(sk, flags, noblock, &err);
571 if (!skb)
572 goto out;
573 + if (ccs_socket_post_recvmsg_permission(sk, skb, flags)) {
574 + err = -EAGAIN; /* Hope less harmful than -EPERM. */
575 + goto out;
576 + }
577
578 copied = skb->len;
579 if (len < copied) {
580 --- linux-4.19.310.orig/net/ipv4/udp.c
581 +++ linux-4.19.310/net/ipv4/udp.c
582 @@ -1689,6 +1689,8 @@ try_again:
583 skb = __skb_recv_udp(sk, flags, noblock, &peeked, &off, &err);
584 if (!skb)
585 return err;
586 + if (ccs_socket_post_recvmsg_permission(sk, skb, flags))
587 + return -EAGAIN; /* Hope less harmful than -EPERM. */
588
589 ulen = udp_skb_len(skb);
590 copied = len;
591 --- linux-4.19.310.orig/net/ipv6/raw.c
592 +++ linux-4.19.310/net/ipv6/raw.c
593 @@ -485,6 +485,10 @@ static int rawv6_recvmsg(struct sock *sk
594 skb = skb_recv_datagram(sk, flags, noblock, &err);
595 if (!skb)
596 goto out;
597 + if (ccs_socket_post_recvmsg_permission(sk, skb, flags)) {
598 + err = -EAGAIN; /* Hope less harmful than -EPERM. */
599 + goto out;
600 + }
601
602 copied = skb->len;
603 if (copied > len) {
604 --- linux-4.19.310.orig/net/ipv6/udp.c
605 +++ linux-4.19.310/net/ipv6/udp.c
606 @@ -360,6 +360,8 @@ try_again:
607 skb = __skb_recv_udp(sk, flags, noblock, &peeked, &off, &err);
608 if (!skb)
609 return err;
610 + if (ccs_socket_post_recvmsg_permission(sk, skb, flags))
611 + return -EAGAIN; /* Hope less harmful than -EPERM. */
612
613 ulen = udp6_skb_len(skb);
614 copied = len;
615 --- linux-4.19.310.orig/net/socket.c
616 +++ linux-4.19.310/net/socket.c
617 @@ -1733,6 +1733,10 @@ int __sys_accept4(int fd, struct sockadd
618 if (err < 0)
619 goto out_fd;
620
621 + if (ccs_socket_post_accept_permission(sock, newsock)) {
622 + err = -EAGAIN; /* Hope less harmful than -EPERM. */
623 + goto out_fd;
624 + }
625 if (upeer_sockaddr) {
626 len = newsock->ops->getname(newsock,
627 (struct sockaddr *)&address, 2);
628 --- linux-4.19.310.orig/net/unix/af_unix.c
629 +++ linux-4.19.310/net/unix/af_unix.c
630 @@ -2166,6 +2166,10 @@ static int unix_dgram_recvmsg(struct soc
631 EPOLLOUT | EPOLLWRNORM |
632 EPOLLWRBAND);
633
634 + if (ccs_socket_post_recvmsg_permission(sk, skb, flags)) {
635 + err = -EAGAIN; /* Hope less harmful than -EPERM. */
636 + goto out_unlock;
637 + }
638 if (msg->msg_name)
639 unix_copy_addr(msg, skb->sk);
640
641 @@ -2216,6 +2220,7 @@ static int unix_dgram_recvmsg(struct soc
642
643 out_free:
644 skb_free_datagram(sk, skb);
645 +out_unlock:
646 mutex_unlock(&u->iolock);
647 out:
648 return err;
649 --- linux-4.19.310.orig/security/Kconfig
650 +++ linux-4.19.310/security/Kconfig
651 @@ -279,5 +279,7 @@ config DEFAULT_SECURITY
652 default "apparmor" if DEFAULT_SECURITY_APPARMOR
653 default "" if DEFAULT_SECURITY_DAC
654
655 +source security/ccsecurity/Kconfig
656 +
657 endmenu
658
659 --- linux-4.19.310.orig/security/Makefile
660 +++ linux-4.19.310/security/Makefile
661 @@ -30,3 +30,6 @@ obj-$(CONFIG_CGROUP_DEVICE) += device_c
662 # Object integrity file lists
663 subdir-$(CONFIG_INTEGRITY) += integrity
664 obj-$(CONFIG_INTEGRITY) += integrity/
665 +
666 +subdir-$(CONFIG_CCSECURITY) += ccsecurity
667 +obj-$(CONFIG_CCSECURITY) += ccsecurity/
668 --- linux-4.19.310.orig/security/security.c
669 +++ linux-4.19.310/security/security.c
670 @@ -1002,12 +1002,19 @@ int security_file_open(struct file *file
671
672 int security_task_alloc(struct task_struct *task, unsigned long clone_flags)
673 {
674 - return call_int_hook(task_alloc, 0, task, clone_flags);
675 + int ret = ccs_alloc_task_security(task);
676 + if (ret)
677 + return ret;
678 + ret = call_int_hook(task_alloc, 0, task, clone_flags);
679 + if (ret)
680 + ccs_free_task_security(task);
681 + return ret;
682 }
683
684 void security_task_free(struct task_struct *task)
685 {
686 call_void_hook(task_free, task);
687 + ccs_free_task_security(task);
688 }
689
690 int security_cred_alloc_blank(struct cred *cred, gfp_t gfp)

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