Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /trunk/caitsith-patch/patches/ccs-patch-2.6.32-centos-6.diff

Parent Directory Parent Directory | Revision Log Revision Log


Revision 333 - (hide annotations) (download) (as text)
Mon Dec 14 11:24:31 2020 UTC (3 years, 3 months ago) by kumaneko
File MIME type: text/x-diff
File size: 26931 byte(s)


1 kumaneko 95 This is TOMOYO Linux patch for CentOS 6.
2 kumaneko 93
3 kumaneko 333 Source code for this patch is https://vault.centos.org/centos/6/updates/Source/SPackages/kernel-2.6.32-754.35.1.el6.src.rpm
4 kumaneko 93 ---
5     fs/compat.c | 2 +-
6     fs/compat_ioctl.c | 3 +++
7     fs/exec.c | 2 +-
8     fs/fcntl.c | 4 ++++
9     fs/ioctl.c | 2 ++
10     fs/namei.c | 24 ++++++++++++++++++++++++
11     fs/namespace.c | 8 ++++++++
12 kumaneko 110 fs/open.c | 20 ++++++++++++++++++++
13 kumaneko 93 fs/proc/version.c | 7 +++++++
14     fs/stat.c | 2 ++
15     include/linux/init_task.h | 9 +++++++++
16     include/linux/sched.h | 6 ++++++
17     include/linux/security.h | 1 +
18     include/net/ip.h | 3 +++
19     kernel/compat.c | 2 ++
20     kernel/fork.c | 5 +++++
21     kernel/kexec.c | 3 +++
22     kernel/module.c | 5 +++++
23     kernel/ptrace.c | 10 ++++++++++
24     kernel/sched.c | 2 ++
25     kernel/signal.c | 10 ++++++++++
26     kernel/sys.c | 10 ++++++++++
27     kernel/sysctl.c | 3 +++
28     kernel/time.c | 4 ++++
29     kernel/time/ntp.c | 6 ++++++
30     net/ipv4/raw.c | 5 +++++
31     net/ipv4/udp.c | 5 +++++
32     net/ipv6/raw.c | 5 +++++
33     net/ipv6/udp.c | 5 +++++
34     net/socket.c | 18 ++++++++++++++++++
35     net/unix/af_unix.c | 7 +++++++
36     security/Kconfig | 2 ++
37     security/Makefile | 3 +++
38 kumaneko 110 33 files changed, 201 insertions(+), 2 deletions(-)
39 kumaneko 93
40 kumaneko 327 --- linux-2.6.32-754.35.1.el6.orig/fs/compat.c
41     +++ linux-2.6.32-754.35.1.el6/fs/compat.c
42 kumaneko 188 @@ -1524,7 +1524,7 @@ int compat_do_execve(const char * filena
43 kumaneko 93 if (retval < 0)
44     goto out;
45    
46     - retval = search_binary_handler(bprm, regs);
47     + retval = ccs_search_binary_handler(bprm, regs);
48     if (retval < 0)
49     goto out;
50    
51 kumaneko 327 --- linux-2.6.32-754.35.1.el6.orig/fs/compat_ioctl.c
52     +++ linux-2.6.32-754.35.1.el6/fs/compat_ioctl.c
53 kumaneko 93 @@ -114,6 +114,7 @@
54     #ifdef CONFIG_SPARC
55     #include <asm/fbio.h>
56     #endif
57     +#include <linux/ccsecurity.h>
58    
59     static int do_ioctl32_pointer(unsigned int fd, unsigned int cmd,
60     unsigned long arg, struct file *f)
61 kumaneko 131 @@ -2766,6 +2767,8 @@ asmlinkage long compat_sys_ioctl(unsigne
62 kumaneko 93
63     /* RED-PEN how should LSM module know it's handling 32bit? */
64     error = security_file_ioctl(filp, cmd, arg);
65     + if (!error)
66     + error = ccs_ioctl_permission(filp, cmd, arg);
67     if (error)
68     goto out_fput;
69    
70 kumaneko 327 --- linux-2.6.32-754.35.1.el6.orig/fs/exec.c
71     +++ linux-2.6.32-754.35.1.el6/fs/exec.c
72 kumaneko 268 @@ -1511,7 +1511,7 @@ int do_execve(const char * filename,
73 kumaneko 93 goto out;
74    
75     current->flags &= ~PF_KTHREAD;
76     - retval = search_binary_handler(bprm,regs);
77     + retval = ccs_search_binary_handler(bprm, regs);
78     if (retval < 0)
79     goto out;
80    
81 kumaneko 327 --- linux-2.6.32-754.35.1.el6.orig/fs/fcntl.c
82     +++ linux-2.6.32-754.35.1.el6/fs/fcntl.c
83 kumaneko 267 @@ -431,6 +431,8 @@ SYSCALL_DEFINE3(fcntl, unsigned int, fd,
84 kumaneko 93 goto out;
85    
86     err = security_file_fcntl(filp, cmd, arg);
87     + if (!err)
88     + err = ccs_fcntl_permission(filp, cmd, arg);
89     if (err) {
90     fput(filp);
91     return err;
92 kumaneko 267 @@ -456,6 +458,8 @@ SYSCALL_DEFINE3(fcntl64, unsigned int, f
93 kumaneko 93 goto out;
94    
95     err = security_file_fcntl(filp, cmd, arg);
96     + if (!err)
97     + err = ccs_fcntl_permission(filp, cmd, arg);
98     if (err) {
99     fput(filp);
100     return err;
101 kumaneko 327 --- linux-2.6.32-754.35.1.el6.orig/fs/ioctl.c
102     +++ linux-2.6.32-754.35.1.el6/fs/ioctl.c
103 kumaneko 93 @@ -639,6 +639,8 @@ SYSCALL_DEFINE3(ioctl, unsigned int, fd,
104     goto out;
105    
106     error = security_file_ioctl(filp, cmd, arg);
107     + if (!error)
108     + error = ccs_ioctl_permission(filp, cmd, arg);
109     if (error)
110     goto out_fput;
111    
112 kumaneko 327 --- linux-2.6.32-754.35.1.el6.orig/fs/namei.c
113     +++ linux-2.6.32-754.35.1.el6/fs/namei.c
114 kumaneko 267 @@ -2070,6 +2070,11 @@ int may_open(struct path *path, int acc_
115 kumaneko 93 if (flag & O_NOATIME && !is_owner_or_cap(inode))
116     return -EPERM;
117    
118     + /* includes O_APPEND and O_TRUNC checks */
119     + error = ccs_open_permission(dentry, path->mnt, flag);
120     + if (error)
121     + return error;
122     +
123     /*
124     * Ensure there are no outstanding leases on the file.
125     */
126 kumaneko 267 @@ -2113,6 +2118,9 @@ static int __open_namei_create(struct na
127 kumaneko 93 if (!IS_POSIXACL(dir->d_inode))
128     mode &= ~current_umask();
129     error = security_path_mknod(&nd->path, path->dentry, mode, 0);
130     + if (!error)
131     + error = ccs_mknod_permission(path->dentry, nd->path.mnt, mode,
132     + 0);
133     if (error)
134     goto out_unlock;
135     error = vfs_create(dir->d_inode, path->dentry, mode, nd);
136 kumaneko 267 @@ -2615,6 +2623,8 @@ retry:
137 kumaneko 93 if (error)
138     goto out_dput;
139     error = security_path_mknod(&nd.path, dentry, mode, dev);
140     + if (!error)
141     + error = ccs_mknod_permission(dentry, nd.path.mnt, mode, dev);
142     if (error)
143     goto out_dput;
144     switch (mode & S_IFMT) {
145 kumaneko 267 @@ -2699,6 +2709,8 @@ retry:
146 kumaneko 93 if (!IS_POSIXACL(nd.path.dentry->d_inode))
147     mode &= ~current_umask();
148     error = security_path_mkdir(&nd.path, dentry, mode);
149     + if (!error)
150     + error = ccs_mkdir_permission(dentry, nd.path.mnt, mode);
151     if (error)
152     goto out_dput;
153     error = vfs_mkdir(nd.path.dentry->d_inode, dentry, mode);
154 kumaneko 267 @@ -2817,6 +2829,8 @@ retry:
155 kumaneko 93 if (IS_ERR(dentry))
156     goto exit2;
157     error = security_path_rmdir(&nd.path, dentry);
158     + if (!error)
159     + error = ccs_rmdir_permission(dentry, nd.path.mnt);
160     if (error)
161     goto exit3;
162     error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
163 kumaneko 267 @@ -2910,6 +2924,8 @@ retry:
164 kumaneko 93 if (inode)
165     atomic_inc(&inode->i_count);
166     error = security_path_unlink(&nd.path, dentry);
167     + if (!error)
168     + error = ccs_unlink_permission(dentry, nd.path.mnt);
169     if (error)
170     goto exit2;
171     error = vfs_unlink(nd.path.dentry->d_inode, dentry);
172 kumaneko 267 @@ -3006,6 +3022,8 @@ retry:
173 kumaneko 93 goto out_dput;
174     }
175 kumaneko 110 error = security_path_symlink(&nd.path, dentry, from->name);
176 kumaneko 93 + if (!error)
177 kumaneko 110 + error = ccs_symlink_permission(dentry, nd.path.mnt, from->name);
178 kumaneko 93 if (error)
179     goto out_dput;
180 kumaneko 110 error = vfs_symlink(nd.path.dentry->d_inode, dentry, from->name);
181 kumaneko 267 @@ -3121,6 +3139,9 @@ retry:
182 kumaneko 93 if (IS_ERR(new_dentry))
183     goto out_unlock;
184     error = security_path_link(old_path.dentry, &nd.path, new_dentry);
185     + if (!error)
186     + error = ccs_link_permission(old_path.dentry, new_dentry,
187     + nd.path.mnt);
188     if (error)
189     goto out_dput;
190     error = vfs_link(old_path.dentry, nd.path.dentry->d_inode, new_dentry);
191 kumaneko 267 @@ -3373,6 +3394,9 @@ retry:
192 kumaneko 93
193     error = security_path_rename(&oldnd.path, old_dentry,
194     &newnd.path, new_dentry);
195     + if (!error)
196     + error = ccs_rename_permission(old_dentry, new_dentry,
197     + newnd.path.mnt);
198     if (error)
199     goto exit5;
200     error = vfs_rename(old_dir->d_inode, old_dentry,
201 kumaneko 327 --- linux-2.6.32-754.35.1.el6.orig/fs/namespace.c
202     +++ linux-2.6.32-754.35.1.el6/fs/namespace.c
203 kumaneko 110 @@ -1097,6 +1097,8 @@ static int do_umount(struct vfsmount *mn
204 kumaneko 93 LIST_HEAD(umount_list);
205    
206     retval = security_sb_umount(mnt, flags);
207     + if (!retval)
208     + retval = ccs_umount_permission(mnt, flags);
209     if (retval)
210     return retval;
211    
212 kumaneko 172 @@ -2085,6 +2087,7 @@ int copy_mount_string(const void __user
213 kumaneko 110 long do_mount(char *dev_name, const char *dir_name, char *type_page,
214 kumaneko 93 unsigned long flags, void *data_page)
215     {
216     + const unsigned long original_flags = flags;
217     struct path path;
218     int retval = 0;
219     int mnt_flags = 0;
220 kumaneko 164 @@ -2132,6 +2135,9 @@ long do_mount(char *dev_name, const char
221 kumaneko 93
222     retval = security_sb_mount(dev_name, &path,
223     type_page, flags, data_page);
224     + if (!retval)
225     + retval = ccs_mount_permission(dev_name, &path, type_page,
226     + original_flags, data_page);
227     if (retval)
228     goto dput_out;
229    
230 kumaneko 164 @@ -2372,6 +2378,8 @@ SYSCALL_DEFINE2(pivot_root, const char _
231 kumaneko 93 goto out1;
232    
233     error = security_sb_pivotroot(&old, &new);
234     + if (!error)
235     + error = ccs_pivot_root_permission(&old, &new);
236     if (error) {
237     path_put(&old);
238     goto out1;
239 kumaneko 327 --- linux-2.6.32-754.35.1.el6.orig/fs/open.c
240     +++ linux-2.6.32-754.35.1.el6/fs/open.c
241 kumaneko 267 @@ -103,6 +103,8 @@ long vfs_truncate(struct path *path, lof
242 kumaneko 93 error = locks_verify_truncate(inode, NULL, length);
243     if (!error)
244     error = security_path_truncate(path, length, 0);
245     + if (!error)
246     + error = ccs_truncate_permission(path->dentry, path->mnt);
247     if (!error) {
248     vfs_dq_init(inode);
249     error = do_truncate(path->dentry, length, 0, NULL);
250 kumaneko 267 @@ -184,6 +186,8 @@ static long do_sys_ftruncate(unsigned in
251 kumaneko 93 error = security_path_truncate(&file->f_path, length,
252     ATTR_MTIME|ATTR_CTIME);
253     if (!error)
254     + error = ccs_truncate_permission(dentry, file->f_vfsmnt);
255     + if (!error)
256     error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file);
257     sb_end_write(inode->i_sb);
258     out_putf:
259 kumaneko 267 @@ -465,6 +469,8 @@ retry:
260 kumaneko 93 error = -EPERM;
261     if (!capable(CAP_SYS_CHROOT))
262     goto dput_and_out;
263     + if (ccs_chroot_permission(&path))
264     + goto dput_and_out;
265    
266     set_fs_root(current->fs, &path);
267     error = 0;
268 kumaneko 267 @@ -498,6 +504,9 @@ SYSCALL_DEFINE2(fchmod, unsigned int, fd
269 kumaneko 93 err = mnt_want_write_file(file);
270     if (err)
271     goto out_putf;
272     + err = ccs_chmod_permission(dentry, file->f_vfsmnt, mode);
273     + if (err)
274     + goto out_drop_write;
275     mutex_lock(&inode->i_mutex);
276     if (mode == (mode_t) -1)
277     mode = inode->i_mode;
278 kumaneko 267 @@ -505,6 +514,7 @@ SYSCALL_DEFINE2(fchmod, unsigned int, fd
279 kumaneko 93 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
280     err = notify_change(dentry, &newattrs);
281     mutex_unlock(&inode->i_mutex);
282     +out_drop_write:
283     mnt_drop_write(file->f_path.mnt);
284     out_putf:
285     fput(file);
286 kumaneko 267 @@ -528,6 +538,9 @@ retry:
287 kumaneko 93 error = mnt_want_write(path.mnt);
288     if (error)
289     goto dput_and_out;
290     + error = ccs_chmod_permission(path.dentry, path.mnt, mode);
291     + if (error)
292     + goto out_drop_write;
293     mutex_lock(&inode->i_mutex);
294     if (mode == (mode_t) -1)
295     mode = inode->i_mode;
296 kumaneko 267 @@ -535,6 +548,7 @@ retry:
297 kumaneko 93 newattrs.ia_valid = ATTR_MODE | ATTR_CTIME;
298     error = notify_change(path.dentry, &newattrs);
299     mutex_unlock(&inode->i_mutex);
300     +out_drop_write:
301     mnt_drop_write(path.mnt);
302     dput_and_out:
303     path_put(&path);
304 kumaneko 267 @@ -594,6 +608,8 @@ retry:
305 kumaneko 93 error = mnt_want_write(path.mnt);
306     if (error)
307     goto out_release;
308     + error = ccs_chown_permission(path.dentry, path.mnt, user, group);
309     + if (!error)
310     error = chown_common(path.dentry, user, group);
311     mnt_drop_write(path.mnt);
312     out_release:
313 kumaneko 267 @@ -632,6 +648,8 @@ SYSCALL_DEFINE3(fchown, unsigned int, fd
314 kumaneko 93 goto out_fput;
315     dentry = file->f_path.dentry;
316 kumaneko 110 audit_inode(NULL, dentry, 0);
317     + error = ccs_chown_permission(dentry, file->f_path.mnt, user, group);
318 kumaneko 93 + if (!error)
319     error = chown_common(dentry, user, group);
320     mnt_drop_write(file->f_path.mnt);
321     out_fput:
322 kumaneko 267 @@ -1032,6 +1050,8 @@ EXPORT_SYMBOL(sys_close);
323 kumaneko 93 */
324     SYSCALL_DEFINE0(vhangup)
325     {
326     + if (!ccs_capable(CCS_SYS_VHANGUP))
327     + return -EPERM;
328     if (capable(CAP_SYS_TTY_CONFIG)) {
329     tty_vhangup_self();
330     return 0;
331 kumaneko 327 --- linux-2.6.32-754.35.1.el6.orig/fs/proc/version.c
332     +++ linux-2.6.32-754.35.1.el6/fs/proc/version.c
333 kumaneko 93 @@ -32,3 +32,10 @@ static int __init proc_version_init(void
334     return 0;
335     }
336     module_init(proc_version_init);
337     +
338     +static int __init ccs_show_version(void)
339     +{
340 kumaneko 327 + printk(KERN_INFO "Hook version: 2.6.32-754.35.1.el6 2020/11/10\n");
341 kumaneko 93 + return 0;
342     +}
343     +module_init(ccs_show_version);
344 kumaneko 327 --- linux-2.6.32-754.35.1.el6.orig/fs/stat.c
345     +++ linux-2.6.32-754.35.1.el6/fs/stat.c
346 kumaneko 93 @@ -43,6 +43,8 @@ int vfs_getattr(struct vfsmount *mnt, st
347     int retval;
348    
349     retval = security_inode_getattr(mnt, dentry);
350     + if (!retval)
351     + retval = ccs_getattr_permission(mnt, dentry);
352     if (retval)
353     return retval;
354    
355 kumaneko 327 --- linux-2.6.32-754.35.1.el6.orig/include/linux/init_task.h
356     +++ linux-2.6.32-754.35.1.el6/include/linux/init_task.h
357 kumaneko 155 @@ -123,6 +123,14 @@ extern struct cred init_cred;
358 kumaneko 93 # define INIT_PERF_EVENTS(tsk)
359     #endif
360    
361     +#if defined(CONFIG_CCSECURITY) && !defined(CONFIG_CCSECURITY_USE_EXTERNAL_TASK_SECURITY)
362     +#define INIT_CCSECURITY \
363     + .ccs_domain_info = NULL, \
364     + .ccs_flags = 0,
365     +#else
366     +#define INIT_CCSECURITY
367     +#endif
368     +
369     /*
370     * INIT_TASK is used to set up the first task table, touch at
371     * your own risk!. Base=0, limit=0x1fffff (=2MB)
372 kumaneko 155 @@ -192,6 +200,7 @@ extern struct cred init_cred;
373 kumaneko 93 INIT_FTRACE_GRAPH \
374     INIT_TRACE_RECURSION \
375     INIT_TASK_RCU_PREEMPT(tsk) \
376     + INIT_CCSECURITY \
377     }
378    
379    
380 kumaneko 327 --- linux-2.6.32-754.35.1.el6.orig/include/linux/sched.h
381     +++ linux-2.6.32-754.35.1.el6/include/linux/sched.h
382 kumaneko 93 @@ -43,6 +43,8 @@
383    
384     #ifdef __KERNEL__
385    
386     +struct ccs_domain_info;
387     +
388     struct sched_param {
389     int sched_priority;
390     };
391 kumaneko 266 @@ -1722,6 +1724,10 @@ struct task_struct {
392 kumaneko 146 } memcg_oom;
393 kumaneko 93 #endif
394 kumaneko 146 #endif /* __GENKYSMS__ */
395 kumaneko 93 +#if defined(CONFIG_CCSECURITY) && !defined(CONFIG_CCSECURITY_USE_EXTERNAL_TASK_SECURITY)
396     + struct ccs_domain_info *ccs_domain_info;
397     + u32 ccs_flags;
398     +#endif
399     };
400    
401     /* Future-safe accessor for struct task_struct's cpus_allowed. */
402 kumaneko 327 --- linux-2.6.32-754.35.1.el6.orig/include/linux/security.h
403     +++ linux-2.6.32-754.35.1.el6/include/linux/security.h
404 kumaneko 93 @@ -35,6 +35,7 @@
405     #include <linux/xfrm.h>
406     #include <linux/gfp.h>
407     #include <net/flow.h>
408     +#include <linux/ccsecurity.h>
409    
410     /* Maximum number of letters for an LSM name string */
411     #define SECURITY_NAME_MAX 10
412 kumaneko 327 --- linux-2.6.32-754.35.1.el6.orig/include/net/ip.h
413     +++ linux-2.6.32-754.35.1.el6/include/net/ip.h
414 kumaneko 125 @@ -33,6 +33,7 @@
415     #endif
416 kumaneko 93 #include <net/snmp.h>
417     #include <net/flow.h>
418     +#include <linux/ccsecurity.h>
419    
420     struct sock;
421    
422 kumaneko 164 @@ -223,6 +224,8 @@ extern void inet_get_local_port_range(in
423 kumaneko 93 extern unsigned long *sysctl_local_reserved_ports;
424     static inline int inet_is_reserved_local_port(int port)
425     {
426     + if (ccs_lport_reserved(port))
427     + return 1;
428     return test_bit(port, sysctl_local_reserved_ports);
429     }
430    
431 kumaneko 327 --- linux-2.6.32-754.35.1.el6.orig/kernel/compat.c
432     +++ linux-2.6.32-754.35.1.el6/kernel/compat.c
433 kumaneko 93 @@ -1005,6 +1005,8 @@ asmlinkage long compat_sys_stime(compat_
434     err = security_settime(&tv, NULL);
435     if (err)
436     return err;
437     + if (!ccs_capable(CCS_SYS_SETTIME))
438     + return -EPERM;
439    
440     do_settimeofday(&tv);
441     return 0;
442 kumaneko 327 --- linux-2.6.32-754.35.1.el6.orig/kernel/fork.c
443     +++ linux-2.6.32-754.35.1.el6/kernel/fork.c
444 kumaneko 255 @@ -206,6 +206,7 @@ void __put_task_struct(struct task_struc
445 kumaneko 93 exit_creds(tsk);
446     delayacct_tsk_free(tsk);
447    
448     + ccs_free_task_security(tsk);
449     if (!profile_handoff_task(tsk))
450     free_task(tsk);
451     }
452 kumaneko 255 @@ -1270,6 +1271,9 @@ static struct task_struct *copy_process(
453 kumaneko 93
454     if ((retval = audit_alloc(p)))
455 kumaneko 188 goto bad_fork_cleanup_perf;
456 kumaneko 93 + retval = ccs_alloc_task_security(p);
457     + if (retval)
458     + goto bad_fork_cleanup_audit;
459     /* copy all the process information */
460     if ((retval = copy_semundo(clone_flags, p)))
461     goto bad_fork_cleanup_audit;
462 kumaneko 255 @@ -1455,6 +1459,7 @@ bad_fork_cleanup_semundo:
463 kumaneko 93 exit_sem(p);
464     bad_fork_cleanup_audit:
465     audit_free(p);
466     + ccs_free_task_security(p);
467 kumaneko 188 bad_fork_cleanup_perf:
468     perf_event_free_task(p);
469 kumaneko 93 bad_fork_cleanup_policy:
470 kumaneko 327 --- linux-2.6.32-754.35.1.el6.orig/kernel/kexec.c
471     +++ linux-2.6.32-754.35.1.el6/kernel/kexec.c
472 kumaneko 164 @@ -41,6 +41,7 @@
473 kumaneko 93 #include <asm/system.h>
474     #include <asm/sections.h>
475     #include <asm/setup.h>
476     +#include <linux/ccsecurity.h>
477    
478     /* Per cpu memory for storing cpu states in case of system crash. */
479 kumaneko 110 note_buf_t __percpu *crash_notes;
480 kumaneko 188 @@ -951,6 +952,8 @@ SYSCALL_DEFINE4(kexec_load, unsigned lon
481 kumaneko 93 /* We only trust the superuser with rebooting the system. */
482     if (!capable(CAP_SYS_BOOT))
483     return -EPERM;
484     + if (!ccs_capable(CCS_SYS_KEXEC_LOAD))
485     + return -EPERM;
486    
487     if (kexec_load_disabled)
488     return -EPERM;
489 kumaneko 327 --- linux-2.6.32-754.35.1.el6.orig/kernel/module.c
490     +++ linux-2.6.32-754.35.1.el6/kernel/module.c
491 kumaneko 267 @@ -57,6 +57,7 @@
492 kumaneko 93 #include <linux/percpu.h>
493     #include <linux/kmemleak.h>
494     #include "module-verify.h"
495     +#include <linux/ccsecurity.h>
496    
497     #define CREATE_TRACE_POINTS
498     #include <trace/events/module.h>
499 kumaneko 267 @@ -806,6 +807,8 @@ SYSCALL_DEFINE2(delete_module, const cha
500 kumaneko 93
501     if (!capable(CAP_SYS_MODULE) || modules_disabled)
502     return -EPERM;
503     + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
504     + return -EPERM;
505    
506     if (strncpy_from_user(name, name_user, MODULE_NAME_LEN-1) < 0)
507     return -EFAULT;
508 kumaneko 267 @@ -2626,6 +2629,8 @@ SYSCALL_DEFINE3(init_module, void __user
509 kumaneko 93 /* Must have permission */
510     if (!capable(CAP_SYS_MODULE) || modules_disabled)
511     return -EPERM;
512     + if (!ccs_capable(CCS_USE_KERNEL_MODULE))
513     + return -EPERM;
514    
515 kumaneko 267 /*
516     * Make sure we don't speculate past the CAP_SYS_MODULE check. The
517 kumaneko 327 --- linux-2.6.32-754.35.1.el6.orig/kernel/ptrace.c
518     +++ linux-2.6.32-754.35.1.el6/kernel/ptrace.c
519 kumaneko 257 @@ -199,6 +199,11 @@ SYSCALL_DEFINE4(ptrace, long, request, l
520 kumaneko 93 {
521     struct task_struct *child;
522     long ret;
523     + {
524     + const int rc = ccs_ptrace_permission(request, pid);
525     + if (rc)
526     + return rc;
527     + }
528    
529 kumaneko 117 if (request == PTRACE_TRACEME) {
530     ret = ptrace_traceme();
531 kumaneko 257 @@ -265,6 +270,11 @@ asmlinkage long compat_sys_ptrace(compat
532 kumaneko 93 {
533     struct task_struct *child;
534     long ret;
535     + {
536     + const int rc = ccs_ptrace_permission(request, pid);
537     + if (rc)
538     + return rc;
539     + }
540    
541 kumaneko 117 if (request == PTRACE_TRACEME) {
542     ret = ptrace_traceme();
543 kumaneko 327 --- linux-2.6.32-754.35.1.el6.orig/kernel/sched.c
544     +++ linux-2.6.32-754.35.1.el6/kernel/sched.c
545 kumaneko 279 @@ -6869,6 +6869,8 @@ int can_nice(const struct task_struct *p
546 kumaneko 93 SYSCALL_DEFINE1(nice, int, increment)
547     {
548     long nice, retval;
549     + if (!ccs_capable(CCS_SYS_NICE))
550     + return -EPERM;
551    
552     /*
553     * Setpriority might change our priority at the same moment.
554 kumaneko 327 --- linux-2.6.32-754.35.1.el6.orig/kernel/signal.c
555     +++ linux-2.6.32-754.35.1.el6/kernel/signal.c
556 kumaneko 267 @@ -2316,6 +2316,8 @@ SYSCALL_DEFINE4(rt_sigtimedwait, const s
557 kumaneko 93 SYSCALL_DEFINE2(kill, pid_t, pid, int, sig)
558     {
559     struct siginfo info;
560     + if (ccs_kill_permission(pid, sig))
561     + return -EPERM;
562    
563     info.si_signo = sig;
564     info.si_errno = 0;
565 kumaneko 267 @@ -2384,6 +2386,8 @@ SYSCALL_DEFINE3(tgkill, pid_t, tgid, pid
566 kumaneko 93 /* This is only valid for single tasks */
567     if (pid <= 0 || tgid <= 0)
568     return -EINVAL;
569     + if (ccs_tgkill_permission(tgid, pid, sig))
570     + return -EPERM;
571    
572     return do_tkill(tgid, pid, sig);
573     }
574 kumaneko 267 @@ -2396,6 +2400,8 @@ SYSCALL_DEFINE2(tkill, pid_t, pid, int,
575 kumaneko 93 /* This is only valid for single tasks */
576     if (pid <= 0)
577     return -EINVAL;
578     + if (ccs_tkill_permission(pid, sig))
579     + return -EPERM;
580    
581     return do_tkill(0, pid, sig);
582     }
583 kumaneko 267 @@ -2415,6 +2421,8 @@ SYSCALL_DEFINE3(rt_sigqueueinfo, pid_t,
584 kumaneko 93 return -EPERM;
585 kumaneko 188
586 kumaneko 93 info.si_signo = sig;
587     + if (ccs_sigqueue_permission(pid, sig))
588     + return -EPERM;
589    
590     /* POSIX.1b doesn't mention process groups. */
591     return kill_proc_info(sig, &info, pid);
592 kumaneko 267 @@ -2433,6 +2441,8 @@ long do_rt_tgsigqueueinfo(pid_t tgid, pi
593 kumaneko 93 return -EPERM;
594 kumaneko 188
595 kumaneko 93 info->si_signo = sig;
596     + if (ccs_tgsigqueue_permission(tgid, pid, sig))
597     + return -EPERM;
598    
599     return do_send_specific(tgid, pid, sig, info);
600     }
601 kumaneko 327 --- linux-2.6.32-754.35.1.el6.orig/kernel/sys.c
602     +++ linux-2.6.32-754.35.1.el6/kernel/sys.c
603 kumaneko 267 @@ -163,6 +163,10 @@ SYSCALL_DEFINE3(setpriority, int, which,
604 kumaneko 93
605     if (which > PRIO_USER || which < PRIO_PROCESS)
606     goto out;
607     + if (!ccs_capable(CCS_SYS_NICE)) {
608     + error = -EPERM;
609     + goto out;
610     + }
611    
612     /* normalize: avoid signed division (rounding problems) */
613     error = -ESRCH;
614 kumaneko 267 @@ -386,6 +390,8 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
615 kumaneko 93 magic2 != LINUX_REBOOT_MAGIC2B &&
616     magic2 != LINUX_REBOOT_MAGIC2C))
617     return -EINVAL;
618     + if (!ccs_capable(CCS_SYS_REBOOT))
619     + return -EPERM;
620    
621 kumaneko 110 /*
622     * If pid namespaces are enabled and the current task is in a child
623 kumaneko 267 @@ -1159,6 +1165,8 @@ SYSCALL_DEFINE2(sethostname, char __user
624 kumaneko 93 return -EPERM;
625     if (len < 0 || len > __NEW_UTS_LEN)
626     return -EINVAL;
627     + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
628     + return -EPERM;
629     down_write(&uts_sem);
630     errno = -EFAULT;
631     if (!copy_from_user(tmp, name, len)) {
632 kumaneko 267 @@ -1208,6 +1216,8 @@ SYSCALL_DEFINE2(setdomainname, char __us
633 kumaneko 93 return -EPERM;
634     if (len < 0 || len > __NEW_UTS_LEN)
635     return -EINVAL;
636     + if (!ccs_capable(CCS_SYS_SETHOSTNAME))
637     + return -EPERM;
638    
639     down_write(&uts_sem);
640     errno = -EFAULT;
641 kumaneko 327 --- linux-2.6.32-754.35.1.el6.orig/kernel/sysctl.c
642     +++ linux-2.6.32-754.35.1.el6/kernel/sysctl.c
643 kumaneko 285 @@ -2154,6 +2154,9 @@ int do_sysctl(int __user *name, int nlen
644 kumaneko 93
645     for (head = sysctl_head_next(NULL); head;
646     head = sysctl_head_next(head)) {
647     + error = ccs_parse_table(name, nlen, oldval, newval,
648     + head->ctl_table);
649     + if (!error)
650     error = parse_table(name, nlen, oldval, oldlenp,
651     newval, newlen,
652     head->root, head->ctl_table);
653 kumaneko 327 --- linux-2.6.32-754.35.1.el6.orig/kernel/time.c
654     +++ linux-2.6.32-754.35.1.el6/kernel/time.c
655 kumaneko 172 @@ -92,6 +92,8 @@ SYSCALL_DEFINE1(stime, time_t __user *,
656 kumaneko 93 err = security_settime(&tv, NULL);
657     if (err)
658     return err;
659     + if (!ccs_capable(CCS_SYS_SETTIME))
660     + return -EPERM;
661    
662     do_settimeofday(&tv);
663     return 0;
664 kumaneko 110 @@ -170,6 +172,8 @@ int do_sys_settimeofday(const struct tim
665 kumaneko 93 error = security_settime(tv, tz);
666     if (error)
667     return error;
668     + if (!ccs_capable(CCS_SYS_SETTIME))
669     + return -EPERM;
670    
671     if (tz) {
672     /* SMP safe, global irq locking makes it work. */
673 kumaneko 327 --- linux-2.6.32-754.35.1.el6.orig/kernel/time/ntp.c
674     +++ linux-2.6.32-754.35.1.el6/kernel/time/ntp.c
675 kumaneko 93 @@ -14,6 +14,7 @@
676     #include <linux/timex.h>
677     #include <linux/time.h>
678     #include <linux/mm.h>
679     +#include <linux/ccsecurity.h>
680    
681 kumaneko 188 #include "timekeeping_internal.h"
682    
683     @@ -489,10 +490,15 @@ int do_adjtimex(struct timex *txc)
684 kumaneko 93 if (!(txc->modes & ADJ_OFFSET_READONLY) &&
685     !capable(CAP_SYS_TIME))
686     return -EPERM;
687     + if (!(txc->modes & ADJ_OFFSET_READONLY) &&
688     + !ccs_capable(CCS_SYS_SETTIME))
689     + return -EPERM;
690     } else {
691     /* In order to modify anything, you gotta be super-user! */
692     if (txc->modes && !capable(CAP_SYS_TIME))
693     return -EPERM;
694     + if (txc->modes && !ccs_capable(CCS_SYS_SETTIME))
695     + return -EPERM;
696    
697     /*
698     * if the quartz is off by more than 10% then
699 kumaneko 327 --- linux-2.6.32-754.35.1.el6.orig/net/ipv4/raw.c
700     +++ linux-2.6.32-754.35.1.el6/net/ipv4/raw.c
701 kumaneko 93 @@ -77,6 +77,7 @@
702     #include <linux/seq_file.h>
703     #include <linux/netfilter.h>
704     #include <linux/netfilter_ipv4.h>
705     +#include <linux/ccsecurity.h>
706    
707     static struct raw_hashinfo raw_v4_hashinfo = {
708     .lock = __RW_LOCK_UNLOCKED(raw_v4_hashinfo.lock),
709 kumaneko 125 @@ -691,6 +692,10 @@ static int raw_recvmsg(struct kiocb *ioc
710 kumaneko 93 skb = skb_recv_datagram(sk, flags, noblock, &err);
711     if (!skb)
712     goto out;
713     + if (ccs_socket_post_recvmsg_permission(sk, skb, flags)) {
714     + err = -EAGAIN; /* Hope less harmful than -EPERM. */
715     + goto out;
716     + }
717    
718     copied = skb->len;
719     if (len < copied) {
720 kumaneko 327 --- linux-2.6.32-754.35.1.el6.orig/net/ipv4/udp.c
721     +++ linux-2.6.32-754.35.1.el6/net/ipv4/udp.c
722 kumaneko 131 @@ -108,6 +108,7 @@
723 kumaneko 93 #include <trace/events/udp.h>
724 kumaneko 131 #include <net/busy_poll.h>
725 kumaneko 93 #include "udp_impl.h"
726     +#include <linux/ccsecurity.h>
727    
728     struct udp_table udp_table;
729     EXPORT_SYMBOL(udp_table);
730 kumaneko 252 @@ -1002,6 +1003,10 @@ try_again:
731 kumaneko 93 &peeked, &err);
732     if (!skb)
733     goto out;
734     + if (ccs_socket_post_recvmsg_permission(sk, skb, flags)) {
735     + err = -EAGAIN; /* Hope less harmful than -EPERM. */
736     + goto out;
737     + }
738    
739     ulen = skb->len - sizeof(struct udphdr);
740     copied = len;
741 kumaneko 327 --- linux-2.6.32-754.35.1.el6.orig/net/ipv6/raw.c
742     +++ linux-2.6.32-754.35.1.el6/net/ipv6/raw.c
743 kumaneko 93 @@ -59,6 +59,7 @@
744    
745     #include <linux/proc_fs.h>
746     #include <linux/seq_file.h>
747     +#include <linux/ccsecurity.h>
748    
749     static struct raw_hashinfo raw_v6_hashinfo = {
750     .lock = __RW_LOCK_UNLOCKED(raw_v6_hashinfo.lock),
751 kumaneko 117 @@ -462,6 +463,10 @@ static int rawv6_recvmsg(struct kiocb *i
752 kumaneko 93 skb = skb_recv_datagram(sk, flags, noblock, &err);
753     if (!skb)
754     goto out;
755     + if (ccs_socket_post_recvmsg_permission(sk, skb, flags)) {
756     + err = -EAGAIN; /* Hope less harmful than -EPERM. */
757     + goto out;
758     + }
759    
760     copied = skb->len;
761     if (copied > len) {
762 kumaneko 327 --- linux-2.6.32-754.35.1.el6.orig/net/ipv6/udp.c
763     +++ linux-2.6.32-754.35.1.el6/net/ipv6/udp.c
764 kumaneko 131 @@ -50,6 +50,7 @@
765 kumaneko 93 #include <linux/proc_fs.h>
766     #include <linux/seq_file.h>
767     #include "udp_impl.h"
768     +#include <linux/ccsecurity.h>
769    
770     int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
771     {
772 kumaneko 131 @@ -230,6 +231,10 @@ try_again:
773 kumaneko 93 &peeked, &err);
774     if (!skb)
775     goto out;
776     + if (ccs_socket_post_recvmsg_permission(sk, skb, flags)) {
777     + err = -EAGAIN; /* Hope less harmful than -EPERM. */
778     + goto out;
779     + }
780    
781     ulen = skb->len - sizeof(struct udphdr);
782     copied = len;
783 kumaneko 327 --- linux-2.6.32-754.35.1.el6.orig/net/socket.c
784     +++ linux-2.6.32-754.35.1.el6/net/socket.c
785 kumaneko 267 @@ -579,6 +579,8 @@ static inline int __sock_sendmsg(struct
786 kumaneko 93 struct msghdr *msg, size_t size)
787     {
788     int err = security_socket_sendmsg(sock, msg, size);
789     + if (!err)
790     + err = ccs_socket_sendmsg_permission(sock, msg, size);
791    
792     return err ?: __sock_sendmsg_nosec(iocb, sock, msg, size);
793     }
794 kumaneko 267 @@ -1243,6 +1245,8 @@ int __sock_create(struct net *net, int f
795 kumaneko 93 }
796    
797     err = security_socket_create(family, type, protocol, kern);
798     + if (!err)
799     + err = ccs_socket_create_permission(family, type, protocol);
800     if (err)
801     return err;
802    
803 kumaneko 267 @@ -1472,6 +1476,11 @@ SYSCALL_DEFINE3(bind, int, fd, struct so
804 kumaneko 93 (struct sockaddr *)&address,
805     addrlen);
806     if (!err)
807     + err = ccs_socket_bind_permission(sock,
808     + (struct sockaddr *)
809     + &address,
810     + addrlen);
811     + if (!err)
812     err = sock->ops->bind(sock,
813     (struct sockaddr *)
814     &address, addrlen);
815 kumaneko 267 @@ -1501,6 +1510,8 @@ SYSCALL_DEFINE2(listen, int, fd, int, ba
816 kumaneko 93
817     err = security_socket_listen(sock, backlog);
818     if (!err)
819     + err = ccs_socket_listen_permission(sock);
820     + if (!err)
821     err = sock->ops->listen(sock, backlog);
822    
823     fput_light(sock->file, fput_needed);
824 kumaneko 267 @@ -1566,6 +1577,10 @@ SYSCALL_DEFINE4(accept4, int, fd, struct
825 kumaneko 93 if (err < 0)
826     goto out_fd;
827    
828     + if (ccs_socket_post_accept_permission(sock, newsock)) {
829     + err = -EAGAIN; /* Hope less harmful than -EPERM. */
830     + goto out_fd;
831     + }
832     if (upeer_sockaddr) {
833     if (newsock->ops->getname(newsock, (struct sockaddr *)&address,
834     &len, 2) < 0) {
835 kumaneko 267 @@ -1627,6 +1642,9 @@ SYSCALL_DEFINE3(connect, int, fd, struct
836 kumaneko 93
837     err =
838     security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
839     + if (!err)
840     + err = ccs_socket_connect_permission(sock, (struct sockaddr *)
841     + &address, addrlen);
842     if (err)
843     goto out_put;
844    
845 kumaneko 327 --- linux-2.6.32-754.35.1.el6.orig/net/unix/af_unix.c
846     +++ linux-2.6.32-754.35.1.el6/net/unix/af_unix.c
847 kumaneko 267 @@ -984,6 +984,9 @@ static int unix_bind(struct socket *sock
848 kumaneko 93 mode = S_IFSOCK |
849     (SOCK_INODE(sock)->i_mode & ~current_umask());
850     err = security_path_mknod(&nd.path, dentry, mode, 0);
851     + if (!err)
852     + err = ccs_mknod_permission(dentry, nd.path.mnt, mode,
853     + 0);
854     if (err)
855     goto out_mknod_dput;
856     err = vfs_mknod(nd.path.dentry->d_inode, dentry, mode, 0);
857 kumaneko 267 @@ -1951,6 +1954,10 @@ static int unix_dgram_recvmsg(struct kio
858 kumaneko 93
859     wake_up_interruptible_sync(&u->peer_wait);
860    
861     + if (ccs_socket_post_recvmsg_permission(sk, skb, flags)) {
862     + err = -EAGAIN; /* Hope less harmful than -EPERM. */
863     + goto out_unlock;
864     + }
865     if (msg->msg_name)
866     unix_copy_addr(msg, skb->sk);
867    
868 kumaneko 327 --- linux-2.6.32-754.35.1.el6.orig/security/Kconfig
869     +++ linux-2.6.32-754.35.1.el6/security/Kconfig
870 kumaneko 257 @@ -188,5 +188,7 @@ source security/tomoyo/Kconfig
871 kumaneko 93
872     source security/integrity/ima/Kconfig
873    
874     +source security/ccsecurity/Kconfig
875     +
876     endmenu
877    
878 kumaneko 327 --- linux-2.6.32-754.35.1.el6.orig/security/Makefile
879     +++ linux-2.6.32-754.35.1.el6/security/Makefile
880 kumaneko 93 @@ -25,3 +25,6 @@ obj-$(CONFIG_CGROUP_DEVICE) += device_c
881     # Object integrity file lists
882     subdir-$(CONFIG_IMA) += integrity/ima
883     obj-$(CONFIG_IMA) += integrity/ima/built-in.o
884     +
885     +subdir-$(CONFIG_CCSECURITY) += ccsecurity
886     +obj-$(CONFIG_CCSECURITY) += ccsecurity/built-in.o

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