--- trunk/1.7.x/ccs-patch/README.ccs 2009/11/06 08:49:37 3149 +++ branches/ccs-patch/README.ccs 2010/07/29 13:29:11 3869 @@ -2088,7 +2088,7 @@ @ Transit to new domain before do_execve() succeeds. Permission checks for interpreters and environment variables are - done using new domain. In order to be allow ccs-queryd to reach the new + done using new domain. In order to allow ccs-queryd to reach the new domain via global PID, I reverted "Don't transit to new domain until do_execve() succeeds." made on 2008/10/07. @@ -2234,3 +2234,354 @@ Audit log for allow_mount was using decimal format. It needs to use hexadecimal format. + +Fix 2009/11/09 + + @ Add profile version check. + + To avoid upgrading from TOMOYO 1.6.x to TOMOYO 1.7.x without upgrading + /proc/ccs/profile (which results in not protecting the system at all), + I added a check for PROFILE_VERSION= . + +Version 1.7.1 2009/11/11 Fourth anniversary release. + +Fix 2009/11/13 + + @ Don't use core_initcall() for initializing lock for GC. + + Some kernels call TOMOYO's hooks before processing core_initcall(). + Thus, I can't use core_initcall() for initializing lock for GC. + +Fix 2009/11/18 + + @ Don't check "allow_write" permission for open(O_RDONLY | O_TRUNC). + + Since TOMOYO checks "allow_truncate" permission rather than "allow_write" + permission for O_TRUNC, I need to distinguish open(O_RDONLY | O_TRUNC) + and open(O_RDWR | O_TRUNC). But I made a mistake between TOMOYO 1.7.0 and + 1.7.1 which made it impossible for TOMOYO for kernels 2.6.14 and earlier + to distinguish them. + +Fix 2009/11/27 + + @ Use newly created domain's name for domain creation audit log. + + Since 1.7.0 , /proc/ccs/reject_log was by error using existing domain's + name when auditing newly created domain's "use_profile" line. + +Fix 2009/12/12 + + @ Use rcu_read_lock() for find_task_by_pid(). + + Since kernel 2.6.18 , caller of find_task_by_pid() needs to call + rcu_read_lock() rather than read_lock(&tasklist_lock) because find_pid() + uses RCU primitives but spinlock does not prevent RCU callback if + preemptive RCU ( CONFIG_PREEMPT_RCU or CONFIG_TREE_PREEMPT_RCU ) is + enabled. + +Fix 2009/12/15 + + @ Allow deleting "quota_exceeded" and "transition_failed" entries. + + To notify users of "this domain has too many entries to hold" and "some + process in this domain was not able to perform domain transition", + "quota_exceeded" and "transition_failed" messages are used respectively. + These messages were not deletable. But it is more convenient for users + to be notified again if such events occurred again after tuning policy. + Thus, I made these messages deletable. + +Fix 2009/12/17 + + @ Don't check read permission in ccs_try_alt_exec(). + + While I was trying to remove ccs_execve_list list for GC optimization + between TOMOYO 1.7.0 and 1.7.1 , I made a mistake which made TOMOYO to + check allow_read permission of the programs specified by execute_handler + and denied_execute_handler keywords. + + @ Don't check DAC permission if disabled mode. + + I was checking DAC permissions regarding directory entry modification + operations (e.g. mkdir()) even if mode=disabled . It is a waste of CPU + resource to check DAC permissions when MAC permissions are not checked. + Thus, I modified to skip DAC permission checks if mode=disabled . + +Fix 2009/12/19 + + @ Fix memory leak in ccs_environ(). + + When I fixed a bug that a permission like + + allow_env PATH if exec.envp["PATH"]="/" + + was not working (2009/11/02), I allocated two buffers but only one buffer + was released. + + This bug will trigger OOM killer if environment variable checking is + enabled. + +Fix 2010/01/17 + + @ Use current domain's name for execute_handler audit log. + + Since 1.6.7 , /proc/ccs/grant_log was by error using next domain's name + when auditing current domain's "execute_handler" line. + +Fix 2010/03/02 + + @ Allow domain transition without execve(). + + To be able to split permissions for Apache's CGI programs which are + executed without execve(), I added special domain transition which is + performed by atomically writing '\0'-terminated binary string to + /proc/ccs/.transition interface. For example, a process which belongs to + " /usr/sbin/httpd" domain will transit to + " /usr/sbin/httpd //app=cgi1\040id=10000" domain by atomically + writing "app=cgi1 id=10000" + '\0' to /proc/ccs/.transition using + Apache's ap_hook_handler() functionality. + + Note that '\0'-terminated binary string is converted to TOMOYO's string + inside kernel and prefix "//" is automatically added to the string so + that domainname does not conflict with domainnames created by execve(). + Without this prefix, if " /usr/sbin/sshd /bin/bash" domain is + allowed to open /proc/ccs/.transition for writing and + " /usr/sbin/sshd /bin/bash /usr/bin/passwd" domain is allowed to + access /etc/shadow , /bin/bash will be able to access /etc/shadow by + atomically writing "/usr/bin/passwd" + '\0' to /proc/ccs/.transition . + Allowing /bin/bash to access /etc/shadow is not what people want. + + Permission for this operation is checked by "allow_transit" keyword. + Unlike "allow_execute" keyword, the string parameter for "allow_transit" + keyword does not refer a real file on filesystem's namespace. Therefore, + you can store any combination of parameters like LDAP's DN entry in the + string parameter for "allow_transit" keyword. + +Fix 2010/03/08 + + @ Allow building as loadable kernel module. + + To be able to minimize filesize increment of vmlinux, I made it + possible to compile TOMOYO Linux as loadable kernel module. + Although patching the kernel source and recompiling the kernel are + inevitable, this change will make it easier to enable TOMOYO Linux + when there is a filesize limitation on vmlinux (e.g. embedded systems). + +Fix 2010/03/25 + + @ Fix ccs_get_ipv6_address() bug. + + Since 1.7.0 , ccs_get_ipv6_address() was by error returning address of + "struct list_head ccs_address_list" if memory allocation failed. + As a result, ccs_put_ipv6_address() will modify memory near + "struct list_head ccs_address_list" if memory allocation failed. + +Fix 2010/03/26 + + @ Fix ccs_lport_reserved() bug. + + Since 1.7.0 , ccs_lport_reserved() was by error checking wrong port + number. As a result, "deny_autobind" keyword was not working as expected. + +Version 1.7.2 2010/04/01 Feature enhancement release. + +Fix 2010/04/10 + + @ Fix invalid "struct nameidata" to "struct path" conversion macro. + + Regarding kernels 2.6.24 and earlier, I was converting "struct nameidata" + to "struct path" in caller side so that I can unify the callee function's + parameter type. But it turned out that the macro I used did not follow C + standards and did not work with gcc 4.x . As a result, "allow_pivot_root" + keyword was not working as expected. + +Fix 2010/05/05 + + @ Fix incorrect audit on/off control. + + The grant_log= and reject_log= parameters of CONFIG::misc::env were not + used because I forgot to update request type. As a result, those of + CONFIG::file::execute were used for CONFIG::misc::env . + + Those of CONFIG::file::rewrite were not used because I forgot to update + request type. As a result, those of CONFIG::file::truncate were used for + CONFIG::file::rewrite . + +Fix 2010/05/10 + + @ Fix incorrect out of memory warning. + + Out of memory warnings were not printed in some cases by error. + +Fix 2010/05/27 + + @ Add missing rcu_dereference() for ccs_find_execute_handler(). + + Since 1.7.0 , ccs_find_execute_handler() was by error using + list_for_each_entry() rather than list_for_each_entry_rcu(). + This bug affects only Alpha architecture. + +Fix 2010/06/03 + + @ Fix missing sanity check for "file_pattern". + + Since 1.7.0 , ccs_write_pattern_policy() was by error accepting + invalid pathname. + +Fix 2010/06/09 + + @ Add missing ccs_put_name() in ccs_parse_envp(). + + Since 1.7.0 , ccs_parse_envp() was not calling ccs_put_name() if + environment variable's value ('if exec.envp["name"]="value"' condition) + was invalid. + + @ Add missing NULL check in ccs_condition(). + + Since 1.7.0 , if 'if symlink.target=' part was given against non-file + permissions (e.g. allow_env PATH if symlink.target="/"), it triggered + NULL pointer dereference. + +Fix 2010/07/29 + + @ Change keyword syntax. + + I removed "allow_" prefix from directives. New directives for files are + prefixed with "file ". For example, "allow_read" changed to "file read", + "allow_ioctl" changed to "file ioctl". New directive for "allow_network" + is "network". New directive for "allow_env" is "misc env". New directive + for "allow_signal" is "ipc signal". New directive for "allow_capability" + is "capability". These directives correspond with keywords used by + profile's CONFIG lines. + + I removed "deny_rewrite" and "allow_rewrite" directives and introduced + "file append" directive. Thus, permission for open(O_WRONLY | O_APPEND) + changed from "allow_write" + "allow_rewrite" to "file append". + + I removed "SYS_MOUNT", "SYS_UMOUNT", "SYS_CHROOT", "SYS_KILL", + "SYS_LINK", "SYS_SYMLINK", "SYS_RENAME", "SYS_UNLINK", "SYS_CHMOD", + "SYS_CHOWN", "SYS_IOCTL", "SYS_PIVOT_ROOT" keywords from capabilities + because these permissions can be checked by other directives (e.g. + "file mount", "ipc signal"). + + I also removed "conceal_mount" keyword from capabilities because this + check requires hooks in filesystem part while almost all hooks for + filesystem part have moved to LSM by Linux 2.6.34. + + @ Distinguish send() and recv() operations for UDP and IP protocols. + + Until now, it was impossible for UDP and IP protocols to allow either + only sending or only receiving because permissions were aggregated with + "connect" keyword. I broke "connect" keyword into "send" and "recv" + keywords so that you can keep access control for send() operation enabled + when you have to turn access control for recv() operation off due to + application breakage by filtering incoming datagram. + + @ Wait for next connection/datagram if current connection/datagram was + discarded. + + Regarding "network TCP accept", "network UDP recv", "network RAW recv" + keywords, I modified to wait for next connection/datagram if current + connection/datagram was discarded. LSM hooks for these keywords are + currently missing because this behavior may break applications. + If you found applications broken by this behavior, you can set + CONFIG::network::inet_tcp_accept and/or CONFIG::network::inet_udp_recv + and/or CONFIG::network::inet_raw_recv to mode=disabled in order to + disable filtering for incoming connection/datagram. + + @ Allow specifying multiple permissions in a line. + + Until now, only "allow_read/write" can be specified for combination of + "allow_read" + "allow_write". Now, you can combine other permissions as + long as type of parameters for these permissions is same. For example, + "file read/write/append/execute/unlink/truncate /tmp/file" is correct + but "file read/write/create /tmp/file" is wrong because "file create" + requires create mode whereas "file read" and "file write" do not. + + @ Allow wildcard for execute permission and domainname. + + Until now, to execute programs with temporary names, "aggregator" is + needed. To simplify code, I modified to accept wildcards for execute + permission and domainname. Now, you can directly specify + "file execute /tmp/logrotate.\?\?\?\?\?\?" and use + "/tmp/logrotate.\?\?\?\?\?\?" within domainnames. + + @ Change pathname for non-rename()able filesystems. + + LSM version of TOMOYO wants to use /proc/self/ rather than /proc/$PID/ if + $PID matches current thread's process ID in order to prevent current + thread from accessing other process's information unless needed. + But since procfs can be mounted on various locations (e.g. /proc/ /proc2/ + /p/ /tmp/foo/100/p/ ), LSM version of TOMOYO cannot tell that whether the + numeric part in the string returned by __d_path() represents process ID + or not. + + Therefore, to be able to convert from $PID to self no matter where procfs + is mounted, I changed pathname representations for filesystems which do + not support rename() operation (e.g. proc, sysfs, securityfs). + + Now, "/proc/self/mounts" changed to "proc:/self/mounts" and + "/sys/kernel/security/" changed to "sys:/kernel/security/" and + "/dev/pts/0" changed to "devpts:/0". + + @ Add a new keyword "any" for domain transition control. + + To be able to make it easier to apply execute_handler on each domain, + I added "any" keyword to domain transition control keywords. Now, + "initialize_domain /usr/sbin/sshd" changed to + "initialize_domain /usr/sbin/sshd from any" and + "keep_domain /usr/sbin/sshd /bin/bash" changed to + "keep_domain any from /usr/sbin/sshd /bin/bash". + + "keep_domain /path/to/execute_handler from any" will allow you to apply + execute_handler for any domains without creating domains for + execute_handler. + + @ Change buffering mode for reading policy. + + To be able to read() very very long lines correctly, I changed the way + TOMOYO buffers policy for reading. + + @ Introduce "acl_group" keyword. + + Until now, it was possible to specify only "allow_read" and "allow_env" + keywords in the exception policy. + + Since some operations like "file read/write/append /dev/null" and + "network UDP send/recv @DNS_SERVER 53" are very common and should be + permitted to all domains, I introduced "acl_group" keyword for giving + such permissions. + + For example, specify "acl_group 0 file read/write/append /dev/null" in + the exception policy and specify "use_group 0" from the domains in the + domain policy. + + "ignore_global_allow_read" and "ignore_global_allow_env" keywords were + removed from domain policy and "use_group" keyword was added. + + @ Allow controlling generation of access granted logs for per an entry + basis. + + I added per-entry flag which controls generation of grant logs because + Xen and KVM issues ioctl requests so frequently. For example, + + file ioctl /dev/null 0x5401 ; set audit=no + + will suppress /proc/ccs/grant_log even if profile says grant_log=yes . + + file ioctl /dev/null 0x5401 ; set audit=yes + + will generate /proc/ccs/grant_log even if profile says grant_log=no . + + file ioctl /dev/null 0x5401 + + will generate /proc/ccs/grant_log only if profile says grant_log=yes . + + This flag is intended for frequently accessed resources like + + file read /var/www/html/\{\*\}/\*.html ; set audit=no + + . + + @ Optimize for object's size. + + I merged similar code in order to reduce object's filesize.