| 1 |
This is TOMOYO Linux patch for CentOS 7. |
| 2 |
|
| 3 |
Source code for this patch is http://vault.centos.org/centos/7/updates/Source/SPackages/kernel-3.10.0-862.11.6.el7.src.rpm |
| 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 | 65 ++++++++++++++++---------- |
| 11 |
include/net/ip.h | 2 |
| 12 |
kernel/fork.c | 5 ++ |
| 13 |
kernel/kexec.c | 2 |
| 14 |
kernel/module.c | 5 ++ |
| 15 |
kernel/ptrace.c | 10 ++++ |
| 16 |
kernel/sched/core.c | 2 |
| 17 |
kernel/signal.c | 10 ++++ |
| 18 |
kernel/sys.c | 10 ++++ |
| 19 |
kernel/time/ntp.c | 8 +++ |
| 20 |
net/ipv4/raw.c | 4 + |
| 21 |
net/ipv4/udp.c | 4 + |
| 22 |
net/ipv6/raw.c | 4 + |
| 23 |
net/ipv6/udp.c | 4 + |
| 24 |
net/socket.c | 4 + |
| 25 |
net/unix/af_unix.c | 4 + |
| 26 |
security/Kconfig | 2 |
| 27 |
security/Makefile | 3 + |
| 28 |
security/security.c | 111 +++++++++++++++++++++++++++++++++++++++++----- |
| 29 |
24 files changed, 248 insertions(+), 37 deletions(-) |
| 30 |
|
| 31 |
--- linux-3.10.0-862.11.6.el7.orig/fs/exec.c |
| 32 |
+++ linux-3.10.0-862.11.6.el7/fs/exec.c |
| 33 |
@@ -1592,7 +1592,7 @@ static int do_execve_common(struct filen |
| 34 |
if (retval < 0) |
| 35 |
goto out; |
| 36 |
|
| 37 |
- retval = search_binary_handler(bprm); |
| 38 |
+ retval = ccs_search_binary_handler(bprm); |
| 39 |
if (retval < 0) |
| 40 |
goto out; |
| 41 |
|
| 42 |
--- linux-3.10.0-862.11.6.el7.orig/fs/open.c |
| 43 |
+++ linux-3.10.0-862.11.6.el7/fs/open.c |
| 44 |
@@ -1142,6 +1142,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-3.10.0-862.11.6.el7.orig/fs/proc/version.c |
| 54 |
+++ linux-3.10.0-862.11.6.el7/fs/proc/version.c |
| 55 |
@@ -32,3 +32,10 @@ static int __init proc_version_init(void |
| 56 |
return 0; |
| 57 |
} |
| 58 |
module_init(proc_version_init); |
| 59 |
+ |
| 60 |
+static int __init ccs_show_version(void) |
| 61 |
+{ |
| 62 |
+ printk(KERN_INFO "Hook version: 3.10.0-862.11.6.el7 2018/08/25\n"); |
| 63 |
+ return 0; |
| 64 |
+} |
| 65 |
+module_init(ccs_show_version); |
| 66 |
--- linux-3.10.0-862.11.6.el7.orig/include/linux/init_task.h |
| 67 |
+++ linux-3.10.0-862.11.6.el7/include/linux/init_task.h |
| 68 |
@@ -173,6 +173,14 @@ extern struct task_group root_task_group |
| 69 |
# define INIT_RT_MUTEXES(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 |
@@ -244,6 +252,7 @@ extern struct task_group root_task_group |
| 84 |
INIT_RT_MUTEXES(tsk) \ |
| 85 |
INIT_PREV_CPUTIME(tsk) \ |
| 86 |
INIT_VTIME(tsk) \ |
| 87 |
+ INIT_CCSECURITY \ |
| 88 |
} |
| 89 |
|
| 90 |
|
| 91 |
--- linux-3.10.0-862.11.6.el7.orig/include/linux/sched.h |
| 92 |
+++ linux-3.10.0-862.11.6.el7/include/linux/sched.h |
| 93 |
@@ -4,6 +4,8 @@ |
| 94 |
#include <uapi/linux/sched.h> |
| 95 |
#include <linux/rh_kabi.h> |
| 96 |
|
| 97 |
+struct ccs_domain_info; |
| 98 |
+ |
| 99 |
struct sched_param { |
| 100 |
int sched_priority; |
| 101 |
}; |
| 102 |
@@ -1818,6 +1820,10 @@ struct task_struct { |
| 103 |
struct wake_q_node wake_q; |
| 104 |
struct prev_cputime prev_cputime; |
| 105 |
#endif /* __GENKSYMS__ */ |
| 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 |
}; |
| 111 |
|
| 112 |
/* Future-safe accessor for struct task_struct's cpus_allowed. */ |
| 113 |
--- linux-3.10.0-862.11.6.el7.orig/include/linux/security.h |
| 114 |
+++ linux-3.10.0-862.11.6.el7/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 |
/* Maximum number of letters for an LSM name string */ |
| 122 |
#define SECURITY_NAME_MAX 10 |
| 123 |
@@ -2060,7 +2061,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 && !ccs_capable(CCS_SYS_SETTIME)) |
| 130 |
+ error = -EPERM; |
| 131 |
+ return error; |
| 132 |
} |
| 133 |
|
| 134 |
static inline int security_vm_enough_memory_mm(struct mm_struct *mm, long pages) |
| 135 |
@@ -2129,18 +2133,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_mount_permission(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_umount_permission(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_pivot_root_permission(old_path, new_path); |
| 154 |
} |
| 155 |
|
| 156 |
static inline int security_sb_set_mnt_opts(struct super_block *sb, |
| 157 |
@@ -2289,7 +2293,7 @@ static inline int security_inode_setattr |
| 158 |
static inline int security_inode_getattr(struct vfsmount *mnt, |
| 159 |
struct dentry *dentry) |
| 160 |
{ |
| 161 |
- return 0; |
| 162 |
+ return ccs_getattr_permission(mnt, dentry); |
| 163 |
} |
| 164 |
|
| 165 |
static inline int security_inode_setxattr(struct dentry *dentry, |
| 166 |
@@ -2375,7 +2379,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_ioctl_permission(file, cmd, arg); |
| 172 |
} |
| 173 |
|
| 174 |
static inline int security_mmap_file(struct file *file, unsigned long prot, |
| 175 |
@@ -2404,7 +2408,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_fcntl_permission(file, cmd, arg); |
| 181 |
} |
| 182 |
|
| 183 |
static inline int security_file_set_fowner(struct file *file) |
| 184 |
@@ -2427,7 +2431,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_open_permission(file); |
| 190 |
} |
| 191 |
|
| 192 |
static inline int security_task_create(unsigned long clone_flags) |
| 193 |
@@ -2789,7 +2793,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_permission(family, type, protocol); |
| 199 |
} |
| 200 |
|
| 201 |
static inline int security_socket_post_create(struct socket *sock, |
| 202 |
@@ -2804,19 +2808,19 @@ static inline int security_socket_bind(s |
| 203 |
struct sockaddr *address, |
| 204 |
int addrlen) |
| 205 |
{ |
| 206 |
- return 0; |
| 207 |
+ return ccs_socket_bind_permission(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_permission(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_permission(sock); |
| 222 |
} |
| 223 |
|
| 224 |
static inline int security_socket_accept(struct socket *sock, |
| 225 |
@@ -2828,7 +2832,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_permission(sock, msg, size); |
| 231 |
} |
| 232 |
|
| 233 |
static inline int security_socket_recvmsg(struct socket *sock, |
| 234 |
@@ -3096,44 +3100,47 @@ int security_path_chmod(struct path *pat |
| 235 |
int security_path_chown(struct path *path, kuid_t uid, kgid_t gid); |
| 236 |
int security_path_chroot(struct path *path); |
| 237 |
#else /* CONFIG_SECURITY_PATH */ |
| 238 |
+ |
| 239 |
+#include <linux/path.h> |
| 240 |
+ |
| 241 |
static inline int security_path_unlink(struct path *dir, struct dentry *dentry) |
| 242 |
{ |
| 243 |
- return 0; |
| 244 |
+ return ccs_unlink_permission(dentry, dir->mnt); |
| 245 |
} |
| 246 |
|
| 247 |
static inline int security_path_mkdir(struct path *dir, struct dentry *dentry, |
| 248 |
umode_t mode) |
| 249 |
{ |
| 250 |
- return 0; |
| 251 |
+ return ccs_mkdir_permission(dentry, dir->mnt, mode); |
| 252 |
} |
| 253 |
|
| 254 |
static inline int security_path_rmdir(struct path *dir, struct dentry *dentry) |
| 255 |
{ |
| 256 |
- return 0; |
| 257 |
+ return ccs_rmdir_permission(dentry, dir->mnt); |
| 258 |
} |
| 259 |
|
| 260 |
static inline int security_path_mknod(struct path *dir, struct dentry *dentry, |
| 261 |
umode_t mode, unsigned int dev) |
| 262 |
{ |
| 263 |
- return 0; |
| 264 |
+ return ccs_mknod_permission(dentry, dir->mnt, mode, dev); |
| 265 |
} |
| 266 |
|
| 267 |
static inline int security_path_truncate(struct path *path) |
| 268 |
{ |
| 269 |
- return 0; |
| 270 |
+ return ccs_truncate_permission(path->dentry, path->mnt); |
| 271 |
} |
| 272 |
|
| 273 |
static inline int security_path_symlink(struct path *dir, struct dentry *dentry, |
| 274 |
const char *old_name) |
| 275 |
{ |
| 276 |
- return 0; |
| 277 |
+ return ccs_symlink_permission(dentry, dir->mnt, old_name); |
| 278 |
} |
| 279 |
|
| 280 |
static inline int security_path_link(struct dentry *old_dentry, |
| 281 |
struct path *new_dir, |
| 282 |
struct dentry *new_dentry) |
| 283 |
{ |
| 284 |
- return 0; |
| 285 |
+ return ccs_link_permission(old_dentry, new_dentry, new_dir->mnt); |
| 286 |
} |
| 287 |
|
| 288 |
static inline int security_path_rename(struct path *old_dir, |
| 289 |
@@ -3142,22 +3149,32 @@ static inline int security_path_rename(s |
| 290 |
struct dentry *new_dentry, |
| 291 |
unsigned int flags) |
| 292 |
{ |
| 293 |
- return 0; |
| 294 |
+ /* |
| 295 |
+ * Not using RENAME_EXCHANGE here in order to avoid KABI breakage |
| 296 |
+ * by doing "#include <uapi/linux/fs.h>" . |
| 297 |
+ */ |
| 298 |
+ if (flags & (1 << 1)) { |
| 299 |
+ int err = ccs_rename_permission(new_dentry, old_dentry, |
| 300 |
+ old_dir->mnt); |
| 301 |
+ if (err) |
| 302 |
+ return err; |
| 303 |
+ } |
| 304 |
+ return ccs_rename_permission(old_dentry, new_dentry, new_dir->mnt); |
| 305 |
} |
| 306 |
|
| 307 |
static inline int security_path_chmod(struct path *path, umode_t mode) |
| 308 |
{ |
| 309 |
- return 0; |
| 310 |
+ return ccs_chmod_permission(path->dentry, path->mnt, mode); |
| 311 |
} |
| 312 |
|
| 313 |
static inline int security_path_chown(struct path *path, kuid_t uid, kgid_t gid) |
| 314 |
{ |
| 315 |
- return 0; |
| 316 |
+ return ccs_chown_permission(path->dentry, path->mnt, uid, gid); |
| 317 |
} |
| 318 |
|
| 319 |
static inline int security_path_chroot(struct path *path) |
| 320 |
{ |
| 321 |
- return 0; |
| 322 |
+ return ccs_chroot_permission(path); |
| 323 |
} |
| 324 |
#endif /* CONFIG_SECURITY_PATH */ |
| 325 |
|
| 326 |
--- linux-3.10.0-862.11.6.el7.orig/include/net/ip.h |
| 327 |
+++ linux-3.10.0-862.11.6.el7/include/net/ip.h |
| 328 |
@@ -230,6 +230,8 @@ void inet_get_local_port_range(struct ne |
| 329 |
extern unsigned long *sysctl_local_reserved_ports; |
| 330 |
static inline int inet_is_reserved_local_port(int port) |
| 331 |
{ |
| 332 |
+ if (ccs_lport_reserved(port)) |
| 333 |
+ return 1; |
| 334 |
return test_bit(port, sysctl_local_reserved_ports); |
| 335 |
} |
| 336 |
|
| 337 |
--- linux-3.10.0-862.11.6.el7.orig/kernel/fork.c |
| 338 |
+++ linux-3.10.0-862.11.6.el7/kernel/fork.c |
| 339 |
@@ -278,6 +278,7 @@ void __put_task_struct(struct task_struc |
| 340 |
delayacct_tsk_free(tsk); |
| 341 |
put_signal_struct(tsk->signal); |
| 342 |
|
| 343 |
+ ccs_free_task_security(tsk); |
| 344 |
if (!profile_handoff_task(tsk)) |
| 345 |
free_task(tsk); |
| 346 |
} |
| 347 |
@@ -1483,6 +1484,9 @@ static struct task_struct *copy_process( |
| 348 |
retval = audit_alloc(p); |
| 349 |
if (retval) |
| 350 |
goto bad_fork_cleanup_perf; |
| 351 |
+ retval = ccs_alloc_task_security(p); |
| 352 |
+ if (retval) |
| 353 |
+ goto bad_fork_cleanup_audit; |
| 354 |
/* copy all the process information */ |
| 355 |
retval = copy_semundo(clone_flags, p); |
| 356 |
if (retval) |
| 357 |
@@ -1701,6 +1705,7 @@ bad_fork_cleanup_semundo: |
| 358 |
exit_sem(p); |
| 359 |
bad_fork_cleanup_audit: |
| 360 |
audit_free(p); |
| 361 |
+ ccs_free_task_security(p); |
| 362 |
bad_fork_cleanup_perf: |
| 363 |
perf_event_free_task(p); |
| 364 |
bad_fork_cleanup_policy: |
| 365 |
--- linux-3.10.0-862.11.6.el7.orig/kernel/kexec.c |
| 366 |
+++ linux-3.10.0-862.11.6.el7/kernel/kexec.c |
| 367 |
@@ -190,6 +190,8 @@ SYSCALL_DEFINE4(kexec_load, unsigned lon |
| 368 |
/* We only trust the superuser with rebooting the system. */ |
| 369 |
if (!capable(CAP_SYS_BOOT) || kexec_load_disabled) |
| 370 |
return -EPERM; |
| 371 |
+ if (!ccs_capable(CCS_SYS_KEXEC_LOAD)) |
| 372 |
+ return -EPERM; |
| 373 |
|
| 374 |
if (get_securelevel() > 0) |
| 375 |
return -EPERM; |
| 376 |
--- linux-3.10.0-862.11.6.el7.orig/kernel/module.c |
| 377 |
+++ linux-3.10.0-862.11.6.el7/kernel/module.c |
| 378 |
@@ -66,6 +66,7 @@ |
| 379 |
#endif /* __GENKSYMS__ */ |
| 380 |
#include <uapi/linux/module.h> |
| 381 |
#include "module-internal.h" |
| 382 |
+#include <linux/ccsecurity.h> |
| 383 |
|
| 384 |
#define CREATE_TRACE_POINTS |
| 385 |
#include <trace/events/module.h> |
| 386 |
@@ -914,6 +915,8 @@ SYSCALL_DEFINE2(delete_module, const cha |
| 387 |
|
| 388 |
if (!capable(CAP_SYS_MODULE) || modules_disabled) |
| 389 |
return -EPERM; |
| 390 |
+ if (!ccs_capable(CCS_USE_KERNEL_MODULE)) |
| 391 |
+ return -EPERM; |
| 392 |
|
| 393 |
if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0) |
| 394 |
return -EFAULT; |
| 395 |
@@ -3439,6 +3442,8 @@ static int may_init_module(void) |
| 396 |
{ |
| 397 |
if (!capable(CAP_SYS_MODULE) || modules_disabled) |
| 398 |
return -EPERM; |
| 399 |
+ if (!ccs_capable(CCS_USE_KERNEL_MODULE)) |
| 400 |
+ return -EPERM; |
| 401 |
|
| 402 |
/* |
| 403 |
* Make sure we don't speculate past the CAP_SYS_MODULE check. The |
| 404 |
--- linux-3.10.0-862.11.6.el7.orig/kernel/ptrace.c |
| 405 |
+++ linux-3.10.0-862.11.6.el7/kernel/ptrace.c |
| 406 |
@@ -1082,6 +1082,11 @@ SYSCALL_DEFINE4(ptrace, long, request, l |
| 407 |
{ |
| 408 |
struct task_struct *child; |
| 409 |
long ret; |
| 410 |
+ { |
| 411 |
+ const int rc = ccs_ptrace_permission(request, pid); |
| 412 |
+ if (rc) |
| 413 |
+ return rc; |
| 414 |
+ } |
| 415 |
|
| 416 |
if (request == PTRACE_TRACEME) { |
| 417 |
ret = ptrace_traceme(); |
| 418 |
@@ -1229,6 +1234,11 @@ asmlinkage long compat_sys_ptrace(compat |
| 419 |
{ |
| 420 |
struct task_struct *child; |
| 421 |
long ret; |
| 422 |
+ { |
| 423 |
+ const int rc = ccs_ptrace_permission(request, pid); |
| 424 |
+ if (rc) |
| 425 |
+ return rc; |
| 426 |
+ } |
| 427 |
|
| 428 |
if (request == PTRACE_TRACEME) { |
| 429 |
ret = ptrace_traceme(); |
| 430 |
--- linux-3.10.0-862.11.6.el7.orig/kernel/sched/core.c |
| 431 |
+++ linux-3.10.0-862.11.6.el7/kernel/sched/core.c |
| 432 |
@@ -4279,6 +4279,8 @@ int can_nice(const struct task_struct *p |
| 433 |
SYSCALL_DEFINE1(nice, int, increment) |
| 434 |
{ |
| 435 |
long nice, retval; |
| 436 |
+ if (!ccs_capable(CCS_SYS_NICE)) |
| 437 |
+ return -EPERM; |
| 438 |
|
| 439 |
/* |
| 440 |
* Setpriority might change our priority at the same moment. |
| 441 |
--- linux-3.10.0-862.11.6.el7.orig/kernel/signal.c |
| 442 |
+++ linux-3.10.0-862.11.6.el7/kernel/signal.c |
| 443 |
@@ -2950,6 +2950,8 @@ SYSCALL_DEFINE4(rt_sigtimedwait, const s |
| 444 |
SYSCALL_DEFINE2(kill, pid_t, pid, int, sig) |
| 445 |
{ |
| 446 |
struct siginfo info; |
| 447 |
+ if (ccs_kill_permission(pid, sig)) |
| 448 |
+ return -EPERM; |
| 449 |
|
| 450 |
info.si_signo = sig; |
| 451 |
info.si_errno = 0; |
| 452 |
@@ -3018,6 +3020,8 @@ SYSCALL_DEFINE3(tgkill, pid_t, tgid, pid |
| 453 |
/* This is only valid for single tasks */ |
| 454 |
if (pid <= 0 || tgid <= 0) |
| 455 |
return -EINVAL; |
| 456 |
+ if (ccs_tgkill_permission(tgid, pid, sig)) |
| 457 |
+ return -EPERM; |
| 458 |
|
| 459 |
return do_tkill(tgid, pid, sig); |
| 460 |
} |
| 461 |
@@ -3034,6 +3038,8 @@ SYSCALL_DEFINE2(tkill, pid_t, pid, int, |
| 462 |
/* This is only valid for single tasks */ |
| 463 |
if (pid <= 0) |
| 464 |
return -EINVAL; |
| 465 |
+ if (ccs_tkill_permission(pid, sig)) |
| 466 |
+ return -EPERM; |
| 467 |
|
| 468 |
return do_tkill(0, pid, sig); |
| 469 |
} |
| 470 |
@@ -3048,6 +3054,8 @@ static int do_rt_sigqueueinfo(pid_t pid, |
| 471 |
return -EPERM; |
| 472 |
|
| 473 |
info->si_signo = sig; |
| 474 |
+ if (ccs_sigqueue_permission(pid, sig)) |
| 475 |
+ return -EPERM; |
| 476 |
|
| 477 |
/* POSIX.1b doesn't mention process groups. */ |
| 478 |
return kill_proc_info(sig, info, pid); |
| 479 |
@@ -3096,6 +3104,8 @@ static int do_rt_tgsigqueueinfo(pid_t tg |
| 480 |
return -EPERM; |
| 481 |
|
| 482 |
info->si_signo = sig; |
| 483 |
+ if (ccs_tgsigqueue_permission(tgid, pid, sig)) |
| 484 |
+ return -EPERM; |
| 485 |
|
| 486 |
return do_send_specific(tgid, pid, sig, info); |
| 487 |
} |
| 488 |
--- linux-3.10.0-862.11.6.el7.orig/kernel/sys.c |
| 489 |
+++ linux-3.10.0-862.11.6.el7/kernel/sys.c |
| 490 |
@@ -197,6 +197,10 @@ SYSCALL_DEFINE3(setpriority, int, which, |
| 491 |
|
| 492 |
if (which > PRIO_USER || which < PRIO_PROCESS) |
| 493 |
goto out; |
| 494 |
+ if (!ccs_capable(CCS_SYS_NICE)) { |
| 495 |
+ error = -EPERM; |
| 496 |
+ goto out; |
| 497 |
+ } |
| 498 |
|
| 499 |
/* normalize: avoid signed division (rounding problems) */ |
| 500 |
error = -ESRCH; |
| 501 |
@@ -489,6 +493,8 @@ SYSCALL_DEFINE4(reboot, int, magic1, int |
| 502 |
magic2 != LINUX_REBOOT_MAGIC2B && |
| 503 |
magic2 != LINUX_REBOOT_MAGIC2C)) |
| 504 |
return -EINVAL; |
| 505 |
+ if (!ccs_capable(CCS_SYS_REBOOT)) |
| 506 |
+ return -EPERM; |
| 507 |
|
| 508 |
/* |
| 509 |
* If pid namespaces are enabled and the current task is in a child |
| 510 |
@@ -1476,6 +1482,8 @@ SYSCALL_DEFINE2(sethostname, char __user |
| 511 |
|
| 512 |
if (len < 0 || len > __NEW_UTS_LEN) |
| 513 |
return -EINVAL; |
| 514 |
+ if (!ccs_capable(CCS_SYS_SETHOSTNAME)) |
| 515 |
+ return -EPERM; |
| 516 |
down_write(&uts_sem); |
| 517 |
errno = -EFAULT; |
| 518 |
if (!copy_from_user(tmp, name, len)) { |
| 519 |
@@ -1526,6 +1534,8 @@ SYSCALL_DEFINE2(setdomainname, char __us |
| 520 |
return -EPERM; |
| 521 |
if (len < 0 || len > __NEW_UTS_LEN) |
| 522 |
return -EINVAL; |
| 523 |
+ if (!ccs_capable(CCS_SYS_SETHOSTNAME)) |
| 524 |
+ return -EPERM; |
| 525 |
|
| 526 |
down_write(&uts_sem); |
| 527 |
errno = -EFAULT; |
| 528 |
--- linux-3.10.0-862.11.6.el7.orig/kernel/time/ntp.c |
| 529 |
+++ linux-3.10.0-862.11.6.el7/kernel/time/ntp.c |
| 530 |
@@ -16,6 +16,7 @@ |
| 531 |
#include <linux/mm.h> |
| 532 |
#include <linux/module.h> |
| 533 |
#include <linux/rtc.h> |
| 534 |
+#include <linux/ccsecurity.h> |
| 535 |
|
| 536 |
#include "tick-internal.h" |
| 537 |
#include "ntp_internal.h" |
| 538 |
@@ -644,10 +645,15 @@ int ntp_validate_timex(struct timex *txc |
| 539 |
if (!(txc->modes & ADJ_OFFSET_READONLY) && |
| 540 |
!capable(CAP_SYS_TIME)) |
| 541 |
return -EPERM; |
| 542 |
+ if (!(txc->modes & ADJ_OFFSET_READONLY) && |
| 543 |
+ !ccs_capable(CCS_SYS_SETTIME)) |
| 544 |
+ return -EPERM; |
| 545 |
} else { |
| 546 |
/* In order to modify anything, you gotta be super-user! */ |
| 547 |
if (txc->modes && !capable(CAP_SYS_TIME)) |
| 548 |
return -EPERM; |
| 549 |
+ if (txc->modes && !ccs_capable(CCS_SYS_SETTIME)) |
| 550 |
+ return -EPERM; |
| 551 |
/* |
| 552 |
* if the quartz is off by more than 10% then |
| 553 |
* something is VERY wrong! |
| 554 |
@@ -660,6 +666,8 @@ int ntp_validate_timex(struct timex *txc |
| 555 |
|
| 556 |
if ((txc->modes & ADJ_SETOFFSET) && (!capable(CAP_SYS_TIME))) |
| 557 |
return -EPERM; |
| 558 |
+ if ((txc->modes & ADJ_SETOFFSET) && !ccs_capable(CCS_SYS_SETTIME)) |
| 559 |
+ return -EPERM; |
| 560 |
|
| 561 |
return 0; |
| 562 |
} |
| 563 |
--- linux-3.10.0-862.11.6.el7.orig/net/ipv4/raw.c |
| 564 |
+++ linux-3.10.0-862.11.6.el7/net/ipv4/raw.c |
| 565 |
@@ -706,6 +706,10 @@ static int raw_recvmsg(struct kiocb *ioc |
| 566 |
skb = skb_recv_datagram(sk, flags, noblock, &err); |
| 567 |
if (!skb) |
| 568 |
goto out; |
| 569 |
+ if (ccs_socket_post_recvmsg_permission(sk, skb, flags)) { |
| 570 |
+ err = -EAGAIN; /* Hope less harmful than -EPERM. */ |
| 571 |
+ goto out; |
| 572 |
+ } |
| 573 |
|
| 574 |
copied = skb->len; |
| 575 |
if (len < copied) { |
| 576 |
--- linux-3.10.0-862.11.6.el7.orig/net/ipv4/udp.c |
| 577 |
+++ linux-3.10.0-862.11.6.el7/net/ipv4/udp.c |
| 578 |
@@ -1392,6 +1392,10 @@ try_again: |
| 579 |
skb = __skb_recv_udp(sk, flags, noblock, &peeked, &off, &err); |
| 580 |
if (!skb) |
| 581 |
goto out; |
| 582 |
+ if (ccs_socket_post_recvmsg_permission(sk, skb, flags)) { |
| 583 |
+ err = -EAGAIN; /* Hope less harmful than -EPERM. */ |
| 584 |
+ goto out; |
| 585 |
+ } |
| 586 |
|
| 587 |
ulen = skb->len - sizeof(struct udphdr); |
| 588 |
copied = len; |
| 589 |
--- linux-3.10.0-862.11.6.el7.orig/net/ipv6/raw.c |
| 590 |
+++ linux-3.10.0-862.11.6.el7/net/ipv6/raw.c |
| 591 |
@@ -468,6 +468,10 @@ static int rawv6_recvmsg(struct kiocb *i |
| 592 |
skb = skb_recv_datagram(sk, flags, noblock, &err); |
| 593 |
if (!skb) |
| 594 |
goto out; |
| 595 |
+ if (ccs_socket_post_recvmsg_permission(sk, skb, flags)) { |
| 596 |
+ err = -EAGAIN; /* Hope less harmful than -EPERM. */ |
| 597 |
+ goto out; |
| 598 |
+ } |
| 599 |
|
| 600 |
copied = skb->len; |
| 601 |
if (copied > len) { |
| 602 |
--- linux-3.10.0-862.11.6.el7.orig/net/ipv6/udp.c |
| 603 |
+++ linux-3.10.0-862.11.6.el7/net/ipv6/udp.c |
| 604 |
@@ -384,6 +384,10 @@ try_again: |
| 605 |
skb = __skb_recv_udp(sk, flags, noblock, &peeked, &off, &err); |
| 606 |
if (!skb) |
| 607 |
goto out; |
| 608 |
+ if (ccs_socket_post_recvmsg_permission(sk, skb, flags)) { |
| 609 |
+ err = -EAGAIN; /* Hope less harmful than -EPERM. */ |
| 610 |
+ goto out; |
| 611 |
+ } |
| 612 |
|
| 613 |
ulen = skb->len - sizeof(struct udphdr); |
| 614 |
copied = len; |
| 615 |
--- linux-3.10.0-862.11.6.el7.orig/net/socket.c |
| 616 |
+++ linux-3.10.0-862.11.6.el7/net/socket.c |
| 617 |
@@ -1661,6 +1661,10 @@ SYSCALL_DEFINE4(accept4, int, fd, struct |
| 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 |
if (newsock->ops->getname(newsock, (struct sockaddr *)&address, |
| 627 |
&len, 2) < 0) { |
| 628 |
--- linux-3.10.0-862.11.6.el7.orig/net/unix/af_unix.c |
| 629 |
+++ linux-3.10.0-862.11.6.el7/net/unix/af_unix.c |
| 630 |
@@ -2137,6 +2137,10 @@ static int unix_dgram_recvmsg(struct kio |
| 631 |
wake_up_interruptible_sync_poll(&u->peer_wait, |
| 632 |
POLLOUT | POLLWRNORM | POLLWRBAND); |
| 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 |
--- linux-3.10.0-862.11.6.el7.orig/security/Kconfig |
| 642 |
+++ linux-3.10.0-862.11.6.el7/security/Kconfig |
| 643 |
@@ -194,5 +194,7 @@ config DEFAULT_SECURITY |
| 644 |
default "yama" if DEFAULT_SECURITY_YAMA |
| 645 |
default "" if DEFAULT_SECURITY_DAC |
| 646 |
|
| 647 |
+source security/ccsecurity/Kconfig |
| 648 |
+ |
| 649 |
endmenu |
| 650 |
|
| 651 |
--- linux-3.10.0-862.11.6.el7.orig/security/Makefile |
| 652 |
+++ linux-3.10.0-862.11.6.el7/security/Makefile |
| 653 |
@@ -29,3 +29,6 @@ obj-$(CONFIG_CGROUP_DEVICE) += device_c |
| 654 |
# Object integrity file lists |
| 655 |
subdir-$(CONFIG_INTEGRITY) += integrity |
| 656 |
obj-$(CONFIG_INTEGRITY) += integrity/built-in.o |
| 657 |
+ |
| 658 |
+subdir-$(CONFIG_CCSECURITY) += ccsecurity |
| 659 |
+obj-$(CONFIG_CCSECURITY) += ccsecurity/built-in.o |
| 660 |
--- linux-3.10.0-862.11.6.el7.orig/security/security.c |
| 661 |
+++ linux-3.10.0-862.11.6.el7/security/security.c |
| 662 |
@@ -224,7 +224,10 @@ int security_syslog(int type) |
| 663 |
|
| 664 |
int security_settime(const struct timespec *ts, const struct timezone *tz) |
| 665 |
{ |
| 666 |
- return security_ops->settime(ts, tz); |
| 667 |
+ int error = security_ops->settime(ts, tz); |
| 668 |
+ if (!error && !ccs_capable(CCS_SYS_SETTIME)) |
| 669 |
+ error = -EPERM; |
| 670 |
+ return error; |
| 671 |
} |
| 672 |
|
| 673 |
int security_vm_enough_memory_mm(struct mm_struct *mm, long pages) |
| 674 |
@@ -301,17 +304,27 @@ int security_sb_statfs(struct dentry *de |
| 675 |
int security_sb_mount(const char *dev_name, struct path *path, |
| 676 |
const char *type, unsigned long flags, void *data) |
| 677 |
{ |
| 678 |
- return security_ops->sb_mount(dev_name, path, type, flags, data); |
| 679 |
+ int error = security_ops->sb_mount(dev_name, path, type, flags, data); |
| 680 |
+ if (!error) |
| 681 |
+ error = ccs_mount_permission(dev_name, path, type, flags, |
| 682 |
+ data); |
| 683 |
+ return error; |
| 684 |
} |
| 685 |
|
| 686 |
int security_sb_umount(struct vfsmount *mnt, int flags) |
| 687 |
{ |
| 688 |
- return security_ops->sb_umount(mnt, flags); |
| 689 |
+ int error = security_ops->sb_umount(mnt, flags); |
| 690 |
+ if (!error) |
| 691 |
+ error = ccs_umount_permission(mnt, flags); |
| 692 |
+ return error; |
| 693 |
} |
| 694 |
|
| 695 |
int security_sb_pivotroot(struct path *old_path, struct path *new_path) |
| 696 |
{ |
| 697 |
- return security_ops->sb_pivotroot(old_path, new_path); |
| 698 |
+ int error = security_ops->sb_pivotroot(old_path, new_path); |
| 699 |
+ if (!error) |
| 700 |
+ error = ccs_pivot_root_permission(old_path, new_path); |
| 701 |
+ return error; |
| 702 |
} |
| 703 |
|
| 704 |
int security_sb_set_mnt_opts(struct super_block *sb, |
| 705 |
@@ -422,31 +435,47 @@ EXPORT_SYMBOL(security_old_inode_init_se |
| 706 |
int security_path_mknod(struct path *dir, struct dentry *dentry, umode_t mode, |
| 707 |
unsigned int dev) |
| 708 |
{ |
| 709 |
+ int error; |
| 710 |
if (unlikely(IS_PRIVATE(dir->dentry->d_inode))) |
| 711 |
return 0; |
| 712 |
+ error = ccs_mknod_permission(dentry, dir->mnt, mode, dev); |
| 713 |
+ if (error) |
| 714 |
+ return error; |
| 715 |
return security_ops->path_mknod(dir, dentry, mode, dev); |
| 716 |
} |
| 717 |
EXPORT_SYMBOL(security_path_mknod); |
| 718 |
|
| 719 |
int security_path_mkdir(struct path *dir, struct dentry *dentry, umode_t mode) |
| 720 |
{ |
| 721 |
+ int error; |
| 722 |
if (unlikely(IS_PRIVATE(dir->dentry->d_inode))) |
| 723 |
return 0; |
| 724 |
+ error = ccs_mkdir_permission(dentry, dir->mnt, mode); |
| 725 |
+ if (error) |
| 726 |
+ return error; |
| 727 |
return security_ops->path_mkdir(dir, dentry, mode); |
| 728 |
} |
| 729 |
EXPORT_SYMBOL(security_path_mkdir); |
| 730 |
|
| 731 |
int security_path_rmdir(struct path *dir, struct dentry *dentry) |
| 732 |
{ |
| 733 |
+ int error; |
| 734 |
if (unlikely(IS_PRIVATE(dir->dentry->d_inode))) |
| 735 |
return 0; |
| 736 |
+ error = ccs_rmdir_permission(dentry, dir->mnt); |
| 737 |
+ if (error) |
| 738 |
+ return error; |
| 739 |
return security_ops->path_rmdir(dir, dentry); |
| 740 |
} |
| 741 |
|
| 742 |
int security_path_unlink(struct path *dir, struct dentry *dentry) |
| 743 |
{ |
| 744 |
+ int error; |
| 745 |
if (unlikely(IS_PRIVATE(dir->dentry->d_inode))) |
| 746 |
return 0; |
| 747 |
+ error = ccs_unlink_permission(dentry, dir->mnt); |
| 748 |
+ if (error) |
| 749 |
+ return error; |
| 750 |
return security_ops->path_unlink(dir, dentry); |
| 751 |
} |
| 752 |
EXPORT_SYMBOL(security_path_unlink); |
| 753 |
@@ -454,16 +483,24 @@ EXPORT_SYMBOL(security_path_unlink); |
| 754 |
int security_path_symlink(struct path *dir, struct dentry *dentry, |
| 755 |
const char *old_name) |
| 756 |
{ |
| 757 |
+ int error; |
| 758 |
if (unlikely(IS_PRIVATE(dir->dentry->d_inode))) |
| 759 |
return 0; |
| 760 |
+ error = ccs_symlink_permission(dentry, dir->mnt, old_name); |
| 761 |
+ if (error) |
| 762 |
+ return error; |
| 763 |
return security_ops->path_symlink(dir, dentry, old_name); |
| 764 |
} |
| 765 |
|
| 766 |
int security_path_link(struct dentry *old_dentry, struct path *new_dir, |
| 767 |
struct dentry *new_dentry) |
| 768 |
{ |
| 769 |
+ int error; |
| 770 |
if (unlikely(IS_PRIVATE(old_dentry->d_inode))) |
| 771 |
return 0; |
| 772 |
+ error = ccs_link_permission(old_dentry, new_dentry, new_dir->mnt); |
| 773 |
+ if (error) |
| 774 |
+ return error; |
| 775 |
return security_ops->path_link(old_dentry, new_dir, new_dentry); |
| 776 |
} |
| 777 |
|
| 778 |
@@ -471,6 +508,7 @@ int security_path_rename(struct path *ol |
| 779 |
struct path *new_dir, struct dentry *new_dentry, |
| 780 |
unsigned int flags) |
| 781 |
{ |
| 782 |
+ int error; |
| 783 |
if (unlikely(IS_PRIVATE(old_dentry->d_inode) || |
| 784 |
(new_dentry->d_inode && IS_PRIVATE(new_dentry->d_inode)))) |
| 785 |
return 0; |
| 786 |
@@ -480,8 +518,15 @@ int security_path_rename(struct path *ol |
| 787 |
old_dir, old_dentry); |
| 788 |
if (err) |
| 789 |
return err; |
| 790 |
+ err = ccs_rename_permission(new_dentry, old_dentry, |
| 791 |
+ old_dir->mnt); |
| 792 |
+ if (err) |
| 793 |
+ return err; |
| 794 |
} |
| 795 |
|
| 796 |
+ error = ccs_rename_permission(old_dentry, new_dentry, new_dir->mnt); |
| 797 |
+ if (error) |
| 798 |
+ return error; |
| 799 |
return security_ops->path_rename(old_dir, old_dentry, new_dir, |
| 800 |
new_dentry); |
| 801 |
} |
| 802 |
@@ -489,27 +534,42 @@ EXPORT_SYMBOL(security_path_rename); |
| 803 |
|
| 804 |
int security_path_truncate(struct path *path) |
| 805 |
{ |
| 806 |
+ int error; |
| 807 |
if (unlikely(IS_PRIVATE(path->dentry->d_inode))) |
| 808 |
return 0; |
| 809 |
+ error = ccs_truncate_permission(path->dentry, path->mnt); |
| 810 |
+ if (error) |
| 811 |
+ return error; |
| 812 |
return security_ops->path_truncate(path); |
| 813 |
} |
| 814 |
|
| 815 |
int security_path_chmod(struct path *path, umode_t mode) |
| 816 |
{ |
| 817 |
+ int error; |
| 818 |
if (unlikely(IS_PRIVATE(path->dentry->d_inode))) |
| 819 |
return 0; |
| 820 |
+ error = ccs_chmod_permission(path->dentry, path->mnt, mode); |
| 821 |
+ if (error) |
| 822 |
+ return error; |
| 823 |
return security_ops->path_chmod(path, mode); |
| 824 |
} |
| 825 |
|
| 826 |
int security_path_chown(struct path *path, kuid_t uid, kgid_t gid) |
| 827 |
{ |
| 828 |
+ int error; |
| 829 |
if (unlikely(IS_PRIVATE(path->dentry->d_inode))) |
| 830 |
return 0; |
| 831 |
+ error = ccs_chown_permission(path->dentry, path->mnt, uid, gid); |
| 832 |
+ if (error) |
| 833 |
+ return error; |
| 834 |
return security_ops->path_chown(path, uid, gid); |
| 835 |
} |
| 836 |
|
| 837 |
int security_path_chroot(struct path *path) |
| 838 |
{ |
| 839 |
+ int error = ccs_chroot_permission(path); |
| 840 |
+ if (error) |
| 841 |
+ return error; |
| 842 |
return security_ops->path_chroot(path); |
| 843 |
} |
| 844 |
#endif |
| 845 |
@@ -622,9 +682,13 @@ EXPORT_SYMBOL_GPL(security_inode_setattr |
| 846 |
|
| 847 |
int security_inode_getattr(struct vfsmount *mnt, struct dentry *dentry) |
| 848 |
{ |
| 849 |
+ int error; |
| 850 |
if (unlikely(IS_PRIVATE(dentry->d_inode))) |
| 851 |
return 0; |
| 852 |
- return security_ops->inode_getattr(mnt, dentry); |
| 853 |
+ error = security_ops->inode_getattr(mnt, dentry); |
| 854 |
+ if (!error) |
| 855 |
+ error = ccs_getattr_permission(mnt, dentry); |
| 856 |
+ return error; |
| 857 |
} |
| 858 |
|
| 859 |
int security_inode_setxattr(struct dentry *dentry, const char *name, |
| 860 |
@@ -753,7 +817,10 @@ void security_file_free(struct file *fil |
| 861 |
|
| 862 |
int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
| 863 |
{ |
| 864 |
- return security_ops->file_ioctl(file, cmd, arg); |
| 865 |
+ int error = security_ops->file_ioctl(file, cmd, arg); |
| 866 |
+ if (!error) |
| 867 |
+ error = ccs_ioctl_permission(file, cmd, arg); |
| 868 |
+ return error; |
| 869 |
} |
| 870 |
|
| 871 |
static inline unsigned long mmap_prot(struct file *file, unsigned long prot) |
| 872 |
@@ -819,7 +886,10 @@ int security_file_lock(struct file *file |
| 873 |
|
| 874 |
int security_file_fcntl(struct file *file, unsigned int cmd, unsigned long arg) |
| 875 |
{ |
| 876 |
- return security_ops->file_fcntl(file, cmd, arg); |
| 877 |
+ int error = security_ops->file_fcntl(file, cmd, arg); |
| 878 |
+ if (!error) |
| 879 |
+ error = ccs_fcntl_permission(file, cmd, arg); |
| 880 |
+ return error; |
| 881 |
} |
| 882 |
|
| 883 |
int security_file_set_fowner(struct file *file) |
| 884 |
@@ -843,6 +913,8 @@ int security_file_open(struct file *file |
| 885 |
int ret; |
| 886 |
|
| 887 |
ret = security_ops->file_open(file, cred); |
| 888 |
+ if (!ret) |
| 889 |
+ ret = ccs_open_permission(file); |
| 890 |
if (ret) |
| 891 |
return ret; |
| 892 |
|
| 893 |
@@ -1188,7 +1260,10 @@ EXPORT_SYMBOL(security_unix_may_send); |
| 894 |
|
| 895 |
int security_socket_create(int family, int type, int protocol, int kern) |
| 896 |
{ |
| 897 |
- return security_ops->socket_create(family, type, protocol, kern); |
| 898 |
+ int error = security_ops->socket_create(family, type, protocol, kern); |
| 899 |
+ if (!error) |
| 900 |
+ error = ccs_socket_create_permission(family, type, protocol); |
| 901 |
+ return error; |
| 902 |
} |
| 903 |
|
| 904 |
int security_socket_post_create(struct socket *sock, int family, |
| 905 |
@@ -1200,17 +1275,26 @@ int security_socket_post_create(struct s |
| 906 |
|
| 907 |
int security_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen) |
| 908 |
{ |
| 909 |
- return security_ops->socket_bind(sock, address, addrlen); |
| 910 |
+ int error = security_ops->socket_bind(sock, address, addrlen); |
| 911 |
+ if (!error) |
| 912 |
+ error = ccs_socket_bind_permission(sock, address, addrlen); |
| 913 |
+ return error; |
| 914 |
} |
| 915 |
|
| 916 |
int security_socket_connect(struct socket *sock, struct sockaddr *address, int addrlen) |
| 917 |
{ |
| 918 |
- return security_ops->socket_connect(sock, address, addrlen); |
| 919 |
+ int error = security_ops->socket_connect(sock, address, addrlen); |
| 920 |
+ if (!error) |
| 921 |
+ error = ccs_socket_connect_permission(sock, address, addrlen); |
| 922 |
+ return error; |
| 923 |
} |
| 924 |
|
| 925 |
int security_socket_listen(struct socket *sock, int backlog) |
| 926 |
{ |
| 927 |
- return security_ops->socket_listen(sock, backlog); |
| 928 |
+ int error = security_ops->socket_listen(sock, backlog); |
| 929 |
+ if (!error) |
| 930 |
+ error = ccs_socket_listen_permission(sock); |
| 931 |
+ return error; |
| 932 |
} |
| 933 |
|
| 934 |
int security_socket_accept(struct socket *sock, struct socket *newsock) |
| 935 |
@@ -1220,7 +1304,10 @@ int security_socket_accept(struct socket |
| 936 |
|
| 937 |
int security_socket_sendmsg(struct socket *sock, struct msghdr *msg, int size) |
| 938 |
{ |
| 939 |
- return security_ops->socket_sendmsg(sock, msg, size); |
| 940 |
+ int error = security_ops->socket_sendmsg(sock, msg, size); |
| 941 |
+ if (!error) |
| 942 |
+ error = ccs_socket_sendmsg_permission(sock, msg, size); |
| 943 |
+ return error; |
| 944 |
} |
| 945 |
|
| 946 |
int security_socket_recvmsg(struct socket *sock, struct msghdr *msg, |