TOMOYO in linux-next
Subsystems (2)
Hi!
I don't think merging that is good idea. Security should be doable without making shell-like glob matching...
+/**
+ * tomoyo_file_matches_to_pattern2 - Pattern matching without '/' character
+ * and "\-" pattern.
+ *
+ * @filename: The start of string to check.
+ * @filename_end: The end of string to check.
+ * @pattern: The start of pattern to compare.
+ * @pattern_end: The end of pattern to compare.
+ *
+ * Returns true if @filename matches @pattern, false otherwise.
+ */
+static bool tomoyo_file_matches_to_pattern2(const char *filename,
...or code like...
+/**
+ * tomoyo_path_depth - Evaluate the number of '/' in a string.
+ *
+ * @pathname: The string to evaluate.
+ *
+ * Returns path depth of the string.
+ *
+ * I score 2 for each of the '/' in the @pathname
+ * and score 1 if the @pathname ends with '/'.
+ */
+static int tomoyo_path_depth(const char *pathname)
...or code like...
+/* String table for functionality that takes 2 modes. */ +static const char *tomoyo_mode_2[4] = {
+ "disabled", "enabled", "enabled", "enabled"
+};
Are those interfaces documented somewhere?
This is quite nasty. I don't think turning off enforcement in interrupt is good idea. ("fails open").
+/**
+ * tomoyo_check_flags - Check mode for specified functionality.
+ *
+ * @domain: Pointer to "struct tomoyo_domain_info".
+ * @index: The functionality to check mode.
+ *
+ * TOMOYO checks only process context.
+ * This code disables TOMOYO's enforcement in case the function is called from
+ * interrupt context.
+ */
+unsigned int tomoyo_check_flags(const struct tomoyo_domain_info *domain,
+ const u8 index)
+{
+ const u8 profile = domain->profile;
+
+ if (WARN_ON(in_interrupt()))
+ return 0;
Comments leave something to be desired:
+ /***** EXCLUSIVE SECTION START *****/
+/**
+ * tomoyo_close_control - close() for /sys/kernel/security/tomoyo/ interface.
+ *
+ * @file: Pointer to "struct file".
I'm not sure basing security on pids is good idea...
+ /* Don't allow updating policies by non manager programs. */
+ if (head->write != tomoyo_write_pid &&
Hmm, barrier is spelled otherwise, and I'm not sure I'd trust this:
+struct tomoyo_path_info_with_data {
+ /* Keep "head" first, for this pointer is passed to tomoyo_free(). */ + struct tomoyo_path_info head; + char bariier1[16]; /* Safeguard for overrun. */
I guess constants should be used here:
+#ifdef TOMOYO_DEBUG_DOMAIN_UNDELETE
+ if (domain2->is_deleted != 255)
+ printk(KERN_DEBUG
+ "Marked %p as non undeletable\n",
+ domain2);
+#endif
+ domain2->is_deleted = 255;
(I don't know why we want undelete in tomoyo.)
If it contains copyright, it should contain copyright. It probably should not contain version numbers.
+/*
+ * security/tomoyo/file.c
+ *
+ * Implementation of the Domain-Based Mandatory Access Control.
+ *
+ * Copyright (C) 2005-2009 NTT DATA CORPORATION
+ *
+ * Version: 2.2.0-pre 2009/02/01
Code is full of tables such as:
+/* Keyword array for single path operations. */ +static const char *tomoyo_sp_keyword[TOMOYO_MAX_SINGLE_PATH_OPERATION] = {
+ [TOMOYO_TYPE_READ_WRITE_ACL] = "read/write", + [TOMOYO_TYPE_EXECUTE_ACL] = "execute", + [TOMOYO_TYPE_READ_ACL] = "read", + [TOMOYO_TYPE_WRITE_ACL] = "write", + [TOMOYO_TYPE_CREATE_ACL] = "create", + [TOMOYO_TYPE_UNLINK_ACL] = "unlink", + [TOMOYO_TYPE_MKDIR_ACL] = "mkdir", + [TOMOYO_TYPE_RMDIR_ACL] = "rmdir", + [TOMOYO_TYPE_MKFIFO_ACL] = "mkfifo", + [TOMOYO_TYPE_MKSOCK_ACL] = "mksock", + [TOMOYO_TYPE_MKBLOCK_ACL] = "mkblock", + [TOMOYO_TYPE_MKCHAR_ACL] = "mkchar", + [TOMOYO_TYPE_TRUNCATE_ACL] = "truncate", + [TOMOYO_TYPE_SYMLINK_ACL] = "symlink", + [TOMOYO_TYPE_REWRITE_ACL] = "rewrite",
+};
Can we get an interface that does not need as many strings/ as much string parsing?
That's my main complaint: Documentation.*tomoyo nor Documentation.*TOMOYO does not exist, still this adds a *lot* of new user<->kernel interfaces.
New user<->kernel interaces should be documented and very carefuly reviewed; I don't think that happened here.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
James Morris
maintainerQuoted 3 lines · Pavel Machek
Hi!
I don't think merging that is good idea.
It's already merged in Linus' tree.
Quoted 2 lines
Security should be doable
without making shell-like glob matching...
The TOMOYO developers have already responded to your feedback on this issue. It's also an inherent aspect of pathname security, an issue which has been resolved in favour of inclusion in the kernel.
As for the rest of the feedback, please work with the developers to fix any bugs or lack of documentation.
- James
Signature · 2 lines
James Morris <[email protected]>
Quoted 7 lines · James Morris
Quoted 3 lines · Pavel Machek
Hi!
I don't think merging that is good idea.
It's already merged in Linus' tree.
Too bad.
Quoted 6 lines
Quoted 2 lines
Security should be doable
without making shell-like glob matching...The TOMOYO developers have already responded to your feedback on this issue. It's also an inherent aspect of pathname security, an issue which has been resolved in favour of inclusion in the kernel.
Do you have any references? My memory claims otherwise on this.
Quoted 2 lines
As for the rest of the feedback, please work with the developers to fix any bugs or lack of documentation.
Which brings a question: given that kernel<->user interface is undocumented, how was this reviewed?
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
James Morris
maintainerQuoted 8 lines · Pavel Machek
Quoted 6 lines
Quoted 2 lines
Security should be doable
without making shell-like glob matching...The TOMOYO developers have already responded to your feedback on this issue. It's also an inherent aspect of pathname security, an issue which has been resolved in favour of inclusion in the kernel.
Do you have any references? My memory claims otherwise on this.
Al Viro merged the LSM pathname hooks.
Quoted 5 lines
Quoted 2 lines
As for the rest of the feedback, please work with the developers to fix any bugs or lack of documentation.
Which brings a question: given that kernel<->user interface is undocumented, how was this reviewed?
By 15 iterative posts to lkml and LSM, with extensive discussion and feedback, as well as presentations by the TOMOYO developers at various conferences around the world.
- James
Signature · 2 lines
James Morris <[email protected]>
Quoted 10 lines
Quoted 6 lines
Quoted 3 lines
As for the rest of the feedback, please work with the developers to fix any bugs or lack of documentation.
Which brings a question: given that kernel<->user interface is undocumented, how was this reviewed?
By 15 iterative posts to lkml and LSM, with extensive discussion and feedback, as well as presentations by the TOMOYO developers at various conferences around the world.
Yeah, 15 posts to lkml, largely ignored becuase the design problems seemed unfixable...
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Hi!
Quoted 2 lines
As for the rest of the feedback, please work with the developers to fix any bugs or lack of documentation.
Apparently not even its user<->kernel interface was reviewed. This violates "one value per file in sysfs":
[root@tomoyo]# cat /sys/kernel/security/tomoyo/meminfo
Shared: 61440
Private: 69632
Dynamic: 768
Total: 131840 You can set memory quota by writing to this file.
(Example)
[root@tomoyo]# echo Shared: 2097152 > /sys/kernel/security/tomoyo/meminfo [root@tomoyo]# echo Private: 2097152 > /sys/kernel/security/tomoyo/meminfo
(not to mention being ugly as hell).
This is totaly useless once tomoyo is merged:
** /sys/kernel/security/tomoyo/version **
This file is used for getting TOMOYO Linux's version. (Example)
[root@etch]# cat /sys/kernel/security/tomoyo/version 2.2.0-pre
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
James Morris
maintainerQuoted 14 lines · Pavel Machek
Hi!
Quoted 2 lines
As for the rest of the feedback, please work with the developers to fix any bugs or lack of documentation.
Apparently not even its user<->kernel interface was reviewed. This violates "one value per file in sysfs":
[root@tomoyo]# cat /sys/kernel/security/tomoyo/meminfo Shared: 61440 Private: 69632 Dynamic: 768 Total: 131840
Quoted 4 lines
You can set memory quota by writing to this file.
(Example)
[root@tomoyo]# echo Shared: 2097152 >/sys/kernel/security/tomoyo/meminfo[root@tomoyo]# echo Private: 2097152 >/sys/kernel/security/tomoyo/meminfo
This is not sysfs, it's securityfs, with their documentation showing it mounted on /sys.
- James
Signature · 2 lines
James Morris <[email protected]>
Quoted 16 lines · James Morris
Quoted 14 lines · Pavel Machek
Hi!
Quoted 2 lines
As for the rest of the feedback, please work with the developers to fix any bugs or lack of documentation.
Apparently not even its user<->kernel interface was reviewed. This violates "one value per file in sysfs":
[root@tomoyo]# cat /sys/kernel/security/tomoyo/meminfo Shared: 61440 Private: 69632 Dynamic: 768 Total: 131840
Quoted 7 lines
Quoted 4 lines
You can set memory quota by writing to this file.
(Example)
[root@tomoyo]# echo Shared: 2097152 >/sys/kernel/security/tomoyo/meminfo[root@tomoyo]# echo Private: 2097152 >/sys/kernel/security/tomoyo/meminfoThis is not sysfs, it's securityfs, with their documentation showing it mounted on /sys.
Well, that's a bit better, but it still does not justify turning securityfs into procfs-like mess... when solution is so easy. Just use one value per file.
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Tetsuo Handa
maintainerHello.
Quoted 2 lines · James Morris
As for the rest of the feedback, please work with the developers to fix any bugs or lack of documentation.
Thanks.
Quoted 1 line · Pavel Machek
Are those interfaces documented somewhere?
They are documented at http://tomoyo.sourceforge.jp/en/2.2.x/policy-reference.html .
Quoted 2 lines
This is quite nasty. I don't think turning off enforcement in interrupt is good idea. ("fails open").
This is not "fails open". TOMOYO deals only operations which are allowed to sleep (e.g. opening files, making directories). This in_interrupt() check is for safety in case somebody who are not allowed to sleep called TOMOYO's function by error.
Quoted 1 line
I'm not sure basing security on pids is good idea...
PID is used for reaching a domain which that PID is in, not for access control decisions.
Quoted 8 lines
Hmm, barrier is spelled otherwise, and I'm not sure I'd trust this:
(quoted diff) +4
-0+struct tomoyo_path_info_with_data { + /* Keep "head" first, for this pointer is passed to tomoyo_free(). */ + struct tomoyo_path_info head; + char bariier1[16]; /* Safeguard for overrun. */I guess constants should be used here:
Oh, typo, thanks.
I think there is no need to use #define here, for nobody accesses barrier1/barrier2.
Quoted 9 lines
(quoted diff) +7
-0+#ifdef TOMOYO_DEBUG_DOMAIN_UNDELETE + if (domain2->is_deleted != 255) + printk(KERN_DEBUG + "Marked %p as non undeletable\n", + domain2); +#endif + domain2->is_deleted = 255;(I don't know why we want undelete in tomoyo.)
This "undelete domain" feature was introduced to allow administrators switch domain policy periodically.
Quoted 2 lines
If it contains copyright, it should contain copyright. It probably should not contain version numbers.
TOMOYO's management tools want /sys/kernel/security/tomoyo/version .
Quoted 2 lines
Can we get an interface that does not need as many strings/ as much string parsing?
A plain text interface splitted by ' ' and '\n' is cleaner than introducing binary interface. (TOMOYO uses \040 for ' ' and \012 for '\n'. No worry for ' ' and '\n' in pathnames.)
Quoted 6 lines
That's my main complaint: Documentation.*tomoyo nor Documentation.*TOMOYO does not exist, still this adds a *lot* of new user<->kernel interfaces.
New user<->kernel interaces should be documented and very carefuly reviewed; I don't think that happened here.
These user<->kernel interface are for TOMOYO's policy management tools, not for general userland applications like /bin/bash /usr/sbin/sshd etc.
Regards.
----------------------------------------
TOMOYO: Fix a typo.
--- security/tomoyo/common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
security/tomoyo/common.h +1 -1
@@ -55,7 +55,7 @@ struct tomoyo_path_info {struct tomoyo_path_info_with_data {/* Keep "head" first, for this pointer is passed to tomoyo_free(). */ struct tomoyo_path_info head; -char bariier1[16 ];/* Safeguard for overrun. */ +char barrier1[16 ];/* Safeguard for overrun. */ char body[TOMOYO_MAX_PATHNAME_LEN ];char barrier2[16 ];/* Safeguard for overrun. */ };
Quoted 14 lines · Tetsuo Handa
----------------------------------------
TOMOYO: Fix a typo.Signed-off-by Kentaro Takeda <[email protected]>Signed-off-by Tetsuo Handa <[email protected]>Signed-off-by Toshiharu Harada <[email protected]>--- security/tomoyo/common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
security/tomoyo/common.h struct tomoyo_path_info { · line 61
Quoted 8 lines
security/tomoyo/common.h +1
-1@@ -55,7 +55,7 @@ struct tomoyo_path_info {struct tomoyo_path_info_with_data {/* Keep "head" first, for this pointer is passed to tomoyo_free(). */ struct tomoyo_path_info head; -char bariier1[16 ];/* Safeguard for overrun. */ +char barrier1[16 ];/* Safeguard for overrun. */ char body[TOMOYO_MAX_PATHNAME_LEN ];char barrier2[16 ];/* Safeguard for overrun. */ };
Applied.
Signature · 2 lines
James Morris <[email protected]>
Quoted 7 lines
Quoted 3 lines
This is quite nasty. I don't think turning off enforcement in interrupt is good idea. ("fails open").
This is not "fails open". TOMOYO deals only operations which are allowed to sleep (e.g. opening files, making directories). This
in_interrupt()check is for safety in case somebody who are not allowed to sleep called TOMOYO's function by error.
If it never happens, why not fail closed?
Quoted 3 lines
Quoted 1 line
I'm not sure basing security on pids is good idea...
PID is used for reaching a domain which that PID is in, not for access control decisions.
Can I get some documentation about domains etc? How will it interact with containers?
Quoted 11 lines
Quoted 8 lines
Hmm, barrier is spelled otherwise, and I'm not sure I'd trust this:
(quoted diff) +4
-0+struct tomoyo_path_info_with_data { + /* Keep "head" first, for this pointer is passed to tomoyo_free(). */ + struct tomoyo_path_info head; + char bariier1[16]; /* Safeguard for overrun. */I guess constants should be used here:
Oh, typo, thanks.
I think there is no need to use #define here, for nobody accesses barrier1/barrier2.
I do believe that those barriers should be deleted. You should just avoid buffer overruns; there's no reason 16 bytes should be enough to protect you.
Quoted 11 lines
Quoted 9 lines
(quoted diff) +7
-0+#ifdef TOMOYO_DEBUG_DOMAIN_UNDELETE + if (domain2->is_deleted != 255) + printk(KERN_DEBUG + "Marked %p as non undeletable\n", + domain2); +#endif + domain2->is_deleted = 255;(I don't know why we want undelete in tomoyo.)
This "undelete domain" feature was introduced to allow administrators switch domain policy periodically.
255 needs a constant at the very least.
Quoted 3 lines
Quoted 2 lines
If it contains copyright, it should contain copyright. It probably should not contain version numbers.
TOMOYO's management tools want
/sys/kernel/security/tomoyo/version.
So fix them. It is better than carrying "version" forever.
Quoted 5 lines
Quoted 2 lines
Can we get an interface that does not need as many strings/ as much string parsing?
A plain text interface splitted by ' ' and '\n' is cleaner than introducing binary interface. (TOMOYO uses \040 for ' ' and \012 for '\n'. No worry for ' ' and '\n' in pathnames.)
\0 terminated strings?
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
private user<->kernel interface in linux-2.6.30, was Re: TOMOYO in linux-next
In reply to Tetsuo HandaHi!
Quoted 8 lines
Quoted 6 lines
That's my main complaint: Documentation.*tomoyo nor Documentation.*TOMOYO does not exist, still this adds a *lot* of new user<->kernel interfaces.
New user<->kernel interaces should be documented and very carefuly reviewed; I don't think that happened here.
These user<->kernel interface are for TOMOYO's policy management tools, not for general userland applications like
/bin/bash/usr/sbin/sshdetc.
I do believe all user<->kernel interfaces should be properly reviewed/documented. We'll have to maintain them forever. Just because you don't intend them to be used by /bin/bash does not mean people will not use them; and it does not mean we will not have to carry them forever.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Tetsuo Handa
maintainerHello.
Quoted 8 lines
Quoted 8 lines
(quoted diff) +7
-0+#ifdef TOMOYO_DEBUG_DOMAIN_UNDELETE + if (domain2->is_deleted != 255) + printk(KERN_DEBUG + "Marked %p as non undeletable\n", + domain2); +#endif + domain2->is_deleted = 255;
Quoted 4 lines
Quoted 1 line
(I don't know why we want undelete in tomoyo.)
This "undelete domain" feature was introduced to allow administrators switch domain policy periodically.
We reconsidered this feature and concluded that we won't need this feature.
Thanks.
----------
Subject: tomoyo: remove "undelete domain" command.
Since TOMOYO's policy management tools does not use the "undelete domain" command, we decided to remove that command.
--- security/tomoyo/common.c | 7 --- security/tomoyo/common.h | 8 ---- security/tomoyo/domain.c | 90 +---------------------------------------------- 3 files changed, 5 insertions(+), 100 deletions(-)
security/tomoyo/common.c +1 -6
@@ -1252,15 +1252,12 @@ static int tomoyo_write_domain_policy(ststruct tomoyo_domain_info *domain = head->write_var1;bool is_delete = false;bool is_select = false; -bool is_undelete = false;unsigned int profile;if (tomoyo_str_starts (&data,TOMOYO_KEYWORD_DELETE )) is_delete = true;else if (tomoyo_str_starts (&data,TOMOYO_KEYWORD_SELECT )) is_select = true; -else if (tomoyo_str_starts (&data,TOMOYO_KEYWORD_UNDELETE )) - is_undelete = true;if (is_select &&tomoyo_is_select_one (head, data))return 0 ;/* Don't allow updating policies by non manager programs. */
@@ -1274,9 +1271,7 @@ static int tomoyo_write_domain_policy(stdown_read (&tomoyo_domain_list_lock); domain =tomoyo_find_domain (data);up_read (&tomoyo_domain_list_lock); - }else if (is_undelete) - domain =tomoyo_undelete_domain (data); -else + }else domain =tomoyo_find_or_assign_new_domain (data,0 ); head->write_var1 = domain;return 0 ;
security/tomoyo/common.h +1 -7
@@ -88,10 +88,7 @@ struct tomoyo_domain_info {/* Name of this domain. Never NULL. */ const struct tomoyo_path_info *domainname;u8 profile;/* Profile number to use. */ -u8 is_deleted;/* Delete flag. -0 = active. -1 = deleted but undeletable. -255 = deleted and no longer undeletable. */ +bool is_deleted;/* Delete flag. */ bool quota_warned;/* Quota warnning flag. */ /* DOMAIN_FLAGS_*. Use tomoyo_set_domain_flag() to modify. */ u8 flags;
@@ -144,7 +141,6 @@ struct tomoyo_double_path_acl_record {#define TOMOYO_KEYWORD_NO_INITIALIZE_DOMAIN "no_initialize_domain "#define TOMOYO_KEYWORD_NO_KEEP_DOMAIN "no_keep_domain "#define TOMOYO_KEYWORD_SELECT "select " -#define TOMOYO_KEYWORD_UNDELETE "undelete "#define TOMOYO_KEYWORD_USE_PROFILE "use_profile "#define TOMOYO_KEYWORD_IGNORE_GLOBAL_ALLOW_READ "ignore_global_allow_read"/* A domain definition starts with <kernel>. */
@@ -267,8 +263,6 @@ struct tomoyo_domain_info *tomoyo_find_dstruct tomoyo_domain_info *tomoyo_find_or_assign_new_domain (const char * domainname,const u8 profile); -/* Undelete a domain. */ -struct tomoyo_domain_info *tomoyo_undelete_domain (const char *domainname);/* Check mode for specified functionality. */ unsigned int tomoyo_check_flags (const struct tomoyo_domain_info *domain,const u8 index);
security/tomoyo/domain.c +3 -87
128 lines not on this page · raw message
Quoted 10 lines · Tetsuo Handa
Hello.
Quoted 8 lines
Quoted 8 lines
(quoted diff) +7
-0+#ifdef TOMOYO_DEBUG_DOMAIN_UNDELETE + if (domain2->is_deleted != 255) + printk(KERN_DEBUG + "Marked %p as non undeletable\n", + domain2); +#endif + domain2->is_deleted = 255;
Quoted 5 lines
Quoted 4 lines
Quoted 1 line
(I don't know why we want undelete in tomoyo.)
This "undelete domain" feature was introduced to allow administrators switch domain policy periodically.
We reconsidered this feature and concluded that we won't need this feature.
Thanks.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
James Morris
maintainerQuoted 10 lines · Tetsuo Handa
Thanks.
----------
Subject: tomoyo: remove "undelete domain" command.Since TOMOYO's policy management tools does not use the "undelete domain" command, we decided to remove that command.
Signed-off-by Kentaro Takeda <[email protected]>Signed-off-by Tetsuo Handa <[email protected]>Signed-off-by Toshiharu Harada <[email protected]>
Applied togit://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6#next
Signature · 2 lines
James Morris <[email protected]>