2 * Copyright (C) 2007 Casey Schaufler <casey@schaufler-ca.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, version 2.
9 * Casey Schaufler <casey@schaufler-ca.com>
10 * Ahmed S. Darwish <darwish.07@gmail.com>
12 * Special thanks to the authors of selinuxfs.
14 * Karl MacMillan <kmacmillan@tresys.com>
15 * James Morris <jmorris@redhat.com>
19 #include <linux/kernel.h>
20 #include <linux/vmalloc.h>
21 #include <linux/security.h>
22 #include <linux/mutex.h>
23 #include <net/netlabel.h>
24 #include <net/cipso_ipv4.h>
25 #include <linux/seq_file.h>
26 #include <linux/ctype.h>
27 #include <linux/audit.h>
31 * smackfs pseudo filesystem.
36 SMK_LOAD = 3, /* load policy */
37 SMK_CIPSO = 4, /* load label -> CIPSO mapping */
38 SMK_DOI = 5, /* CIPSO DOI */
39 SMK_DIRECT = 6, /* CIPSO level indicating direct label */
40 SMK_AMBIENT = 7, /* internet ambient label */
41 SMK_NLTYPE = 8, /* label scheme to use by default */
42 SMK_ONLYCAP = 9, /* the only "capable" label */
48 static DEFINE_MUTEX(smack_list_lock);
49 static DEFINE_MUTEX(smack_cipso_lock);
50 static DEFINE_MUTEX(smack_ambient_lock);
53 * This is the "ambient" label for network traffic.
54 * If it isn't somehow marked, use this.
55 * It can be reset via smackfs/ambient
57 char *smack_net_ambient = smack_known_floor.smk_known;
60 * This is the default packet marking scheme for network traffic.
61 * It can be reset via smackfs/nltype
63 int smack_net_nltype = NETLBL_NLTYPE_CIPSOV4;
66 * This is the level in a CIPSO header that indicates a
67 * smack label is contained directly in the category set.
68 * It can be reset via smackfs/direct
70 int smack_cipso_direct = SMACK_CIPSO_DIRECT_DEFAULT;
73 * Unless a process is running with this label even
74 * having CAP_MAC_OVERRIDE isn't enough to grant
75 * privilege to violate MAC policy. If no label is
76 * designated (the NULL case) capabilities apply to
77 * everyone. It is expected that the hat (^) label
78 * will be used if any label is used.
82 static int smk_cipso_doi_value = SMACK_CIPSO_DOI_DEFAULT;
83 struct smk_list_entry *smack_list;
85 #define SEQ_READ_FINISHED 1
88 * Values for parsing cipso rules
89 * SMK_DIGITLEN: Length of a digit field in a rule.
90 * SMK_CIPSOMIN: Minimum possible cipso rule length.
91 * SMK_CIPSOMAX: Maximum possible cipso rule length.
93 #define SMK_DIGITLEN 4
94 #define SMK_CIPSOMIN (SMK_LABELLEN + 2 * SMK_DIGITLEN)
95 #define SMK_CIPSOMAX (SMK_CIPSOMIN + SMACK_CIPSO_MAXCATNUM * SMK_DIGITLEN)
98 * Values for parsing MAC rules
99 * SMK_ACCESS: Maximum possible combination of access permissions
100 * SMK_ACCESSLEN: Maximum length for a rule access field
101 * SMK_LOADLEN: Smack rule length
103 #define SMK_ACCESS "rwxa"
104 #define SMK_ACCESSLEN (sizeof(SMK_ACCESS) - 1)
105 #define SMK_LOADLEN (SMK_LABELLEN + SMK_LABELLEN + SMK_ACCESSLEN)
109 * Seq_file read operations for /smack/load
112 static void *load_seq_start(struct seq_file *s, loff_t *pos)
114 if (*pos == SEQ_READ_FINISHED)
120 static void *load_seq_next(struct seq_file *s, void *v, loff_t *pos)
122 struct smk_list_entry *skp = ((struct smk_list_entry *) v)->smk_next;
125 *pos = SEQ_READ_FINISHED;
130 static int load_seq_show(struct seq_file *s, void *v)
132 struct smk_list_entry *slp = (struct smk_list_entry *) v;
133 struct smack_rule *srp = &slp->smk_rule;
135 seq_printf(s, "%s %s", (char *)srp->smk_subject,
136 (char *)srp->smk_object);
140 if (srp->smk_access & MAY_READ)
142 if (srp->smk_access & MAY_WRITE)
144 if (srp->smk_access & MAY_EXEC)
146 if (srp->smk_access & MAY_APPEND)
148 if (srp->smk_access == 0)
156 static void load_seq_stop(struct seq_file *s, void *v)
161 static struct seq_operations load_seq_ops = {
162 .start = load_seq_start,
163 .next = load_seq_next,
164 .show = load_seq_show,
165 .stop = load_seq_stop,
169 * smk_open_load - open() for /smack/load
170 * @inode: inode structure representing file
171 * @file: "load" file pointer
173 * For reading, use load_seq_* seq_file reading operations.
175 static int smk_open_load(struct inode *inode, struct file *file)
177 return seq_open(file, &load_seq_ops);
181 * smk_set_access - add a rule to the rule list
182 * @srp: the new rule to add
184 * Looks through the current subject/object/access list for
185 * the subject/object pair and replaces the access that was
186 * there. If the pair isn't found add it with the specified
189 * Returns 0 if nothing goes wrong or -ENOMEM if it fails
190 * during the allocation of the new pair to add.
192 static int smk_set_access(struct smack_rule *srp)
194 struct smk_list_entry *sp;
195 struct smk_list_entry *newp;
198 mutex_lock(&smack_list_lock);
200 for (sp = smack_list; sp != NULL; sp = sp->smk_next)
201 if (sp->smk_rule.smk_subject == srp->smk_subject &&
202 sp->smk_rule.smk_object == srp->smk_object) {
203 sp->smk_rule.smk_access = srp->smk_access;
208 newp = kzalloc(sizeof(struct smk_list_entry), GFP_KERNEL);
214 newp->smk_rule = *srp;
215 newp->smk_next = smack_list;
220 mutex_unlock(&smack_list_lock);
226 * smk_write_load - write() for /smack/load
227 * @filp: file pointer, not actually used
228 * @buf: where to get the data from
230 * @ppos: where to start - must be 0
232 * Get one smack access rule from above.
233 * The format is exactly:
234 * char subject[SMK_LABELLEN]
235 * char object[SMK_LABELLEN]
236 * char access[SMK_ACCESSLEN]
238 * writes must be SMK_LABELLEN+SMK_LABELLEN+SMK_ACCESSLEN bytes.
240 static ssize_t smk_write_load(struct file *file, const char __user *buf,
241 size_t count, loff_t *ppos)
243 struct smack_rule rule;
248 * Must have privilege.
250 * Enough data must be present.
252 if (!capable(CAP_MAC_ADMIN))
256 if (count != SMK_LOADLEN)
259 data = kzalloc(count, GFP_KERNEL);
263 if (copy_from_user(data, buf, count) != 0) {
268 rule.smk_subject = smk_import(data, 0);
269 if (rule.smk_subject == NULL)
272 rule.smk_object = smk_import(data + SMK_LABELLEN, 0);
273 if (rule.smk_object == NULL)
278 switch (data[SMK_LABELLEN + SMK_LABELLEN]) {
283 rule.smk_access |= MAY_READ;
289 switch (data[SMK_LABELLEN + SMK_LABELLEN + 1]) {
294 rule.smk_access |= MAY_WRITE;
300 switch (data[SMK_LABELLEN + SMK_LABELLEN + 2]) {
305 rule.smk_access |= MAY_EXEC;
311 switch (data[SMK_LABELLEN + SMK_LABELLEN + 3]) {
316 rule.smk_access |= MAY_READ;
322 rc = smk_set_access(&rule);
332 static const struct file_operations smk_load_ops = {
333 .open = smk_open_load,
336 .write = smk_write_load,
337 .release = seq_release,
341 * smk_cipso_doi - initialize the CIPSO domain
343 static void smk_cipso_doi(void)
346 struct cipso_v4_doi *doip;
347 struct netlbl_audit audit_info;
349 audit_info.loginuid = audit_get_loginuid(current);
350 audit_info.sessionid = audit_get_sessionid(current);
351 audit_info.secid = smack_to_secid(current_security());
353 rc = netlbl_cfg_map_del(NULL, PF_UNSPEC, NULL, NULL, &audit_info);
355 printk(KERN_WARNING "%s:%d remove rc = %d\n",
356 __func__, __LINE__, rc);
358 doip = kmalloc(sizeof(struct cipso_v4_doi), GFP_KERNEL);
360 panic("smack: Failed to initialize cipso DOI.\n");
361 doip->map.std = NULL;
362 doip->doi = smk_cipso_doi_value;
363 doip->type = CIPSO_V4_MAP_PASS;
364 doip->tags[0] = CIPSO_V4_TAG_RBITMAP;
365 for (rc = 1; rc < CIPSO_V4_TAG_MAXCNT; rc++)
366 doip->tags[rc] = CIPSO_V4_TAG_INVALID;
368 rc = netlbl_cfg_cipsov4_add(doip, &audit_info);
370 printk(KERN_WARNING "%s:%d cipso add rc = %d\n",
371 __func__, __LINE__, rc);
375 rc = netlbl_cfg_cipsov4_map_add(doip->doi,
376 NULL, NULL, NULL, &audit_info);
378 printk(KERN_WARNING "%s:%d map add rc = %d\n",
379 __func__, __LINE__, rc);
386 * smk_unlbl_ambient - initialize the unlabeled domain
388 static void smk_unlbl_ambient(char *oldambient)
391 struct netlbl_audit audit_info;
393 audit_info.loginuid = audit_get_loginuid(current);
394 audit_info.sessionid = audit_get_sessionid(current);
395 audit_info.secid = smack_to_secid(current_security());
397 if (oldambient != NULL) {
398 rc = netlbl_cfg_map_del(oldambient,
399 PF_UNSPEC, NULL, NULL, &audit_info);
401 printk(KERN_WARNING "%s:%d remove rc = %d\n",
402 __func__, __LINE__, rc);
405 rc = netlbl_cfg_unlbl_map_add(smack_net_ambient,
406 PF_INET, NULL, NULL, &audit_info);
408 printk(KERN_WARNING "%s:%d add rc = %d\n",
409 __func__, __LINE__, rc);
413 * Seq_file read operations for /smack/cipso
416 static void *cipso_seq_start(struct seq_file *s, loff_t *pos)
418 if (*pos == SEQ_READ_FINISHED)
424 static void *cipso_seq_next(struct seq_file *s, void *v, loff_t *pos)
426 struct smack_known *skp = ((struct smack_known *) v)->smk_next;
429 * Omit labels with no associated cipso value
431 while (skp != NULL && !skp->smk_cipso)
435 *pos = SEQ_READ_FINISHED;
441 * Print cipso labels in format:
442 * label level[/cat[,cat]]
444 static int cipso_seq_show(struct seq_file *s, void *v)
446 struct smack_known *skp = (struct smack_known *) v;
447 struct smack_cipso *scp = skp->smk_cipso;
457 seq_printf(s, "%s %3d", (char *)&skp->smk_known, scp->smk_level);
459 cbp = scp->smk_catset;
460 for (i = 0; i < SMK_LABELLEN; i++)
461 for (m = 0x80; m != 0; m >>= 1) {
463 seq_printf(s, "%c%d", sep, cat);
474 static void cipso_seq_stop(struct seq_file *s, void *v)
479 static struct seq_operations cipso_seq_ops = {
480 .start = cipso_seq_start,
481 .stop = cipso_seq_stop,
482 .next = cipso_seq_next,
483 .show = cipso_seq_show,
487 * smk_open_cipso - open() for /smack/cipso
488 * @inode: inode structure representing file
489 * @file: "cipso" file pointer
491 * Connect our cipso_seq_* operations with /smack/cipso
494 static int smk_open_cipso(struct inode *inode, struct file *file)
496 return seq_open(file, &cipso_seq_ops);
500 * smk_write_cipso - write() for /smack/cipso
501 * @filp: file pointer, not actually used
502 * @buf: where to get the data from
504 * @ppos: where to start
506 * Accepts only one cipso rule per write call.
507 * Returns number of bytes written or error code, as appropriate
509 static ssize_t smk_write_cipso(struct file *file, const char __user *buf,
510 size_t count, loff_t *ppos)
512 struct smack_known *skp;
513 struct smack_cipso *scp = NULL;
514 char mapcatset[SMK_LABELLEN];
518 ssize_t rc = -EINVAL;
525 * Must have privilege.
527 * Enough data must be present.
529 if (!capable(CAP_MAC_ADMIN))
533 if (count < SMK_CIPSOMIN || count > SMK_CIPSOMAX)
536 data = kzalloc(count + 1, GFP_KERNEL);
540 if (copy_from_user(data, buf, count) != 0) {
548 * Only allow one writer at a time. Writes should be
549 * quite rare and small in any case.
551 mutex_lock(&smack_cipso_lock);
553 skp = smk_import_entry(rule, 0);
557 rule += SMK_LABELLEN;;
558 ret = sscanf(rule, "%d", &maplevel);
559 if (ret != 1 || maplevel > SMACK_CIPSO_MAXLEVEL)
562 rule += SMK_DIGITLEN;
563 ret = sscanf(rule, "%d", &catlen);
564 if (ret != 1 || catlen > SMACK_CIPSO_MAXCATNUM)
567 if (count != (SMK_CIPSOMIN + catlen * SMK_DIGITLEN))
570 memset(mapcatset, 0, sizeof(mapcatset));
572 for (i = 0; i < catlen; i++) {
573 rule += SMK_DIGITLEN;
574 ret = sscanf(rule, "%d", &cat);
575 if (ret != 1 || cat > SMACK_CIPSO_MAXCATVAL)
578 smack_catset_bit(cat, mapcatset);
581 if (skp->smk_cipso == NULL) {
582 scp = kzalloc(sizeof(struct smack_cipso), GFP_KERNEL);
589 spin_lock_bh(&skp->smk_cipsolock);
592 scp = skp->smk_cipso;
594 skp->smk_cipso = scp;
596 scp->smk_level = maplevel;
597 memcpy(scp->smk_catset, mapcatset, sizeof(mapcatset));
599 spin_unlock_bh(&skp->smk_cipsolock);
603 mutex_unlock(&smack_cipso_lock);
609 static const struct file_operations smk_cipso_ops = {
610 .open = smk_open_cipso,
613 .write = smk_write_cipso,
614 .release = seq_release,
618 * smk_read_doi - read() for /smack/doi
619 * @filp: file pointer, not actually used
620 * @buf: where to put the result
621 * @count: maximum to send along
622 * @ppos: where to start
624 * Returns number of bytes read or error code, as appropriate
626 static ssize_t smk_read_doi(struct file *filp, char __user *buf,
627 size_t count, loff_t *ppos)
635 sprintf(temp, "%d", smk_cipso_doi_value);
636 rc = simple_read_from_buffer(buf, count, ppos, temp, strlen(temp));
642 * smk_write_doi - write() for /smack/doi
643 * @filp: file pointer, not actually used
644 * @buf: where to get the data from
646 * @ppos: where to start
648 * Returns number of bytes written or error code, as appropriate
650 static ssize_t smk_write_doi(struct file *file, const char __user *buf,
651 size_t count, loff_t *ppos)
656 if (!capable(CAP_MAC_ADMIN))
659 if (count >= sizeof(temp) || count == 0)
662 if (copy_from_user(temp, buf, count) != 0)
667 if (sscanf(temp, "%d", &i) != 1)
670 smk_cipso_doi_value = i;
677 static const struct file_operations smk_doi_ops = {
678 .read = smk_read_doi,
679 .write = smk_write_doi,
683 * smk_read_direct - read() for /smack/direct
684 * @filp: file pointer, not actually used
685 * @buf: where to put the result
686 * @count: maximum to send along
687 * @ppos: where to start
689 * Returns number of bytes read or error code, as appropriate
691 static ssize_t smk_read_direct(struct file *filp, char __user *buf,
692 size_t count, loff_t *ppos)
700 sprintf(temp, "%d", smack_cipso_direct);
701 rc = simple_read_from_buffer(buf, count, ppos, temp, strlen(temp));
707 * smk_write_direct - write() for /smack/direct
708 * @filp: file pointer, not actually used
709 * @buf: where to get the data from
711 * @ppos: where to start
713 * Returns number of bytes written or error code, as appropriate
715 static ssize_t smk_write_direct(struct file *file, const char __user *buf,
716 size_t count, loff_t *ppos)
721 if (!capable(CAP_MAC_ADMIN))
724 if (count >= sizeof(temp) || count == 0)
727 if (copy_from_user(temp, buf, count) != 0)
732 if (sscanf(temp, "%d", &i) != 1)
735 smack_cipso_direct = i;
740 static const struct file_operations smk_direct_ops = {
741 .read = smk_read_direct,
742 .write = smk_write_direct,
746 * smk_read_ambient - read() for /smack/ambient
747 * @filp: file pointer, not actually used
748 * @buf: where to put the result
749 * @cn: maximum to send along
750 * @ppos: where to start
752 * Returns number of bytes read or error code, as appropriate
754 static ssize_t smk_read_ambient(struct file *filp, char __user *buf,
755 size_t cn, loff_t *ppos)
763 * Being careful to avoid a problem in the case where
764 * smack_net_ambient gets changed in midstream.
766 mutex_lock(&smack_ambient_lock);
768 asize = strlen(smack_net_ambient) + 1;
771 rc = simple_read_from_buffer(buf, cn, ppos,
772 smack_net_ambient, asize);
776 mutex_unlock(&smack_ambient_lock);
782 * smk_write_ambient - write() for /smack/ambient
783 * @filp: file pointer, not actually used
784 * @buf: where to get the data from
786 * @ppos: where to start
788 * Returns number of bytes written or error code, as appropriate
790 static ssize_t smk_write_ambient(struct file *file, const char __user *buf,
791 size_t count, loff_t *ppos)
793 char in[SMK_LABELLEN];
797 if (!capable(CAP_MAC_ADMIN))
800 if (count >= SMK_LABELLEN)
803 if (copy_from_user(in, buf, count) != 0)
806 smack = smk_import(in, count);
810 mutex_lock(&smack_ambient_lock);
812 oldambient = smack_net_ambient;
813 smack_net_ambient = smack;
814 smk_unlbl_ambient(oldambient);
816 mutex_unlock(&smack_ambient_lock);
821 static const struct file_operations smk_ambient_ops = {
822 .read = smk_read_ambient,
823 .write = smk_write_ambient,
827 * smk_read_onlycap - read() for /smack/onlycap
828 * @filp: file pointer, not actually used
829 * @buf: where to put the result
830 * @cn: maximum to send along
831 * @ppos: where to start
833 * Returns number of bytes read or error code, as appropriate
835 static ssize_t smk_read_onlycap(struct file *filp, char __user *buf,
836 size_t cn, loff_t *ppos)
839 ssize_t rc = -EINVAL;
845 if (smack_onlycap != NULL)
846 smack = smack_onlycap;
848 asize = strlen(smack) + 1;
851 rc = simple_read_from_buffer(buf, cn, ppos, smack, asize);
857 * smk_write_onlycap - write() for /smack/onlycap
858 * @filp: file pointer, not actually used
859 * @buf: where to get the data from
861 * @ppos: where to start
863 * Returns number of bytes written or error code, as appropriate
865 static ssize_t smk_write_onlycap(struct file *file, const char __user *buf,
866 size_t count, loff_t *ppos)
868 char in[SMK_LABELLEN];
869 char *sp = current->cred->security;
871 if (!capable(CAP_MAC_ADMIN))
875 * This can be done using smk_access() but is done
876 * explicitly for clarity. The smk_access() implementation
877 * would use smk_access(smack_onlycap, MAY_WRITE)
879 if (smack_onlycap != NULL && smack_onlycap != sp)
882 if (count >= SMK_LABELLEN)
885 if (copy_from_user(in, buf, count) != 0)
889 * Should the null string be passed in unset the onlycap value.
890 * This seems like something to be careful with as usually
891 * smk_import only expects to return NULL for errors. It
892 * is usually the case that a nullstring or "\n" would be
893 * bad to pass to smk_import but in fact this is useful here.
895 smack_onlycap = smk_import(in, count);
900 static const struct file_operations smk_onlycap_ops = {
901 .read = smk_read_onlycap,
902 .write = smk_write_onlycap,
905 struct option_names {
911 static struct option_names netlbl_choices[] = {
912 { NETLBL_NLTYPE_RIPSO,
913 NETLBL_NLTYPE_RIPSO_NAME, "ripso" },
914 { NETLBL_NLTYPE_CIPSOV4,
915 NETLBL_NLTYPE_CIPSOV4_NAME, "cipsov4" },
916 { NETLBL_NLTYPE_CIPSOV4,
917 NETLBL_NLTYPE_CIPSOV4_NAME, "cipso" },
918 { NETLBL_NLTYPE_CIPSOV6,
919 NETLBL_NLTYPE_CIPSOV6_NAME, "cipsov6" },
920 { NETLBL_NLTYPE_UNLABELED,
921 NETLBL_NLTYPE_UNLABELED_NAME, "unlabeled" },
925 * smk_read_nltype - read() for /smack/nltype
926 * @filp: file pointer, not actually used
927 * @buf: where to put the result
928 * @count: maximum to send along
929 * @ppos: where to start
931 * Returns number of bytes read or error code, as appropriate
933 static ssize_t smk_read_nltype(struct file *filp, char __user *buf,
934 size_t count, loff_t *ppos)
940 if (count < SMK_LABELLEN)
946 sprintf(bound, "unknown");
948 for (i = 0; i < ARRAY_SIZE(netlbl_choices); i++)
949 if (smack_net_nltype == netlbl_choices[i].o_number) {
950 sprintf(bound, "%s", netlbl_choices[i].o_name);
954 rc = simple_read_from_buffer(buf, count, ppos, bound, strlen(bound));
960 * smk_write_nltype - write() for /smack/nltype
961 * @filp: file pointer, not actually used
962 * @buf: where to get the data from
964 * @ppos: where to start
966 * Returns number of bytes written or error code, as appropriate
968 static ssize_t smk_write_nltype(struct file *file, const char __user *buf,
969 size_t count, loff_t *ppos)
975 if (!capable(CAP_MAC_ADMIN))
981 if (copy_from_user(bound, buf, count) != 0)
985 cp = strchr(bound, ' ');
988 cp = strchr(bound, '\n');
992 for (i = 0; i < ARRAY_SIZE(netlbl_choices); i++)
993 if (strcmp(bound, netlbl_choices[i].o_name) == 0 ||
994 strcmp(bound, netlbl_choices[i].o_alias) == 0) {
995 smack_net_nltype = netlbl_choices[i].o_number;
999 * Not a valid choice.
1004 static const struct file_operations smk_nltype_ops = {
1005 .read = smk_read_nltype,
1006 .write = smk_write_nltype,
1010 * smk_fill_super - fill the /smackfs superblock
1011 * @sb: the empty superblock
1015 * Fill in the well known entries for /smack
1017 * Returns 0 on success, an error code on failure
1019 static int smk_fill_super(struct super_block *sb, void *data, int silent)
1022 struct inode *root_inode;
1024 static struct tree_descr smack_files[] = {
1026 {"load", &smk_load_ops, S_IRUGO|S_IWUSR},
1028 {"cipso", &smk_cipso_ops, S_IRUGO|S_IWUSR},
1030 {"doi", &smk_doi_ops, S_IRUGO|S_IWUSR},
1032 {"direct", &smk_direct_ops, S_IRUGO|S_IWUSR},
1034 {"ambient", &smk_ambient_ops, S_IRUGO|S_IWUSR},
1036 {"nltype", &smk_nltype_ops, S_IRUGO|S_IWUSR},
1038 {"onlycap", &smk_onlycap_ops, S_IRUGO|S_IWUSR},
1042 rc = simple_fill_super(sb, SMACK_MAGIC, smack_files);
1044 printk(KERN_ERR "%s failed %d while creating inodes\n",
1049 root_inode = sb->s_root->d_inode;
1050 root_inode->i_security = new_inode_smack(smack_known_floor.smk_known);
1056 * smk_get_sb - get the smackfs superblock
1057 * @fs_type: passed along without comment
1058 * @flags: passed along without comment
1059 * @dev_name: passed along without comment
1060 * @data: passed along without comment
1061 * @mnt: passed along without comment
1063 * Just passes everything along.
1065 * Returns what the lower level code does.
1067 static int smk_get_sb(struct file_system_type *fs_type,
1068 int flags, const char *dev_name, void *data,
1069 struct vfsmount *mnt)
1071 return get_sb_single(fs_type, flags, data, smk_fill_super, mnt);
1074 static struct file_system_type smk_fs_type = {
1076 .get_sb = smk_get_sb,
1077 .kill_sb = kill_litter_super,
1080 static struct vfsmount *smackfs_mount;
1083 * init_smk_fs - get the smackfs superblock
1085 * register the smackfs
1087 * Do not register smackfs if Smack wasn't enabled
1088 * on boot. We can not put this method normally under the
1089 * smack_init() code path since the security subsystem get
1090 * initialized before the vfs caches.
1092 * Returns true if we were not chosen on boot or if
1093 * we were chosen and filesystem registration succeeded.
1095 static int __init init_smk_fs(void)
1099 if (!security_module_enable(&smack_ops))
1102 err = register_filesystem(&smk_fs_type);
1104 smackfs_mount = kern_mount(&smk_fs_type);
1105 if (IS_ERR(smackfs_mount)) {
1106 printk(KERN_ERR "smackfs: could not mount!\n");
1107 err = PTR_ERR(smackfs_mount);
1108 smackfs_mount = NULL;
1113 smk_unlbl_ambient(NULL);
1118 __initcall(init_smk_fs);