--- trunk/1.7.x/ccs-patch/README.ccs 2009/12/12 08:47:01 3248 +++ trunk/1.8.x/ccs-patch/README.ccs 2010/09/01 14:04:16 3934 @@ -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. @@ -2273,8 +2273,394 @@ @ Use rcu_read_lock() for find_task_by_pid(). - Since kernel 2.6.16 , caller of find_task_by_pid() needs to call + 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/09/01 + + @ Change directives. + + 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 + TCP" is "network inet stream", "allow_network UDP" is "network inet + dgram", "allow_network RAW" is "network inet raw". New directive for + "allow_env" is "misc env". New directive for "allow_signal" is "ipc + signal". New directive for "allow_capability" is "capability". These new + 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. + + New directive for "execute_handler" is "task auto_execute_handler", + "denied_execute_handler" is "task denied_execute_handler". + + @ Distinguish send() and recv() operations. + + Until now, it was impossible for UDP and IP sockets 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 disable access control for recv() operation due to + application breakage by discarding incoming datagram. + + @ Wait for next connection/datagram if current connection/datagram was + discarded. + + Regarding "network inet stream accept", "network inet dgram recv", + "network inet raw recv" directives, I modified to wait for next + connection/datagram if current connection/datagram was discarded. + LSM hooks for these directives are currently missing because this + behavior may break applications. If you found applications broken by + this behavior, you can set CONFIG::network::inet_stream_accept and/or + CONFIG::network::inet_dgram_recv and/or CONFIG::network::inet_raw_recv + to mode=disabled in order to only disable filtering for incoming + connection/datagram. + + @ Add Unix domain socket restriction support. + + Until now, it was possible to restrict only inet domain sockets (i.e. + TCP/UDP/RAW). I added restriction for Unix domain sockets (i.e. stream/ + dgram/seqpacket). New directive "network unix" is added as well as + "network inet" directive. + + @ 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 auto_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/auto_execute_handler from any" will allow you to + apply auto_execute_handler for any domains without creating domains for + auto_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" directives 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 if audit=no + + will suppress /proc/ccs/grant_log even if profile says grant_log=yes . + + file ioctl /dev/null 0x5401 if 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 if audit=no + + . + + @ Change profile structure. + + To make it clear that preferences can be specified by per-profile basis, + I removed global preference ("PREFERENCE::"). Now, you need to explicitly + specify per-profile preference ("$profilenumber-PREFERENCE::"). + + I changed default mode for access grant logs from "yes" to "no". + You may change mode to "yes" if you want all grant logs to be generated. + You may override mode using "if audit=yes" if you want specific grant + logs to be generated. + + Since printing all warning/error messages to console is noisy, + I changed verbose mode control from per-preference basis to + per-functionality basis. Now, you can selectively print warning/error + messages. + + @ Automatically create domain by execve() even if enforcing mode. + + Until now, new domains are not created if the domain was not defined and + current domain is enforcing mode ("CONFIG::file::execute=enforcing"). + + To be able to restrict shell session without using "keep_domain", + I changed to create new domains automatically even if current domain is + enforcing mode. + + @ Replace "task.state" with "auto_domain_transition". + + task.state is difficult to use. Thus, I replaced task.state with + auto_domain_transition which performs domain transition instead of + changing current process's state variables. + + If domain transition failed, current process will be killed by SIGKILL + signal. This should not happen in normal circumstances, for you know the + domain to transit to and thereby you will define the domain beforehand + when you use "auto_domain_transition" keyword. + + @ Replace "allow_transit" with "task manual_domain_transition". + + I changed this directive to specify absolute domainname (e.g. + " /usr/sbin/httpd //app=cgi1\040id=10000") rather than virtual + pathname (e.g. "//app=cgi1\040id=10000") because you know the domain to + transit to and thereby you will define the domain beforehand when you use + "task manual_domain_transition" directive. + + This change allows you to jump to arbitrary domain. + + @ Add "task auto_domain_transition". + + This is similar to "task manual_domain_transition", but is automatically + applied if conditions are met. For example, + + task auto_domain_transition //./non-root if task.uid!=0 + + will automatically jump to " //./non-root" domain if current + process's UID is not 0 whereas + + task manual_domain_transition //./non-root if task.uid!=0 + + will jump to " //./non-root" domain if current process's UID is + not 0 and current process wrote " //./non-root" + '\n' to + /proc/ccs/.transition interface. + + If domain transition failed, current process will be killed by SIGKILL + signal. + + @ Optimize for object's size. + + I merged similar code in order to reduce object's filesize. + +Version 1.8.0 2010/XX/XX Feature enhancement release.