12 |
arch/sparc/kernel/ptrace.c | 5 +++++ |
arch/sparc/kernel/ptrace.c | 5 +++++ |
13 |
arch/sparc64/kernel/ptrace.c | 5 +++++ |
arch/sparc64/kernel/ptrace.c | 5 +++++ |
14 |
arch/x86_64/ia32/ptrace32.c | 3 +++ |
arch/x86_64/ia32/ptrace32.c | 3 +++ |
|
fs/attr.c | 5 +++++ |
|
15 |
fs/compat.c | 9 ++++++++- |
fs/compat.c | 9 ++++++++- |
16 |
fs/exec.c | 12 +++++++++++- |
fs/exec.c | 12 +++++++++++- |
17 |
fs/fcntl.c | 5 +++++ |
fs/fcntl.c | 4 ++++ |
18 |
fs/ioctl.c | 5 +++++ |
fs/ioctl.c | 5 +++++ |
19 |
fs/namei.c | 38 ++++++++++++++++++++++++++++++++++++++ |
fs/namei.c | 34 ++++++++++++++++++++++++++++++++++ |
20 |
fs/namespace.c | 25 ++++++++++++++++++++++++- |
fs/namespace.c | 23 ++++++++++++++++++++++- |
21 |
fs/open.c | 30 +++++++++++++++++++++++++++++- |
fs/open.c | 31 ++++++++++++++++++++++++++++++- |
22 |
fs/proc/proc_misc.c | 1 + |
fs/proc/proc_misc.c | 1 + |
23 |
include/linux/init_task.h | 2 ++ |
include/linux/init_task.h | 9 +++++++++ |
24 |
include/linux/sched.h | 4 ++++ |
include/linux/sched.h | 6 ++++++ |
25 |
kernel/compat.c | 3 +++ |
kernel/compat.c | 3 +++ |
26 |
kernel/kexec.c | 3 +++ |
kernel/kexec.c | 3 +++ |
27 |
kernel/kmod.c | 3 +++ |
kernel/kmod.c | 5 +++++ |
28 |
kernel/module.c | 7 +++++-- |
kernel/module.c | 7 +++++-- |
29 |
kernel/ptrace.c | 3 +++ |
kernel/ptrace.c | 3 +++ |
30 |
kernel/sched.c | 3 +++ |
kernel/sched.c | 3 +++ |
43 |
net/unix/af_unix.c | 4 ++++ |
net/unix/af_unix.c | 4 ++++ |
44 |
security/Kconfig | 2 ++ |
security/Kconfig | 2 ++ |
45 |
security/Makefile | 3 +++ |
security/Makefile | 3 +++ |
46 |
42 files changed, 290 insertions(+), 11 deletions(-) |
41 files changed, 290 insertions(+), 11 deletions(-) |
47 |
|
|
48 |
--- linux-2.6.16-76.51vl4.orig/arch/alpha/kernel/ptrace.c |
--- linux-2.6.16-76.51vl4.orig/arch/alpha/kernel/ptrace.c |
49 |
+++ linux-2.6.16-76.51vl4/arch/alpha/kernel/ptrace.c |
+++ linux-2.6.16-76.51vl4/arch/alpha/kernel/ptrace.c |
239 |
|
|
240 |
switch (request) { |
switch (request) { |
241 |
default: |
default: |
|
--- linux-2.6.16-76.51vl4.orig/fs/attr.c |
|
|
+++ linux-2.6.16-76.51vl4/fs/attr.c |
|
|
@@ -15,6 +15,7 @@ |
|
|
#include <linux/fcntl.h> |
|
|
#include <linux/quotaops.h> |
|
|
#include <linux/security.h> |
|
|
+#include <linux/ccsecurity.h> |
|
|
|
|
|
/* Taken over from the old code... */ |
|
|
|
|
|
@@ -146,11 +147,15 @@ int notify_change(struct dentry * dentry |
|
|
if (inode->i_op && inode->i_op->setattr) { |
|
|
error = security_inode_setattr(dentry, attr); |
|
|
if (!error) |
|
|
+ error = ccs_check_setattr_permission(dentry, attr); |
|
|
+ if (!error) |
|
|
error = inode->i_op->setattr(dentry, attr); |
|
|
} else { |
|
|
error = inode_change_ok(inode, attr); |
|
|
if (!error) |
|
|
error = security_inode_setattr(dentry, attr); |
|
|
+ if (!error) |
|
|
+ error = ccs_check_setattr_permission(dentry, attr); |
|
|
if (!error) { |
|
|
if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) || |
|
|
(ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) |
|
242 |
--- linux-2.6.16-76.51vl4.orig/fs/compat.c |
--- linux-2.6.16-76.51vl4.orig/fs/compat.c |
243 |
+++ linux-2.6.16-76.51vl4/fs/compat.c |
+++ linux-2.6.16-76.51vl4/fs/compat.c |
244 |
@@ -52,6 +52,7 @@ |
@@ -52,6 +52,7 @@ |
293 |
if (error) |
if (error) |
294 |
goto exit; |
goto exit; |
295 |
|
|
296 |
+ error = ccs_check_uselib_permission(nd.dentry, nd.mnt); |
+ error = ccs_uselib_permission(nd.dentry, nd.mnt); |
297 |
+ if (error) |
+ if (error) |
298 |
+ goto exit; |
+ goto exit; |
299 |
+ |
+ |
305 |
if (!err && !(inode->i_mode & 0111)) |
if (!err && !(inode->i_mode & 0111)) |
306 |
err = -EACCES; |
err = -EACCES; |
307 |
+ if (!err) |
+ if (!err) |
308 |
+ err = ccs_check_open_exec_permission(nd.dentry, |
+ err = ccs_open_exec_permission(nd.dentry, |
309 |
+ nd.mnt); |
+ nd.mnt); |
310 |
file = ERR_PTR(err); |
file = ERR_PTR(err); |
311 |
if (!err) { |
if (!err) { |
330 |
|
|
331 |
void fastcall set_close_on_exec(unsigned int fd, int flag) |
void fastcall set_close_on_exec(unsigned int fd, int flag) |
332 |
{ |
{ |
333 |
@@ -215,6 +216,10 @@ static int setfl(int fd, struct file * f |
@@ -215,6 +216,9 @@ static int setfl(int fd, struct file * f |
334 |
if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode)) |
if (((arg ^ filp->f_flags) & O_APPEND) && IS_APPEND(inode)) |
335 |
return -EPERM; |
return -EPERM; |
336 |
|
|
337 |
+ if (((arg ^ filp->f_flags) & O_APPEND) && |
+ if (((arg ^ filp->f_flags) & O_APPEND) && ccs_rewrite_permission(filp)) |
|
+ ccs_check_rewrite_permission(filp)) |
|
338 |
+ return -EPERM; |
+ return -EPERM; |
339 |
+ |
+ |
340 |
/* O_NOATIME can only be set by the owner or superuser */ |
/* O_NOATIME can only be set by the owner or superuser */ |
364 |
|
|
365 |
error = security_file_ioctl(filp, cmd, arg); |
error = security_file_ioctl(filp, cmd, arg); |
366 |
+ if (!error) |
+ if (!error) |
367 |
+ error = ccs_check_ioctl_permission(filp, cmd, arg); |
+ error = ccs_ioctl_permission(filp, cmd, arg); |
368 |
if (error) |
if (error) |
369 |
goto out_fput; |
goto out_fput; |
370 |
|
|
384 |
return -EPERM; |
return -EPERM; |
385 |
|
|
386 |
+ /* includes O_APPEND and O_TRUNC checks */ |
+ /* includes O_APPEND and O_TRUNC checks */ |
387 |
+ error = ccs_check_open_permission(dentry, nd->mnt, flag); |
+ error = ccs_open_permission(dentry, nd->mnt, flag); |
388 |
+ if (error) |
+ if (error) |
389 |
+ return error; |
+ return error; |
390 |
+ |
+ |
403 |
if (!path.dentry->d_inode) { |
if (!path.dentry->d_inode) { |
404 |
if (!IS_POSIXACL(dir->d_inode)) |
if (!IS_POSIXACL(dir->d_inode)) |
405 |
mode &= ~current->fs->umask; |
mode &= ~current->fs->umask; |
406 |
+ error = ccs_check_mknod_permission(dir->d_inode, path.dentry, |
+ error = ccs_mknod_permission(dir->d_inode, path.dentry, |
407 |
+ nd->mnt, mode, 0); |
+ nd->mnt, mode, 0); |
408 |
+ if (!error) |
+ if (!error) |
409 |
error = vfs_create(dir->d_inode, path.dentry, mode, nd); |
error = vfs_create(dir->d_inode, path.dentry, mode, nd); |
410 |
mutex_unlock(&dir->d_inode->i_mutex); |
mutex_unlock(&dir->d_inode->i_mutex); |
411 |
dput(nd->dentry); |
dput(nd->dentry); |
412 |
@@ -1847,6 +1858,10 @@ asmlinkage long sys_mknodat(int dfd, con |
@@ -1847,6 +1858,9 @@ asmlinkage long sys_mknodat(int dfd, con |
413 |
if (!IS_POSIXACL(nd.dentry->d_inode)) |
if (!IS_POSIXACL(nd.dentry->d_inode)) |
414 |
mode &= ~current->fs->umask; |
mode &= ~current->fs->umask; |
415 |
if (!IS_ERR(dentry)) { |
if (!IS_ERR(dentry)) { |
416 |
+ error = ccs_check_mknod_permission(nd.dentry->d_inode, dentry, |
+ error = ccs_mknod_permission(nd.dentry->d_inode, dentry, |
417 |
+ nd.mnt, mode, |
+ nd.mnt, mode, dev); |
|
+ new_decode_dev(dev)); |
|
418 |
+ if (!error) |
+ if (!error) |
419 |
switch (mode & S_IFMT) { |
switch (mode & S_IFMT) { |
420 |
case 0: case S_IFREG: |
case 0: case S_IFREG: |
421 |
error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd); |
error = vfs_create(nd.dentry->d_inode,dentry,mode,&nd); |
422 |
@@ -1920,6 +1935,10 @@ asmlinkage long sys_mkdirat(int dfd, con |
@@ -1920,6 +1934,9 @@ asmlinkage long sys_mkdirat(int dfd, con |
423 |
if (!IS_ERR(dentry)) { |
if (!IS_ERR(dentry)) { |
424 |
if (!IS_POSIXACL(nd.dentry->d_inode)) |
if (!IS_POSIXACL(nd.dentry->d_inode)) |
425 |
mode &= ~current->fs->umask; |
mode &= ~current->fs->umask; |
426 |
+ error = ccs_check_mkdir_permission(nd.dentry->d_inode, |
+ error = ccs_mkdir_permission(nd.dentry->d_inode, |
427 |
+ dentry, nd.mnt, |
+ dentry, nd.mnt, mode); |
|
+ mode); |
|
428 |
+ if (!error) |
+ if (!error) |
429 |
error = vfs_mkdir(nd.dentry->d_inode, dentry, mode); |
error = vfs_mkdir(nd.dentry->d_inode, dentry, mode); |
430 |
dput(dentry); |
dput(dentry); |
431 |
} |
} |
432 |
@@ -2028,6 +2047,9 @@ static long do_rmdir(int dfd, const char |
@@ -2028,6 +2045,9 @@ static long do_rmdir(int dfd, const char |
433 |
dentry = lookup_hash(&nd); |
dentry = lookup_hash(&nd); |
434 |
error = PTR_ERR(dentry); |
error = PTR_ERR(dentry); |
435 |
if (!IS_ERR(dentry)) { |
if (!IS_ERR(dentry)) { |
436 |
+ error = ccs_check_rmdir_permission(nd.dentry->d_inode, dentry, |
+ error = ccs_rmdir_permission(nd.dentry->d_inode, dentry, |
437 |
+ nd.mnt); |
+ nd.mnt); |
438 |
+ if (!error) |
+ if (!error) |
439 |
error = vfs_rmdir(nd.dentry->d_inode, dentry); |
error = vfs_rmdir(nd.dentry->d_inode, dentry); |
440 |
dput(dentry); |
dput(dentry); |
441 |
} |
} |
442 |
@@ -2108,6 +2130,9 @@ static long do_unlinkat(int dfd, const c |
@@ -2108,6 +2128,9 @@ static long do_unlinkat(int dfd, const c |
443 |
inode = dentry->d_inode; |
inode = dentry->d_inode; |
444 |
if (inode) |
if (inode) |
445 |
atomic_inc(&inode->i_count); |
atomic_inc(&inode->i_count); |
446 |
+ error = ccs_check_unlink_permission(nd.dentry->d_inode, dentry, |
+ error = ccs_unlink_permission(nd.dentry->d_inode, dentry, |
447 |
+ nd.mnt); |
+ nd.mnt); |
448 |
+ if (!error) |
+ if (!error) |
449 |
error = vfs_unlink(nd.dentry->d_inode, dentry); |
error = vfs_unlink(nd.dentry->d_inode, dentry); |
450 |
exit2: |
exit2: |
451 |
dput(dentry); |
dput(dentry); |
452 |
@@ -2186,6 +2211,10 @@ asmlinkage long sys_symlinkat(const char |
@@ -2186,6 +2209,9 @@ asmlinkage long sys_symlinkat(const char |
453 |
dentry = lookup_create(&nd, 0); |
dentry = lookup_create(&nd, 0); |
454 |
error = PTR_ERR(dentry); |
error = PTR_ERR(dentry); |
455 |
if (!IS_ERR(dentry)) { |
if (!IS_ERR(dentry)) { |
456 |
+ error = ccs_check_symlink_permission(nd.dentry->d_inode, |
+ error = ccs_symlink_permission(nd.dentry->d_inode, |
457 |
+ dentry, nd.mnt, |
+ dentry, nd.mnt, from); |
|
+ from); |
|
458 |
+ if (!error) |
+ if (!error) |
459 |
error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO); |
error = vfs_symlink(nd.dentry->d_inode, dentry, from, S_IALLUGO); |
460 |
dput(dentry); |
dput(dentry); |
461 |
} |
} |
462 |
@@ -2278,6 +2307,10 @@ asmlinkage long sys_linkat(int olddfd, c |
@@ -2278,6 +2304,9 @@ asmlinkage long sys_linkat(int olddfd, c |
463 |
new_dentry = lookup_create(&nd, 0); |
new_dentry = lookup_create(&nd, 0); |
464 |
error = PTR_ERR(new_dentry); |
error = PTR_ERR(new_dentry); |
465 |
if (!IS_ERR(new_dentry)) { |
if (!IS_ERR(new_dentry)) { |
466 |
+ error = ccs_check_link_permission(old_nd.dentry, |
+ error = ccs_link_permission(old_nd.dentry, nd.dentry->d_inode, |
467 |
+ nd.dentry->d_inode, |
+ new_dentry, nd.mnt); |
|
+ new_dentry, nd.mnt); |
|
468 |
+ if (!error) |
+ if (!error) |
469 |
error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry); |
error = vfs_link(old_nd.dentry, nd.dentry->d_inode, new_dentry); |
470 |
dput(new_dentry); |
dput(new_dentry); |
471 |
} |
} |
472 |
@@ -2504,6 +2537,11 @@ static int do_rename(int olddfd, const c |
@@ -2504,6 +2533,11 @@ static int do_rename(int olddfd, const c |
473 |
if (new_dentry == trap) |
if (new_dentry == trap) |
474 |
goto exit5; |
goto exit5; |
475 |
|
|
476 |
+ error = ccs_check_rename_permission(old_dir->d_inode, old_dentry, |
+ error = ccs_rename_permission(old_dir->d_inode, old_dentry, |
477 |
+ new_dir->d_inode, new_dentry, |
+ new_dir->d_inode, new_dentry, newnd.mnt); |
478 |
+ newnd.mnt); |
+ if (error) |
479 |
+ if (!error) |
+ goto exit5; |
480 |
+ |
+ |
481 |
error = vfs_rename(old_dir->d_inode, old_dentry, |
error = vfs_rename(old_dir->d_inode, old_dentry, |
482 |
new_dir->d_inode, new_dentry); |
new_dir->d_inode, new_dentry); |
491 |
|
|
492 |
extern int __init init_rootfs(void); |
extern int __init init_rootfs(void); |
493 |
|
|
494 |
@@ -509,6 +510,9 @@ static int do_umount(struct vfsmount *mn |
@@ -506,6 +507,8 @@ static int do_umount(struct vfsmount *mn |
495 |
|
LIST_HEAD(umount_list); |
496 |
|
|
497 |
|
retval = security_sb_umount(mnt, flags); |
498 |
|
+ if (!retval) |
499 |
|
+ retval = ccs_umount_permission(mnt, flags); |
500 |
if (retval) |
if (retval) |
501 |
return retval; |
return retval; |
502 |
|
|
503 |
+ if (ccs_may_umount(mnt)) |
@@ -597,6 +600,8 @@ asmlinkage long sys_umount(char __user * |
|
+ return -EPERM; |
|
|
+ |
|
|
/* |
|
|
* Allow userspace to request a mountpoint be expired rather than |
|
|
* unmounting unconditionally. Unmount only happens if: |
|
|
@@ -597,6 +601,8 @@ asmlinkage long sys_umount(char __user * |
|
504 |
{ |
{ |
505 |
struct nameidata nd; |
struct nameidata nd; |
506 |
int retval; |
int retval; |
509 |
|
|
510 |
retval = __user_walk(name, LOOKUP_FOLLOW, &nd); |
retval = __user_walk(name, LOOKUP_FOLLOW, &nd); |
511 |
if (retval) |
if (retval) |
512 |
@@ -884,6 +890,9 @@ static int do_loopback(struct nameidata |
@@ -884,6 +889,9 @@ static int do_loopback(struct nameidata |
513 |
|
|
514 |
if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt)) |
if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt)) |
515 |
goto out; |
goto out; |
519 |
|
|
520 |
err = -ENOMEM; |
err = -ENOMEM; |
521 |
if (recurse) |
if (recurse) |
522 |
@@ -968,7 +977,9 @@ static int do_move_mount(struct nameidat |
@@ -968,7 +976,9 @@ static int do_move_mount(struct nameidat |
523 |
err = -EINVAL; |
err = -EINVAL; |
524 |
if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt)) |
if (!check_mnt(nd->mnt) || !check_mnt(old_nd.mnt)) |
525 |
goto out; |
goto out; |
526 |
- |
- |
527 |
+ err = -EPERM; |
+ err = -EPERM; |
528 |
+ if (ccs_may_umount(old_nd.mnt) || ccs_may_mount(nd)) |
+ if (ccs_may_mount(nd)) |
529 |
+ goto out; |
+ goto out; |
530 |
err = -ENOENT; |
err = -ENOENT; |
531 |
mutex_lock(&nd->dentry->d_inode->i_mutex); |
mutex_lock(&nd->dentry->d_inode->i_mutex); |
532 |
if (IS_DEADDIR(nd->dentry->d_inode)) |
if (IS_DEADDIR(nd->dentry->d_inode)) |
533 |
@@ -1070,6 +1081,9 @@ int do_add_mount(struct vfsmount *newmnt |
@@ -1070,6 +1080,9 @@ int do_add_mount(struct vfsmount *newmnt |
534 |
err = -EINVAL; |
err = -EINVAL; |
535 |
if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode)) |
if (S_ISLNK(newmnt->mnt_root->d_inode->i_mode)) |
536 |
goto unlock; |
goto unlock; |
540 |
|
|
541 |
newmnt->mnt_flags = mnt_flags; |
newmnt->mnt_flags = mnt_flags; |
542 |
if ((err = graft_tree(newmnt, nd))) |
if ((err = graft_tree(newmnt, nd))) |
543 |
@@ -1287,6 +1301,11 @@ long do_mount(char *dev_name, char *dir_ |
@@ -1269,6 +1282,7 @@ int copy_mount_options(const void __user |
544 |
if (data_page) |
long do_mount(char *dev_name, char *dir_name, char *type_page, |
545 |
((char *)data_page)[PAGE_SIZE - 1] = 0; |
unsigned long flags, void *data_page) |
546 |
|
{ |
547 |
+ retval = ccs_check_mount_permission(dev_name, dir_name, type_page, |
+ const unsigned long original_flags = flags; |
548 |
+ &flags); |
struct nameidata nd; |
549 |
+ if (retval) |
int retval = 0; |
550 |
+ return retval; |
int mnt_flags = 0; |
551 |
+ |
@@ -1308,6 +1322,9 @@ long do_mount(char *dev_name, char *dir_ |
552 |
/* Separate the per-mountpoint flags */ |
return retval; |
553 |
if (flags & MS_NOSUID) |
|
554 |
mnt_flags |= MNT_NOSUID; |
retval = security_sb_mount(dev_name, &nd, type_page, flags, data_page); |
555 |
@@ -1585,6 +1604,8 @@ asmlinkage long sys_pivot_root(const cha |
+ if (!retval) |
556 |
|
+ retval = ccs_mount_permission(dev_name, &nd, type_page, |
557 |
|
+ original_flags, data_page); |
558 |
|
if (retval) |
559 |
|
goto dput_out; |
560 |
|
|
561 |
|
@@ -1585,6 +1602,8 @@ asmlinkage long sys_pivot_root(const cha |
562 |
|
|
563 |
if (!capable(CAP_SYS_ADMIN)) |
if (!capable(CAP_SYS_ADMIN)) |
564 |
return -EPERM; |
return -EPERM; |
567 |
|
|
568 |
lock_kernel(); |
lock_kernel(); |
569 |
|
|
570 |
@@ -1601,6 +1622,8 @@ asmlinkage long sys_pivot_root(const cha |
@@ -1601,6 +1620,8 @@ asmlinkage long sys_pivot_root(const cha |
571 |
goto out1; |
goto out1; |
572 |
|
|
573 |
error = security_sb_pivotroot(&old_nd, &new_nd); |
error = security_sb_pivotroot(&old_nd, &new_nd); |
574 |
+ if (!error) |
+ if (!error) |
575 |
+ error = ccs_check_pivot_root_permission(&old_nd, &new_nd); |
+ error = ccs_pivot_root_permission(&old_nd, &new_nd); |
576 |
if (error) { |
if (error) { |
577 |
path_release(&old_nd); |
path_release(&old_nd); |
578 |
goto out1; |
goto out1; |
591 |
if (error) |
if (error) |
592 |
goto dput_and_out; |
goto dput_and_out; |
593 |
|
|
594 |
+ error = ccs_check_truncate_permission(nd.dentry, nd.mnt, length, 0); |
+ error = ccs_truncate_permission(nd.dentry, nd.mnt, length, 0); |
595 |
+ if (!error) |
+ if (!error) |
596 |
error = locks_verify_truncate(inode, NULL, length); |
error = locks_verify_truncate(inode, NULL, length); |
597 |
if (!error) { |
if (!error) { |
598 |
DQUOT_INIT(inode); |
DQUOT_INIT(inode); |
599 |
@@ -321,7 +325,10 @@ static long do_sys_ftruncate(unsigned in |
@@ -321,7 +325,9 @@ static long do_sys_ftruncate(unsigned in |
600 |
error = -EPERM; |
error = -EPERM; |
601 |
if (IS_APPEND(inode)) |
if (IS_APPEND(inode)) |
602 |
goto out_putf; |
goto out_putf; |
603 |
- |
- |
604 |
+ error = ccs_check_truncate_permission(dentry, file->f_vfsmnt, length, |
+ error = ccs_truncate_permission(dentry, file->f_vfsmnt, length, 0); |
|
+ 0); |
|
605 |
+ if (error) |
+ if (error) |
606 |
+ goto out_putf; |
+ goto out_putf; |
607 |
error = locks_verify_truncate(inode, file, length); |
error = locks_verify_truncate(inode, file, length); |
608 |
if (!error) |
if (!error) |
609 |
error = do_truncate(dentry, length, 0, file); |
error = do_truncate(dentry, length, 0, file); |
610 |
@@ -610,6 +617,10 @@ asmlinkage long sys_chroot(const char __ |
@@ -610,6 +616,10 @@ asmlinkage long sys_chroot(const char __ |
611 |
error = -EPERM; |
error = -EPERM; |
612 |
if (!capable(CAP_SYS_CHROOT)) |
if (!capable(CAP_SYS_CHROOT)) |
613 |
goto dput_and_out; |
goto dput_and_out; |
614 |
+ if (!ccs_capable(CCS_SYS_CHROOT)) |
+ if (!ccs_capable(CCS_SYS_CHROOT)) |
615 |
+ goto dput_and_out; |
+ goto dput_and_out; |
616 |
+ if (ccs_check_chroot_permission(&nd)) |
+ if (ccs_chroot_permission(&nd)) |
617 |
+ goto dput_and_out; |
+ goto dput_and_out; |
618 |
|
|
619 |
set_fs_root(current->fs, nd.mnt, nd.dentry); |
set_fs_root(current->fs, nd.mnt, nd.dentry); |
620 |
set_fs_altroot(); |
set_fs_altroot(); |
621 |
@@ -641,6 +652,9 @@ asmlinkage long sys_fchmod(unsigned int |
@@ -641,6 +651,9 @@ asmlinkage long sys_fchmod(unsigned int |
622 |
err = -EPERM; |
err = -EPERM; |
623 |
if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) |
if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) |
624 |
goto out_putf; |
goto out_putf; |
628 |
mutex_lock(&inode->i_mutex); |
mutex_lock(&inode->i_mutex); |
629 |
if (mode == (mode_t) -1) |
if (mode == (mode_t) -1) |
630 |
mode = inode->i_mode; |
mode = inode->i_mode; |
631 |
@@ -675,6 +689,9 @@ asmlinkage long sys_fchmodat(int dfd, co |
@@ -675,6 +688,9 @@ asmlinkage long sys_fchmodat(int dfd, co |
632 |
error = -EPERM; |
error = -EPERM; |
633 |
if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) |
if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) |
634 |
goto dput_and_out; |
goto dput_and_out; |
638 |
|
|
639 |
mutex_lock(&inode->i_mutex); |
mutex_lock(&inode->i_mutex); |
640 |
if (mode == (mode_t) -1) |
if (mode == (mode_t) -1) |
641 |
@@ -737,6 +754,8 @@ asmlinkage long sys_chown(const char __u |
@@ -737,6 +753,8 @@ asmlinkage long sys_chown(const char __u |
642 |
|
|
643 |
error = user_path_walk(filename, &nd); |
error = user_path_walk(filename, &nd); |
644 |
if (!error) { |
if (!error) { |
647 |
error = chown_common(nd.dentry, user, group); |
error = chown_common(nd.dentry, user, group); |
648 |
path_release(&nd); |
path_release(&nd); |
649 |
} |
} |
650 |
@@ -756,6 +775,8 @@ asmlinkage long sys_fchownat(int dfd, co |
@@ -756,6 +774,8 @@ asmlinkage long sys_fchownat(int dfd, co |
651 |
follow = (flag & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW; |
follow = (flag & AT_SYMLINK_NOFOLLOW) ? 0 : LOOKUP_FOLLOW; |
652 |
error = __user_walk_fd(dfd, filename, follow, &nd); |
error = __user_walk_fd(dfd, filename, follow, &nd); |
653 |
if (!error) { |
if (!error) { |
656 |
error = chown_common(nd.dentry, user, group); |
error = chown_common(nd.dentry, user, group); |
657 |
path_release(&nd); |
path_release(&nd); |
658 |
} |
} |
659 |
@@ -770,6 +791,8 @@ asmlinkage long sys_lchown(const char __ |
@@ -770,6 +790,8 @@ asmlinkage long sys_lchown(const char __ |
660 |
|
|
661 |
error = user_path_walk_link(filename, &nd); |
error = user_path_walk_link(filename, &nd); |
662 |
if (!error) { |
if (!error) { |
665 |
error = chown_common(nd.dentry, user, group); |
error = chown_common(nd.dentry, user, group); |
666 |
path_release(&nd); |
path_release(&nd); |
667 |
} |
} |
668 |
@@ -784,6 +807,9 @@ asmlinkage long sys_fchown(unsigned int |
@@ -784,6 +806,9 @@ asmlinkage long sys_fchown(unsigned int |
669 |
|
|
670 |
file = fget(fd); |
file = fget(fd); |
671 |
if (file) { |
if (file) { |
675 |
error = chown_common(file->f_dentry, user, group); |
error = chown_common(file->f_dentry, user, group); |
676 |
fput(file); |
fput(file); |
677 |
} |
} |
678 |
@@ -1192,6 +1218,8 @@ EXPORT_SYMBOL(sys_close); |
@@ -876,7 +901,9 @@ static struct file *do_filp_open(int dfd |
679 |
|
if ((namei_flags+1) & O_ACCMODE) |
680 |
|
namei_flags++; |
681 |
|
|
682 |
|
+ ccs_save_open_mode(flags); |
683 |
|
error = open_namei(dfd, filename, namei_flags, mode, &nd); |
684 |
|
+ ccs_clear_open_mode(); |
685 |
|
if (!error) |
686 |
|
return nameidata_to_filp(&nd, flags); |
687 |
|
|
688 |
|
@@ -1192,6 +1219,8 @@ EXPORT_SYMBOL(sys_close); |
689 |
*/ |
*/ |
690 |
asmlinkage long sys_vhangup(void) |
asmlinkage long sys_vhangup(void) |
691 |
{ |
{ |
700 |
if (entry) |
if (entry) |
701 |
entry->proc_fops = &proc_sysrq_trigger_operations; |
entry->proc_fops = &proc_sysrq_trigger_operations; |
702 |
#endif |
#endif |
703 |
+ printk(KERN_INFO "Hook version: 2.6.16-76.51vl4 2009/08/09\n"); |
+ printk(KERN_INFO "Hook version: 2.6.16-76.51vl4 2009/09/24\n"); |
704 |
} |
} |
705 |
--- linux-2.6.16-76.51vl4.orig/include/linux/init_task.h |
--- linux-2.6.16-76.51vl4.orig/include/linux/init_task.h |
706 |
+++ linux-2.6.16-76.51vl4/include/linux/init_task.h |
+++ linux-2.6.16-76.51vl4/include/linux/init_task.h |
707 |
@@ -121,6 +121,8 @@ extern struct group_info init_groups; |
@@ -72,6 +72,14 @@ |
708 |
|
|
709 |
|
extern struct group_info init_groups; |
710 |
|
|
711 |
|
+#ifdef CONFIG_CCSECURITY |
712 |
|
+#define INIT_CCSECURITY \ |
713 |
|
+ .ccs_domain_info = NULL, \ |
714 |
|
+ .ccs_flags = 0, |
715 |
|
+#else |
716 |
|
+#define INIT_CCSECURITY |
717 |
|
+#endif |
718 |
|
+ |
719 |
|
/* |
720 |
|
* INIT_TASK is used to set up the first task table, touch at |
721 |
|
* your own risk!. Base=0, limit=0x1fffff (=2MB) |
722 |
|
@@ -121,6 +129,7 @@ extern struct group_info init_groups; |
723 |
.journal_info = NULL, \ |
.journal_info = NULL, \ |
724 |
.cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \ |
.cpu_timers = INIT_CPU_TIMERS(tsk.cpu_timers), \ |
725 |
.fs_excl = ATOMIC_INIT(0), \ |
.fs_excl = ATOMIC_INIT(0), \ |
726 |
+ .ccs_domain_info = NULL, \ |
+ INIT_CCSECURITY \ |
|
+ .ccs_flags = 0, \ |
|
727 |
} |
} |
728 |
|
|
729 |
|
|
738 |
/* |
/* |
739 |
* cloning flags: |
* cloning flags: |
740 |
*/ |
*/ |
741 |
@@ -873,6 +875,8 @@ struct task_struct { |
@@ -873,6 +875,10 @@ struct task_struct { |
742 |
struct rcu_head rcu; |
struct rcu_head rcu; |
743 |
|
|
744 |
struct list_head *scm_work_list; |
struct list_head *scm_work_list; |
745 |
|
+#ifdef CONFIG_CCSECURITY |
746 |
+ struct ccs_domain_info *ccs_domain_info; |
+ struct ccs_domain_info *ccs_domain_info; |
747 |
+ u32 ccs_flags; |
+ u32 ccs_flags; |
748 |
|
+#endif |
749 |
}; |
}; |
750 |
|
|
751 |
static inline pid_t process_group(struct task_struct *tsk) |
static inline pid_t process_group(struct task_struct *tsk) |
789 |
* Verify we have a legal set of flags |
* Verify we have a legal set of flags |
790 |
--- linux-2.6.16-76.51vl4.orig/kernel/kmod.c |
--- linux-2.6.16-76.51vl4.orig/kernel/kmod.c |
791 |
+++ linux-2.6.16-76.51vl4/kernel/kmod.c |
+++ linux-2.6.16-76.51vl4/kernel/kmod.c |
792 |
@@ -150,6 +150,9 @@ static int ____call_usermodehelper(void |
@@ -150,6 +150,11 @@ static int ____call_usermodehelper(void |
793 |
/* We can run anywhere, unlike our parent keventd(). */ |
/* We can run anywhere, unlike our parent keventd(). */ |
794 |
set_cpus_allowed(current, CPU_MASK_ALL); |
set_cpus_allowed(current, CPU_MASK_ALL); |
795 |
|
|
796 |
|
+#ifdef CONFIG_CCSECURITY |
797 |
+ current->ccs_domain_info = NULL; |
+ current->ccs_domain_info = NULL; |
798 |
+ current->ccs_flags = 0; |
+ current->ccs_flags = 0; |
799 |
|
+#endif |
800 |
+ |
+ |
801 |
retval = -EPERM; |
retval = -EPERM; |
802 |
if (current->fs->root) |
if (current->fs->root) |
1312 |
*/ |
*/ |
1313 |
mode = S_IFSOCK | |
mode = S_IFSOCK | |
1314 |
(SOCK_INODE(sock)->i_mode & ~current->fs->umask); |
(SOCK_INODE(sock)->i_mode & ~current->fs->umask); |
1315 |
+ err = ccs_check_mknod_permission(nd.dentry->d_inode, dentry, |
+ err = ccs_mknod_permission(nd.dentry->d_inode, dentry, nd.mnt, |
1316 |
+ nd.mnt, mode, 0); |
+ mode, 0); |
1317 |
+ if (!err) |
+ if (!err) |
1318 |
err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0); |
err = vfs_mknod(nd.dentry->d_inode, dentry, mode, 0); |
1319 |
if (err) |
if (err) |