summaryrefslogtreecommitdiffstats
path: root/security/smack/smackfs.c
diff options
context:
space:
mode:
authorCasey Schaufler <casey@schaufler-ca.com>2014-08-27 17:51:27 -0400
committerCasey Schaufler <casey@schaufler-ca.com>2014-08-28 16:11:56 -0400
commitd166c8024d620d654b12834fac354fb4203c6c22 (patch)
treed804064cb7fce9448071691ae5a6260dc35674db /security/smack/smackfs.c
parentd83d2c26461d661384676a4eed935d925b0fcc34 (diff)
Smack: Bring-up access mode
People keep asking me for permissive mode, and I keep saying "no". Permissive mode is wrong for more reasons than I can enumerate, but the compelling one is that it's once on, never off. Nonetheless, there is an argument to be made for running a process with lots of permissions, logging which are required, and then locking the process down. There wasn't a way to do that with Smack, but this provides it. The notion is that you start out by giving the process an appropriate Smack label, such as "ATBirds". You create rules with a wide range of access and the "b" mode. On Tizen it might be: ATBirds System rwxalb ATBirds User rwxalb ATBirds _ rwxalb User ATBirds wb System ATBirds wb Accesses that fail will generate audit records. Accesses that succeed because of rules marked with a "b" generate log messages identifying the rule, the program and as much object information as is convenient. When the system is properly configured and the programs brought in line with the labeling scheme the "b" mode can be removed from the rules. When the system is ready for production the facility can be configured out. This provides the developer the convenience of permissive mode without creating a system that looks like it is enforcing a policy while it is not. Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
Diffstat (limited to 'security/smack/smackfs.c')
-rw-r--r--security/smack/smackfs.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
index 56a1439786a9..49a2248b525c 100644
--- a/security/smack/smackfs.c
+++ b/security/smack/smackfs.c
@@ -304,6 +304,10 @@ static int smk_perm_from_str(const char *string)
304 case 'L': 304 case 'L':
305 perm |= MAY_LOCK; 305 perm |= MAY_LOCK;
306 break; 306 break;
307 case 'b':
308 case 'B':
309 perm |= MAY_BRINGUP;
310 break;
307 default: 311 default:
308 return perm; 312 return perm;
309 } 313 }
@@ -616,6 +620,8 @@ static void smk_rule_show(struct seq_file *s, struct smack_rule *srp, int max)
616 seq_putc(s, 't'); 620 seq_putc(s, 't');
617 if (srp->smk_access & MAY_LOCK) 621 if (srp->smk_access & MAY_LOCK)
618 seq_putc(s, 'l'); 622 seq_putc(s, 'l');
623 if (srp->smk_access & MAY_BRINGUP)
624 seq_putc(s, 'b');
619 625
620 seq_putc(s, '\n'); 626 seq_putc(s, '\n');
621} 627}
@@ -1880,7 +1886,10 @@ static ssize_t smk_user_access(struct file *file, const char __user *buf,
1880 else if (res != -ENOENT) 1886 else if (res != -ENOENT)
1881 return -EINVAL; 1887 return -EINVAL;
1882 1888
1883 data[0] = res == 0 ? '1' : '0'; 1889 /*
1890 * smk_access() can return a value > 0 in the "bringup" case.
1891 */
1892 data[0] = res >= 0 ? '1' : '0';
1884 data[1] = '\0'; 1893 data[1] = '\0';
1885 1894
1886 simple_transaction_set(file, 2); 1895 simple_transaction_set(file, 2);