1 /* Updated: Karl MacMillan <kmacmillan@tresys.com>
3 * Added conditional policy language extensions
5 * Updated: Hewlett-Packard <paul.moore@hp.com>
7 * Added support for the policy capability bitmap
9 * Copyright (C) 2007 Hewlett-Packard Development Company, L.P.
10 * Copyright (C) 2003 - 2004 Tresys Technology, LLC
11 * Copyright (C) 2004 Red Hat, Inc., James Morris <jmorris@redhat.com>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation, version 2.
17 #include <linux/kernel.h>
18 #include <linux/pagemap.h>
19 #include <linux/slab.h>
20 #include <linux/vmalloc.h>
22 #include <linux/mutex.h>
23 #include <linux/init.h>
24 #include <linux/string.h>
25 #include <linux/security.h>
26 #include <linux/major.h>
27 #include <linux/seq_file.h>
28 #include <linux/percpu.h>
29 #include <linux/audit.h>
30 #include <linux/uaccess.h>
31 #include <linux/kobject.h>
33 /* selinuxfs pseudo filesystem for exporting the security policy API.
34 Based on the proc code and the fs/nfsd/nfsctl.c code. */
41 #include "conditional.h"
43 /* Policy capability filenames */
44 static char *policycap_names
[] = {
45 "network_peer_controls",
49 unsigned int selinux_checkreqprot
= CONFIG_SECURITY_SELINUX_CHECKREQPROT_VALUE
;
51 static int __init
checkreqprot_setup(char *str
)
53 unsigned long checkreqprot
;
54 if (!strict_strtoul(str
, 0, &checkreqprot
))
55 selinux_checkreqprot
= checkreqprot
? 1 : 0;
58 __setup("checkreqprot=", checkreqprot_setup
);
60 static DEFINE_MUTEX(sel_mutex
);
62 /* global data for booleans */
63 static struct dentry
*bool_dir
;
65 static char **bool_pending_names
;
66 static int *bool_pending_values
;
68 /* global data for classes */
69 static struct dentry
*class_dir
;
70 static unsigned long last_class_ino
;
72 static char policy_opened
;
74 /* global data for policy capabilities */
75 static struct dentry
*policycap_dir
;
77 extern void selnl_notify_setenforce(int val
);
79 /* Check whether a task is allowed to use a security operation. */
80 static int task_has_security(struct task_struct
*tsk
,
83 const struct task_security_struct
*tsec
;
87 tsec
= __task_cred(tsk
)->security
;
94 return avc_has_perm(sid
, SECINITSID_SECURITY
,
95 SECCLASS_SECURITY
, perms
, NULL
);
100 SEL_LOAD
, /* load policy */
101 SEL_ENFORCE
, /* get or set enforcing status */
102 SEL_CONTEXT
, /* validate context */
103 SEL_ACCESS
, /* compute access decision */
104 SEL_CREATE
, /* compute create labeling decision */
105 SEL_RELABEL
, /* compute relabeling decision */
106 SEL_USER
, /* compute reachable user contexts */
107 SEL_POLICYVERS
, /* return policy version for this kernel */
108 SEL_COMMIT_BOOLS
, /* commit new boolean values */
109 SEL_MLS
, /* return if MLS policy is enabled */
110 SEL_DISABLE
, /* disable SELinux until next reboot */
111 SEL_MEMBER
, /* compute polyinstantiation membership decision */
112 SEL_CHECKREQPROT
, /* check requested protection, not kernel-applied one */
113 SEL_COMPAT_NET
, /* whether to use old compat network packet controls */
114 SEL_REJECT_UNKNOWN
, /* export unknown reject handling to userspace */
115 SEL_DENY_UNKNOWN
, /* export unknown deny handling to userspace */
116 SEL_STATUS
, /* export current status using mmap() */
117 SEL_POLICY
, /* allow userspace to read the in kernel policy */
118 SEL_INO_NEXT
, /* The next inode number to use */
121 static unsigned long sel_last_ino
= SEL_INO_NEXT
- 1;
123 #define SEL_INITCON_INO_OFFSET 0x01000000
124 #define SEL_BOOL_INO_OFFSET 0x02000000
125 #define SEL_CLASS_INO_OFFSET 0x04000000
126 #define SEL_POLICYCAP_INO_OFFSET 0x08000000
127 #define SEL_INO_MASK 0x00ffffff
130 static ssize_t
sel_read_enforce(struct file
*filp
, char __user
*buf
,
131 size_t count
, loff_t
*ppos
)
133 char tmpbuf
[TMPBUFLEN
];
136 length
= scnprintf(tmpbuf
, TMPBUFLEN
, "%d", selinux_enforcing
);
137 return simple_read_from_buffer(buf
, count
, ppos
, tmpbuf
, length
);
140 #ifdef CONFIG_SECURITY_SELINUX_DEVELOP
141 static ssize_t
sel_write_enforce(struct file
*file
, const char __user
*buf
,
142 size_t count
, loff_t
*ppos
)
150 if (count
>= PAGE_SIZE
)
153 /* No partial writes. */
159 page
= (char *)get_zeroed_page(GFP_KERNEL
);
164 if (copy_from_user(page
, buf
, count
))
168 if (sscanf(page
, "%d", &new_value
) != 1)
171 if (new_value
!= selinux_enforcing
) {
172 length
= task_has_security(current
, SECURITY__SETENFORCE
);
175 audit_log(current
->audit_context
, GFP_KERNEL
, AUDIT_MAC_STATUS
,
176 "enforcing=%d old_enforcing=%d auid=%u ses=%u",
177 new_value
, selinux_enforcing
,
178 audit_get_loginuid(current
),
179 audit_get_sessionid(current
));
180 selinux_enforcing
= new_value
;
181 if (selinux_enforcing
)
183 selnl_notify_setenforce(selinux_enforcing
);
184 selinux_status_update_setenforce(selinux_enforcing
);
188 free_page((unsigned long) page
);
192 #define sel_write_enforce NULL
195 static const struct file_operations sel_enforce_ops
= {
196 .read
= sel_read_enforce
,
197 .write
= sel_write_enforce
,
198 .llseek
= generic_file_llseek
,
201 static ssize_t
sel_read_handle_unknown(struct file
*filp
, char __user
*buf
,
202 size_t count
, loff_t
*ppos
)
204 char tmpbuf
[TMPBUFLEN
];
206 ino_t ino
= filp
->f_path
.dentry
->d_inode
->i_ino
;
207 int handle_unknown
= (ino
== SEL_REJECT_UNKNOWN
) ?
208 security_get_reject_unknown() : !security_get_allow_unknown();
210 length
= scnprintf(tmpbuf
, TMPBUFLEN
, "%d", handle_unknown
);
211 return simple_read_from_buffer(buf
, count
, ppos
, tmpbuf
, length
);
214 static const struct file_operations sel_handle_unknown_ops
= {
215 .read
= sel_read_handle_unknown
,
216 .llseek
= generic_file_llseek
,
219 static int sel_open_handle_status(struct inode
*inode
, struct file
*filp
)
221 struct page
*status
= selinux_kernel_status_page();
226 filp
->private_data
= status
;
231 static ssize_t
sel_read_handle_status(struct file
*filp
, char __user
*buf
,
232 size_t count
, loff_t
*ppos
)
234 struct page
*status
= filp
->private_data
;
238 return simple_read_from_buffer(buf
, count
, ppos
,
239 page_address(status
),
240 sizeof(struct selinux_kernel_status
));
243 static int sel_mmap_handle_status(struct file
*filp
,
244 struct vm_area_struct
*vma
)
246 struct page
*status
= filp
->private_data
;
247 unsigned long size
= vma
->vm_end
- vma
->vm_start
;
251 /* only allows one page from the head */
252 if (vma
->vm_pgoff
> 0 || size
!= PAGE_SIZE
)
254 /* disallow writable mapping */
255 if (vma
->vm_flags
& VM_WRITE
)
257 /* disallow mprotect() turns it into writable */
258 vma
->vm_flags
&= ~VM_MAYWRITE
;
260 return remap_pfn_range(vma
, vma
->vm_start
,
262 size
, vma
->vm_page_prot
);
265 static const struct file_operations sel_handle_status_ops
= {
266 .open
= sel_open_handle_status
,
267 .read
= sel_read_handle_status
,
268 .mmap
= sel_mmap_handle_status
,
269 .llseek
= generic_file_llseek
,
272 #ifdef CONFIG_SECURITY_SELINUX_DISABLE
273 static ssize_t
sel_write_disable(struct file
*file
, const char __user
*buf
,
274 size_t count
, loff_t
*ppos
)
280 extern int selinux_disable(void);
283 if (count
>= PAGE_SIZE
)
286 /* No partial writes. */
292 page
= (char *)get_zeroed_page(GFP_KERNEL
);
297 if (copy_from_user(page
, buf
, count
))
301 if (sscanf(page
, "%d", &new_value
) != 1)
305 length
= selinux_disable();
308 audit_log(current
->audit_context
, GFP_KERNEL
, AUDIT_MAC_STATUS
,
309 "selinux=0 auid=%u ses=%u",
310 audit_get_loginuid(current
),
311 audit_get_sessionid(current
));
316 free_page((unsigned long) page
);
320 #define sel_write_disable NULL
323 static const struct file_operations sel_disable_ops
= {
324 .write
= sel_write_disable
,
325 .llseek
= generic_file_llseek
,
328 static ssize_t
sel_read_policyvers(struct file
*filp
, char __user
*buf
,
329 size_t count
, loff_t
*ppos
)
331 char tmpbuf
[TMPBUFLEN
];
334 length
= scnprintf(tmpbuf
, TMPBUFLEN
, "%u", POLICYDB_VERSION_MAX
);
335 return simple_read_from_buffer(buf
, count
, ppos
, tmpbuf
, length
);
338 static const struct file_operations sel_policyvers_ops
= {
339 .read
= sel_read_policyvers
,
340 .llseek
= generic_file_llseek
,
343 /* declaration for sel_write_load */
344 static int sel_make_bools(void);
345 static int sel_make_classes(void);
346 static int sel_make_policycap(void);
348 /* declaration for sel_make_class_dirs */
349 static int sel_make_dir(struct inode
*dir
, struct dentry
*dentry
,
352 static ssize_t
sel_read_mls(struct file
*filp
, char __user
*buf
,
353 size_t count
, loff_t
*ppos
)
355 char tmpbuf
[TMPBUFLEN
];
358 length
= scnprintf(tmpbuf
, TMPBUFLEN
, "%d",
359 security_mls_enabled());
360 return simple_read_from_buffer(buf
, count
, ppos
, tmpbuf
, length
);
363 static const struct file_operations sel_mls_ops
= {
364 .read
= sel_read_mls
,
365 .llseek
= generic_file_llseek
,
368 struct policy_load_memory
{
373 static int sel_open_policy(struct inode
*inode
, struct file
*filp
)
375 struct policy_load_memory
*plm
= NULL
;
378 BUG_ON(filp
->private_data
);
380 mutex_lock(&sel_mutex
);
382 rc
= task_has_security(current
, SECURITY__READ_POLICY
);
391 plm
= kzalloc(sizeof(*plm
), GFP_KERNEL
);
395 if (i_size_read(inode
) != security_policydb_len()) {
396 mutex_lock(&inode
->i_mutex
);
397 i_size_write(inode
, security_policydb_len());
398 mutex_unlock(&inode
->i_mutex
);
401 rc
= security_read_policy(&plm
->data
, &plm
->len
);
407 filp
->private_data
= plm
;
409 mutex_unlock(&sel_mutex
);
413 mutex_unlock(&sel_mutex
);
421 static int sel_release_policy(struct inode
*inode
, struct file
*filp
)
423 struct policy_load_memory
*plm
= filp
->private_data
;
435 static ssize_t
sel_read_policy(struct file
*filp
, char __user
*buf
,
436 size_t count
, loff_t
*ppos
)
438 struct policy_load_memory
*plm
= filp
->private_data
;
441 mutex_lock(&sel_mutex
);
443 ret
= task_has_security(current
, SECURITY__READ_POLICY
);
447 ret
= simple_read_from_buffer(buf
, count
, ppos
, plm
->data
, plm
->len
);
449 mutex_unlock(&sel_mutex
);
453 static int sel_mmap_policy_fault(struct vm_area_struct
*vma
,
454 struct vm_fault
*vmf
)
456 struct policy_load_memory
*plm
= vma
->vm_file
->private_data
;
457 unsigned long offset
;
460 if (vmf
->flags
& (FAULT_FLAG_MKWRITE
| FAULT_FLAG_WRITE
))
461 return VM_FAULT_SIGBUS
;
463 offset
= vmf
->pgoff
<< PAGE_SHIFT
;
464 if (offset
>= roundup(plm
->len
, PAGE_SIZE
))
465 return VM_FAULT_SIGBUS
;
467 page
= vmalloc_to_page(plm
->data
+ offset
);
475 static struct vm_operations_struct sel_mmap_policy_ops
= {
476 .fault
= sel_mmap_policy_fault
,
477 .page_mkwrite
= sel_mmap_policy_fault
,
480 int sel_mmap_policy(struct file
*filp
, struct vm_area_struct
*vma
)
482 if (vma
->vm_flags
& VM_SHARED
) {
483 /* do not allow mprotect to make mapping writable */
484 vma
->vm_flags
&= ~VM_MAYWRITE
;
486 if (vma
->vm_flags
& VM_WRITE
)
490 vma
->vm_flags
|= VM_RESERVED
;
491 vma
->vm_ops
= &sel_mmap_policy_ops
;
496 static const struct file_operations sel_policy_ops
= {
497 .open
= sel_open_policy
,
498 .read
= sel_read_policy
,
499 .mmap
= sel_mmap_policy
,
500 .release
= sel_release_policy
,
503 static ssize_t
sel_write_load(struct file
*file
, const char __user
*buf
,
504 size_t count
, loff_t
*ppos
)
510 mutex_lock(&sel_mutex
);
512 length
= task_has_security(current
, SECURITY__LOAD_POLICY
);
516 /* No partial writes. */
522 if (count
> 64 * 1024 * 1024)
526 data
= vmalloc(count
);
531 if (copy_from_user(data
, buf
, count
) != 0)
534 length
= security_load_policy(data
, count
);
538 length
= sel_make_bools();
542 length
= sel_make_classes();
546 length
= sel_make_policycap();
553 audit_log(current
->audit_context
, GFP_KERNEL
, AUDIT_MAC_POLICY_LOAD
,
554 "policy loaded auid=%u ses=%u",
555 audit_get_loginuid(current
),
556 audit_get_sessionid(current
));
558 mutex_unlock(&sel_mutex
);
563 static const struct file_operations sel_load_ops
= {
564 .write
= sel_write_load
,
565 .llseek
= generic_file_llseek
,
568 static ssize_t
sel_write_context(struct file
*file
, char *buf
, size_t size
)
574 length
= task_has_security(current
, SECURITY__CHECK_CONTEXT
);
578 length
= security_context_to_sid(buf
, size
, &sid
);
582 length
= security_sid_to_context(sid
, &canon
, &len
);
587 if (len
> SIMPLE_TRANSACTION_LIMIT
) {
588 printk(KERN_ERR
"SELinux: %s: context size (%u) exceeds "
589 "payload max\n", __func__
, len
);
593 memcpy(buf
, canon
, len
);
600 static ssize_t
sel_read_checkreqprot(struct file
*filp
, char __user
*buf
,
601 size_t count
, loff_t
*ppos
)
603 char tmpbuf
[TMPBUFLEN
];
606 length
= scnprintf(tmpbuf
, TMPBUFLEN
, "%u", selinux_checkreqprot
);
607 return simple_read_from_buffer(buf
, count
, ppos
, tmpbuf
, length
);
610 static ssize_t
sel_write_checkreqprot(struct file
*file
, const char __user
*buf
,
611 size_t count
, loff_t
*ppos
)
615 unsigned int new_value
;
617 length
= task_has_security(current
, SECURITY__SETCHECKREQPROT
);
622 if (count
>= PAGE_SIZE
)
625 /* No partial writes. */
631 page
= (char *)get_zeroed_page(GFP_KERNEL
);
636 if (copy_from_user(page
, buf
, count
))
640 if (sscanf(page
, "%u", &new_value
) != 1)
643 selinux_checkreqprot
= new_value
? 1 : 0;
646 free_page((unsigned long) page
);
649 static const struct file_operations sel_checkreqprot_ops
= {
650 .read
= sel_read_checkreqprot
,
651 .write
= sel_write_checkreqprot
,
652 .llseek
= generic_file_llseek
,
656 * Remaining nodes use transaction based IO methods like nfsd/nfsctl.c
658 static ssize_t
sel_write_access(struct file
*file
, char *buf
, size_t size
);
659 static ssize_t
sel_write_create(struct file
*file
, char *buf
, size_t size
);
660 static ssize_t
sel_write_relabel(struct file
*file
, char *buf
, size_t size
);
661 static ssize_t
sel_write_user(struct file
*file
, char *buf
, size_t size
);
662 static ssize_t
sel_write_member(struct file
*file
, char *buf
, size_t size
);
664 static ssize_t (*write_op
[])(struct file
*, char *, size_t) = {
665 [SEL_ACCESS
] = sel_write_access
,
666 [SEL_CREATE
] = sel_write_create
,
667 [SEL_RELABEL
] = sel_write_relabel
,
668 [SEL_USER
] = sel_write_user
,
669 [SEL_MEMBER
] = sel_write_member
,
670 [SEL_CONTEXT
] = sel_write_context
,
673 static ssize_t
selinux_transaction_write(struct file
*file
, const char __user
*buf
, size_t size
, loff_t
*pos
)
675 ino_t ino
= file
->f_path
.dentry
->d_inode
->i_ino
;
679 if (ino
>= ARRAY_SIZE(write_op
) || !write_op
[ino
])
682 data
= simple_transaction_get(file
, buf
, size
);
684 return PTR_ERR(data
);
686 rv
= write_op
[ino
](file
, data
, size
);
688 simple_transaction_set(file
, rv
);
694 static const struct file_operations transaction_ops
= {
695 .write
= selinux_transaction_write
,
696 .read
= simple_transaction_read
,
697 .release
= simple_transaction_release
,
698 .llseek
= generic_file_llseek
,
702 * payload - write methods
703 * If the method has a response, the response should be put in buf,
704 * and the length returned. Otherwise return 0 or and -error.
707 static ssize_t
sel_write_access(struct file
*file
, char *buf
, size_t size
)
709 char *scon
= NULL
, *tcon
= NULL
;
712 struct av_decision avd
;
715 length
= task_has_security(current
, SECURITY__COMPUTE_AV
);
720 scon
= kzalloc(size
+ 1, GFP_KERNEL
);
725 tcon
= kzalloc(size
+ 1, GFP_KERNEL
);
730 if (sscanf(buf
, "%s %s %hu", scon
, tcon
, &tclass
) != 3)
733 length
= security_context_to_sid(scon
, strlen(scon
) + 1, &ssid
);
737 length
= security_context_to_sid(tcon
, strlen(tcon
) + 1, &tsid
);
741 security_compute_av_user(ssid
, tsid
, tclass
, &avd
);
743 length
= scnprintf(buf
, SIMPLE_TRANSACTION_LIMIT
,
745 avd
.allowed
, 0xffffffff,
746 avd
.auditallow
, avd
.auditdeny
,
747 avd
.seqno
, avd
.flags
);
754 static ssize_t
sel_write_create(struct file
*file
, char *buf
, size_t size
)
756 char *scon
= NULL
, *tcon
= NULL
;
757 char *namebuf
= NULL
, *objname
= NULL
;
758 u32 ssid
, tsid
, newsid
;
765 length
= task_has_security(current
, SECURITY__COMPUTE_CREATE
);
770 scon
= kzalloc(size
+ 1, GFP_KERNEL
);
775 tcon
= kzalloc(size
+ 1, GFP_KERNEL
);
780 namebuf
= kzalloc(size
+ 1, GFP_KERNEL
);
785 nargs
= sscanf(buf
, "%s %s %hu %s", scon
, tcon
, &tclass
, namebuf
);
786 if (nargs
< 3 || nargs
> 4)
791 length
= security_context_to_sid(scon
, strlen(scon
) + 1, &ssid
);
795 length
= security_context_to_sid(tcon
, strlen(tcon
) + 1, &tsid
);
799 length
= security_transition_sid_user(ssid
, tsid
, tclass
,
804 length
= security_sid_to_context(newsid
, &newcon
, &len
);
809 if (len
> SIMPLE_TRANSACTION_LIMIT
) {
810 printk(KERN_ERR
"SELinux: %s: context size (%u) exceeds "
811 "payload max\n", __func__
, len
);
815 memcpy(buf
, newcon
, len
);
825 static ssize_t
sel_write_relabel(struct file
*file
, char *buf
, size_t size
)
827 char *scon
= NULL
, *tcon
= NULL
;
828 u32 ssid
, tsid
, newsid
;
834 length
= task_has_security(current
, SECURITY__COMPUTE_RELABEL
);
839 scon
= kzalloc(size
+ 1, GFP_KERNEL
);
844 tcon
= kzalloc(size
+ 1, GFP_KERNEL
);
849 if (sscanf(buf
, "%s %s %hu", scon
, tcon
, &tclass
) != 3)
852 length
= security_context_to_sid(scon
, strlen(scon
) + 1, &ssid
);
856 length
= security_context_to_sid(tcon
, strlen(tcon
) + 1, &tsid
);
860 length
= security_change_sid(ssid
, tsid
, tclass
, &newsid
);
864 length
= security_sid_to_context(newsid
, &newcon
, &len
);
869 if (len
> SIMPLE_TRANSACTION_LIMIT
)
872 memcpy(buf
, newcon
, len
);
881 static ssize_t
sel_write_user(struct file
*file
, char *buf
, size_t size
)
883 char *con
= NULL
, *user
= NULL
, *ptr
;
884 u32 sid
, *sids
= NULL
;
890 length
= task_has_security(current
, SECURITY__COMPUTE_USER
);
895 con
= kzalloc(size
+ 1, GFP_KERNEL
);
900 user
= kzalloc(size
+ 1, GFP_KERNEL
);
905 if (sscanf(buf
, "%s %s", con
, user
) != 2)
908 length
= security_context_to_sid(con
, strlen(con
) + 1, &sid
);
912 length
= security_get_user_sids(sid
, user
, &sids
, &nsids
);
916 length
= sprintf(buf
, "%u", nsids
) + 1;
918 for (i
= 0; i
< nsids
; i
++) {
919 rc
= security_sid_to_context(sids
[i
], &newcon
, &len
);
924 if ((length
+ len
) >= SIMPLE_TRANSACTION_LIMIT
) {
929 memcpy(ptr
, newcon
, len
);
941 static ssize_t
sel_write_member(struct file
*file
, char *buf
, size_t size
)
943 char *scon
= NULL
, *tcon
= NULL
;
944 u32 ssid
, tsid
, newsid
;
950 length
= task_has_security(current
, SECURITY__COMPUTE_MEMBER
);
955 scon
= kzalloc(size
+ 1, GFP_KERNEL
);
960 tcon
= kzalloc(size
+ 1, GFP_KERNEL
);
965 if (sscanf(buf
, "%s %s %hu", scon
, tcon
, &tclass
) != 3)
968 length
= security_context_to_sid(scon
, strlen(scon
) + 1, &ssid
);
972 length
= security_context_to_sid(tcon
, strlen(tcon
) + 1, &tsid
);
976 length
= security_member_sid(ssid
, tsid
, tclass
, &newsid
);
980 length
= security_sid_to_context(newsid
, &newcon
, &len
);
985 if (len
> SIMPLE_TRANSACTION_LIMIT
) {
986 printk(KERN_ERR
"SELinux: %s: context size (%u) exceeds "
987 "payload max\n", __func__
, len
);
991 memcpy(buf
, newcon
, len
);
1000 static struct inode
*sel_make_inode(struct super_block
*sb
, int mode
)
1002 struct inode
*ret
= new_inode(sb
);
1006 ret
->i_atime
= ret
->i_mtime
= ret
->i_ctime
= CURRENT_TIME
;
1011 static ssize_t
sel_read_bool(struct file
*filep
, char __user
*buf
,
1012 size_t count
, loff_t
*ppos
)
1018 struct inode
*inode
= filep
->f_path
.dentry
->d_inode
;
1019 unsigned index
= inode
->i_ino
& SEL_INO_MASK
;
1020 const char *name
= filep
->f_path
.dentry
->d_name
.name
;
1022 mutex_lock(&sel_mutex
);
1025 if (index
>= bool_num
|| strcmp(name
, bool_pending_names
[index
]))
1029 page
= (char *)get_zeroed_page(GFP_KERNEL
);
1033 cur_enforcing
= security_get_bool_value(index
);
1034 if (cur_enforcing
< 0) {
1035 ret
= cur_enforcing
;
1038 length
= scnprintf(page
, PAGE_SIZE
, "%d %d", cur_enforcing
,
1039 bool_pending_values
[index
]);
1040 ret
= simple_read_from_buffer(buf
, count
, ppos
, page
, length
);
1042 mutex_unlock(&sel_mutex
);
1043 free_page((unsigned long)page
);
1047 static ssize_t
sel_write_bool(struct file
*filep
, const char __user
*buf
,
1048 size_t count
, loff_t
*ppos
)
1053 struct inode
*inode
= filep
->f_path
.dentry
->d_inode
;
1054 unsigned index
= inode
->i_ino
& SEL_INO_MASK
;
1055 const char *name
= filep
->f_path
.dentry
->d_name
.name
;
1057 mutex_lock(&sel_mutex
);
1059 length
= task_has_security(current
, SECURITY__SETBOOL
);
1064 if (index
>= bool_num
|| strcmp(name
, bool_pending_names
[index
]))
1068 if (count
>= PAGE_SIZE
)
1071 /* No partial writes. */
1077 page
= (char *)get_zeroed_page(GFP_KERNEL
);
1082 if (copy_from_user(page
, buf
, count
))
1086 if (sscanf(page
, "%d", &new_value
) != 1)
1092 bool_pending_values
[index
] = new_value
;
1096 mutex_unlock(&sel_mutex
);
1097 free_page((unsigned long) page
);
1101 static const struct file_operations sel_bool_ops
= {
1102 .read
= sel_read_bool
,
1103 .write
= sel_write_bool
,
1104 .llseek
= generic_file_llseek
,
1107 static ssize_t
sel_commit_bools_write(struct file
*filep
,
1108 const char __user
*buf
,
1109 size_t count
, loff_t
*ppos
)
1115 mutex_lock(&sel_mutex
);
1117 length
= task_has_security(current
, SECURITY__SETBOOL
);
1122 if (count
>= PAGE_SIZE
)
1125 /* No partial writes. */
1131 page
= (char *)get_zeroed_page(GFP_KERNEL
);
1136 if (copy_from_user(page
, buf
, count
))
1140 if (sscanf(page
, "%d", &new_value
) != 1)
1144 if (new_value
&& bool_pending_values
)
1145 length
= security_set_bools(bool_num
, bool_pending_values
);
1151 mutex_unlock(&sel_mutex
);
1152 free_page((unsigned long) page
);
1156 static const struct file_operations sel_commit_bools_ops
= {
1157 .write
= sel_commit_bools_write
,
1158 .llseek
= generic_file_llseek
,
1161 static void sel_remove_entries(struct dentry
*de
)
1163 struct list_head
*node
;
1165 spin_lock(&de
->d_lock
);
1166 node
= de
->d_subdirs
.next
;
1167 while (node
!= &de
->d_subdirs
) {
1168 struct dentry
*d
= list_entry(node
, struct dentry
, d_u
.d_child
);
1170 spin_lock_nested(&d
->d_lock
, DENTRY_D_LOCK_NESTED
);
1171 list_del_init(node
);
1175 spin_unlock(&de
->d_lock
);
1176 spin_unlock(&d
->d_lock
);
1178 simple_unlink(de
->d_inode
, d
);
1180 spin_lock(&de
->d_lock
);
1182 spin_unlock(&d
->d_lock
);
1183 node
= de
->d_subdirs
.next
;
1186 spin_unlock(&de
->d_lock
);
1189 #define BOOL_DIR_NAME "booleans"
1191 static int sel_make_bools(void)
1195 struct dentry
*dentry
= NULL
;
1196 struct dentry
*dir
= bool_dir
;
1197 struct inode
*inode
= NULL
;
1198 struct inode_security_struct
*isec
;
1199 char **names
= NULL
, *page
;
1204 /* remove any existing files */
1205 for (i
= 0; i
< bool_num
; i
++)
1206 kfree(bool_pending_names
[i
]);
1207 kfree(bool_pending_names
);
1208 kfree(bool_pending_values
);
1209 bool_pending_names
= NULL
;
1210 bool_pending_values
= NULL
;
1212 sel_remove_entries(dir
);
1215 page
= (char *)get_zeroed_page(GFP_KERNEL
);
1219 ret
= security_get_bools(&num
, &names
, &values
);
1223 for (i
= 0; i
< num
; i
++) {
1225 dentry
= d_alloc_name(dir
, names
[i
]);
1230 inode
= sel_make_inode(dir
->d_sb
, S_IFREG
| S_IRUGO
| S_IWUSR
);
1235 len
= snprintf(page
, PAGE_SIZE
, "/%s/%s", BOOL_DIR_NAME
, names
[i
]);
1239 ret
= -ENAMETOOLONG
;
1240 if (len
>= PAGE_SIZE
)
1243 isec
= (struct inode_security_struct
*)inode
->i_security
;
1244 ret
= security_genfs_sid("selinuxfs", page
, SECCLASS_FILE
, &sid
);
1249 isec
->initialized
= 1;
1250 inode
->i_fop
= &sel_bool_ops
;
1251 inode
->i_ino
= i
|SEL_BOOL_INO_OFFSET
;
1252 d_add(dentry
, inode
);
1255 bool_pending_names
= names
;
1256 bool_pending_values
= values
;
1258 free_page((unsigned long)page
);
1261 free_page((unsigned long)page
);
1264 for (i
= 0; i
< num
; i
++)
1269 sel_remove_entries(dir
);
1274 #define NULL_FILE_NAME "null"
1276 struct dentry
*selinux_null
;
1278 static ssize_t
sel_read_avc_cache_threshold(struct file
*filp
, char __user
*buf
,
1279 size_t count
, loff_t
*ppos
)
1281 char tmpbuf
[TMPBUFLEN
];
1284 length
= scnprintf(tmpbuf
, TMPBUFLEN
, "%u", avc_cache_threshold
);
1285 return simple_read_from_buffer(buf
, count
, ppos
, tmpbuf
, length
);
1288 static ssize_t
sel_write_avc_cache_threshold(struct file
*file
,
1289 const char __user
*buf
,
1290 size_t count
, loff_t
*ppos
)
1297 ret
= task_has_security(current
, SECURITY__SETSECPARAM
);
1302 if (count
>= PAGE_SIZE
)
1305 /* No partial writes. */
1311 page
= (char *)get_zeroed_page(GFP_KERNEL
);
1316 if (copy_from_user(page
, buf
, count
))
1320 if (sscanf(page
, "%u", &new_value
) != 1)
1323 avc_cache_threshold
= new_value
;
1327 free_page((unsigned long)page
);
1331 static ssize_t
sel_read_avc_hash_stats(struct file
*filp
, char __user
*buf
,
1332 size_t count
, loff_t
*ppos
)
1337 page
= (char *)__get_free_page(GFP_KERNEL
);
1341 length
= avc_get_hash_stats(page
);
1343 length
= simple_read_from_buffer(buf
, count
, ppos
, page
, length
);
1344 free_page((unsigned long)page
);
1349 static const struct file_operations sel_avc_cache_threshold_ops
= {
1350 .read
= sel_read_avc_cache_threshold
,
1351 .write
= sel_write_avc_cache_threshold
,
1352 .llseek
= generic_file_llseek
,
1355 static const struct file_operations sel_avc_hash_stats_ops
= {
1356 .read
= sel_read_avc_hash_stats
,
1357 .llseek
= generic_file_llseek
,
1360 #ifdef CONFIG_SECURITY_SELINUX_AVC_STATS
1361 static struct avc_cache_stats
*sel_avc_get_stat_idx(loff_t
*idx
)
1365 for (cpu
= *idx
; cpu
< nr_cpu_ids
; ++cpu
) {
1366 if (!cpu_possible(cpu
))
1369 return &per_cpu(avc_cache_stats
, cpu
);
1374 static void *sel_avc_stats_seq_start(struct seq_file
*seq
, loff_t
*pos
)
1376 loff_t n
= *pos
- 1;
1379 return SEQ_START_TOKEN
;
1381 return sel_avc_get_stat_idx(&n
);
1384 static void *sel_avc_stats_seq_next(struct seq_file
*seq
, void *v
, loff_t
*pos
)
1386 return sel_avc_get_stat_idx(pos
);
1389 static int sel_avc_stats_seq_show(struct seq_file
*seq
, void *v
)
1391 struct avc_cache_stats
*st
= v
;
1393 if (v
== SEQ_START_TOKEN
)
1394 seq_printf(seq
, "lookups hits misses allocations reclaims "
1397 unsigned int lookups
= st
->lookups
;
1398 unsigned int misses
= st
->misses
;
1399 unsigned int hits
= lookups
- misses
;
1400 seq_printf(seq
, "%u %u %u %u %u %u\n", lookups
,
1401 hits
, misses
, st
->allocations
,
1402 st
->reclaims
, st
->frees
);
1407 static void sel_avc_stats_seq_stop(struct seq_file
*seq
, void *v
)
1410 static const struct seq_operations sel_avc_cache_stats_seq_ops
= {
1411 .start
= sel_avc_stats_seq_start
,
1412 .next
= sel_avc_stats_seq_next
,
1413 .show
= sel_avc_stats_seq_show
,
1414 .stop
= sel_avc_stats_seq_stop
,
1417 static int sel_open_avc_cache_stats(struct inode
*inode
, struct file
*file
)
1419 return seq_open(file
, &sel_avc_cache_stats_seq_ops
);
1422 static const struct file_operations sel_avc_cache_stats_ops
= {
1423 .open
= sel_open_avc_cache_stats
,
1425 .llseek
= seq_lseek
,
1426 .release
= seq_release
,
1430 static int sel_make_avc_files(struct dentry
*dir
)
1433 static struct tree_descr files
[] = {
1434 { "cache_threshold",
1435 &sel_avc_cache_threshold_ops
, S_IRUGO
|S_IWUSR
},
1436 { "hash_stats", &sel_avc_hash_stats_ops
, S_IRUGO
},
1437 #ifdef CONFIG_SECURITY_SELINUX_AVC_STATS
1438 { "cache_stats", &sel_avc_cache_stats_ops
, S_IRUGO
},
1442 for (i
= 0; i
< ARRAY_SIZE(files
); i
++) {
1443 struct inode
*inode
;
1444 struct dentry
*dentry
;
1446 dentry
= d_alloc_name(dir
, files
[i
].name
);
1450 inode
= sel_make_inode(dir
->d_sb
, S_IFREG
|files
[i
].mode
);
1454 inode
->i_fop
= files
[i
].ops
;
1455 inode
->i_ino
= ++sel_last_ino
;
1456 d_add(dentry
, inode
);
1462 static ssize_t
sel_read_initcon(struct file
*file
, char __user
*buf
,
1463 size_t count
, loff_t
*ppos
)
1465 struct inode
*inode
;
1470 inode
= file
->f_path
.dentry
->d_inode
;
1471 sid
= inode
->i_ino
&SEL_INO_MASK
;
1472 ret
= security_sid_to_context(sid
, &con
, &len
);
1476 ret
= simple_read_from_buffer(buf
, count
, ppos
, con
, len
);
1481 static const struct file_operations sel_initcon_ops
= {
1482 .read
= sel_read_initcon
,
1483 .llseek
= generic_file_llseek
,
1486 static int sel_make_initcon_files(struct dentry
*dir
)
1490 for (i
= 1; i
<= SECINITSID_NUM
; i
++) {
1491 struct inode
*inode
;
1492 struct dentry
*dentry
;
1493 dentry
= d_alloc_name(dir
, security_get_initial_sid_context(i
));
1497 inode
= sel_make_inode(dir
->d_sb
, S_IFREG
|S_IRUGO
);
1501 inode
->i_fop
= &sel_initcon_ops
;
1502 inode
->i_ino
= i
|SEL_INITCON_INO_OFFSET
;
1503 d_add(dentry
, inode
);
1509 static inline unsigned int sel_div(unsigned long a
, unsigned long b
)
1511 return a
/ b
- (a
% b
< 0);
1514 static inline unsigned long sel_class_to_ino(u16
class)
1516 return (class * (SEL_VEC_MAX
+ 1)) | SEL_CLASS_INO_OFFSET
;
1519 static inline u16
sel_ino_to_class(unsigned long ino
)
1521 return sel_div(ino
& SEL_INO_MASK
, SEL_VEC_MAX
+ 1);
1524 static inline unsigned long sel_perm_to_ino(u16
class, u32 perm
)
1526 return (class * (SEL_VEC_MAX
+ 1) + perm
) | SEL_CLASS_INO_OFFSET
;
1529 static inline u32
sel_ino_to_perm(unsigned long ino
)
1531 return (ino
& SEL_INO_MASK
) % (SEL_VEC_MAX
+ 1);
1534 static ssize_t
sel_read_class(struct file
*file
, char __user
*buf
,
1535 size_t count
, loff_t
*ppos
)
1539 unsigned long ino
= file
->f_path
.dentry
->d_inode
->i_ino
;
1541 page
= (char *)__get_free_page(GFP_KERNEL
);
1545 len
= snprintf(page
, PAGE_SIZE
, "%d", sel_ino_to_class(ino
));
1546 rc
= simple_read_from_buffer(buf
, count
, ppos
, page
, len
);
1547 free_page((unsigned long)page
);
1552 static const struct file_operations sel_class_ops
= {
1553 .read
= sel_read_class
,
1554 .llseek
= generic_file_llseek
,
1557 static ssize_t
sel_read_perm(struct file
*file
, char __user
*buf
,
1558 size_t count
, loff_t
*ppos
)
1562 unsigned long ino
= file
->f_path
.dentry
->d_inode
->i_ino
;
1564 page
= (char *)__get_free_page(GFP_KERNEL
);
1568 len
= snprintf(page
, PAGE_SIZE
, "%d", sel_ino_to_perm(ino
));
1569 rc
= simple_read_from_buffer(buf
, count
, ppos
, page
, len
);
1570 free_page((unsigned long)page
);
1575 static const struct file_operations sel_perm_ops
= {
1576 .read
= sel_read_perm
,
1577 .llseek
= generic_file_llseek
,
1580 static ssize_t
sel_read_policycap(struct file
*file
, char __user
*buf
,
1581 size_t count
, loff_t
*ppos
)
1584 char tmpbuf
[TMPBUFLEN
];
1586 unsigned long i_ino
= file
->f_path
.dentry
->d_inode
->i_ino
;
1588 value
= security_policycap_supported(i_ino
& SEL_INO_MASK
);
1589 length
= scnprintf(tmpbuf
, TMPBUFLEN
, "%d", value
);
1591 return simple_read_from_buffer(buf
, count
, ppos
, tmpbuf
, length
);
1594 static const struct file_operations sel_policycap_ops
= {
1595 .read
= sel_read_policycap
,
1596 .llseek
= generic_file_llseek
,
1599 static int sel_make_perm_files(char *objclass
, int classvalue
,
1605 rc
= security_get_permissions(objclass
, &perms
, &nperms
);
1609 for (i
= 0; i
< nperms
; i
++) {
1610 struct inode
*inode
;
1611 struct dentry
*dentry
;
1614 dentry
= d_alloc_name(dir
, perms
[i
]);
1619 inode
= sel_make_inode(dir
->d_sb
, S_IFREG
|S_IRUGO
);
1623 inode
->i_fop
= &sel_perm_ops
;
1624 /* i+1 since perm values are 1-indexed */
1625 inode
->i_ino
= sel_perm_to_ino(classvalue
, i
+ 1);
1626 d_add(dentry
, inode
);
1630 for (i
= 0; i
< nperms
; i
++)
1636 static int sel_make_class_dir_entries(char *classname
, int index
,
1639 struct dentry
*dentry
= NULL
;
1640 struct inode
*inode
= NULL
;
1643 dentry
= d_alloc_name(dir
, "index");
1647 inode
= sel_make_inode(dir
->d_sb
, S_IFREG
|S_IRUGO
);
1651 inode
->i_fop
= &sel_class_ops
;
1652 inode
->i_ino
= sel_class_to_ino(index
);
1653 d_add(dentry
, inode
);
1655 dentry
= d_alloc_name(dir
, "perms");
1659 rc
= sel_make_dir(dir
->d_inode
, dentry
, &last_class_ino
);
1663 rc
= sel_make_perm_files(classname
, index
, dentry
);
1668 static void sel_remove_classes(void)
1670 struct list_head
*class_node
;
1672 list_for_each(class_node
, &class_dir
->d_subdirs
) {
1673 struct dentry
*class_subdir
= list_entry(class_node
,
1674 struct dentry
, d_u
.d_child
);
1675 struct list_head
*class_subdir_node
;
1677 list_for_each(class_subdir_node
, &class_subdir
->d_subdirs
) {
1678 struct dentry
*d
= list_entry(class_subdir_node
,
1679 struct dentry
, d_u
.d_child
);
1682 if (d
->d_inode
->i_mode
& S_IFDIR
)
1683 sel_remove_entries(d
);
1686 sel_remove_entries(class_subdir
);
1689 sel_remove_entries(class_dir
);
1692 static int sel_make_classes(void)
1694 int rc
, nclasses
, i
;
1697 /* delete any existing entries */
1698 sel_remove_classes();
1700 rc
= security_get_classes(&classes
, &nclasses
);
1704 /* +2 since classes are 1-indexed */
1705 last_class_ino
= sel_class_to_ino(nclasses
+ 2);
1707 for (i
= 0; i
< nclasses
; i
++) {
1708 struct dentry
*class_name_dir
;
1711 class_name_dir
= d_alloc_name(class_dir
, classes
[i
]);
1712 if (!class_name_dir
)
1715 rc
= sel_make_dir(class_dir
->d_inode
, class_name_dir
,
1720 /* i+1 since class values are 1-indexed */
1721 rc
= sel_make_class_dir_entries(classes
[i
], i
+ 1,
1728 for (i
= 0; i
< nclasses
; i
++)
1734 static int sel_make_policycap(void)
1737 struct dentry
*dentry
= NULL
;
1738 struct inode
*inode
= NULL
;
1740 sel_remove_entries(policycap_dir
);
1742 for (iter
= 0; iter
<= POLICYDB_CAPABILITY_MAX
; iter
++) {
1743 if (iter
< ARRAY_SIZE(policycap_names
))
1744 dentry
= d_alloc_name(policycap_dir
,
1745 policycap_names
[iter
]);
1747 dentry
= d_alloc_name(policycap_dir
, "unknown");
1752 inode
= sel_make_inode(policycap_dir
->d_sb
, S_IFREG
| S_IRUGO
);
1756 inode
->i_fop
= &sel_policycap_ops
;
1757 inode
->i_ino
= iter
| SEL_POLICYCAP_INO_OFFSET
;
1758 d_add(dentry
, inode
);
1764 static int sel_make_dir(struct inode
*dir
, struct dentry
*dentry
,
1767 struct inode
*inode
;
1769 inode
= sel_make_inode(dir
->i_sb
, S_IFDIR
| S_IRUGO
| S_IXUGO
);
1773 inode
->i_op
= &simple_dir_inode_operations
;
1774 inode
->i_fop
= &simple_dir_operations
;
1775 inode
->i_ino
= ++(*ino
);
1776 /* directory inodes start off with i_nlink == 2 (for "." entry) */
1778 d_add(dentry
, inode
);
1779 /* bump link count on parent directory, too */
1785 static int sel_fill_super(struct super_block
*sb
, void *data
, int silent
)
1788 struct dentry
*dentry
;
1789 struct inode
*inode
, *root_inode
;
1790 struct inode_security_struct
*isec
;
1792 static struct tree_descr selinux_files
[] = {
1793 [SEL_LOAD
] = {"load", &sel_load_ops
, S_IRUSR
|S_IWUSR
},
1794 [SEL_ENFORCE
] = {"enforce", &sel_enforce_ops
, S_IRUGO
|S_IWUSR
},
1795 [SEL_CONTEXT
] = {"context", &transaction_ops
, S_IRUGO
|S_IWUGO
},
1796 [SEL_ACCESS
] = {"access", &transaction_ops
, S_IRUGO
|S_IWUGO
},
1797 [SEL_CREATE
] = {"create", &transaction_ops
, S_IRUGO
|S_IWUGO
},
1798 [SEL_RELABEL
] = {"relabel", &transaction_ops
, S_IRUGO
|S_IWUGO
},
1799 [SEL_USER
] = {"user", &transaction_ops
, S_IRUGO
|S_IWUGO
},
1800 [SEL_POLICYVERS
] = {"policyvers", &sel_policyvers_ops
, S_IRUGO
},
1801 [SEL_COMMIT_BOOLS
] = {"commit_pending_bools", &sel_commit_bools_ops
, S_IWUSR
},
1802 [SEL_MLS
] = {"mls", &sel_mls_ops
, S_IRUGO
},
1803 [SEL_DISABLE
] = {"disable", &sel_disable_ops
, S_IWUSR
},
1804 [SEL_MEMBER
] = {"member", &transaction_ops
, S_IRUGO
|S_IWUGO
},
1805 [SEL_CHECKREQPROT
] = {"checkreqprot", &sel_checkreqprot_ops
, S_IRUGO
|S_IWUSR
},
1806 [SEL_REJECT_UNKNOWN
] = {"reject_unknown", &sel_handle_unknown_ops
, S_IRUGO
},
1807 [SEL_DENY_UNKNOWN
] = {"deny_unknown", &sel_handle_unknown_ops
, S_IRUGO
},
1808 [SEL_STATUS
] = {"status", &sel_handle_status_ops
, S_IRUGO
},
1809 [SEL_POLICY
] = {"policy", &sel_policy_ops
, S_IRUSR
},
1812 ret
= simple_fill_super(sb
, SELINUX_MAGIC
, selinux_files
);
1816 root_inode
= sb
->s_root
->d_inode
;
1819 dentry
= d_alloc_name(sb
->s_root
, BOOL_DIR_NAME
);
1823 ret
= sel_make_dir(root_inode
, dentry
, &sel_last_ino
);
1830 dentry
= d_alloc_name(sb
->s_root
, NULL_FILE_NAME
);
1835 inode
= sel_make_inode(sb
, S_IFCHR
| S_IRUGO
| S_IWUGO
);
1839 inode
->i_ino
= ++sel_last_ino
;
1840 isec
= (struct inode_security_struct
*)inode
->i_security
;
1841 isec
->sid
= SECINITSID_DEVNULL
;
1842 isec
->sclass
= SECCLASS_CHR_FILE
;
1843 isec
->initialized
= 1;
1845 init_special_inode(inode
, S_IFCHR
| S_IRUGO
| S_IWUGO
, MKDEV(MEM_MAJOR
, 3));
1846 d_add(dentry
, inode
);
1847 selinux_null
= dentry
;
1850 dentry
= d_alloc_name(sb
->s_root
, "avc");
1854 ret
= sel_make_dir(root_inode
, dentry
, &sel_last_ino
);
1858 ret
= sel_make_avc_files(dentry
);
1863 dentry
= d_alloc_name(sb
->s_root
, "initial_contexts");
1867 ret
= sel_make_dir(root_inode
, dentry
, &sel_last_ino
);
1871 ret
= sel_make_initcon_files(dentry
);
1876 dentry
= d_alloc_name(sb
->s_root
, "class");
1880 ret
= sel_make_dir(root_inode
, dentry
, &sel_last_ino
);
1887 dentry
= d_alloc_name(sb
->s_root
, "policy_capabilities");
1891 ret
= sel_make_dir(root_inode
, dentry
, &sel_last_ino
);
1895 policycap_dir
= dentry
;
1899 printk(KERN_ERR
"SELinux: %s: failed while creating inodes\n",
1904 static struct dentry
*sel_mount(struct file_system_type
*fs_type
,
1905 int flags
, const char *dev_name
, void *data
)
1907 return mount_single(fs_type
, flags
, data
, sel_fill_super
);
1910 static struct file_system_type sel_fs_type
= {
1911 .name
= "selinuxfs",
1913 .kill_sb
= kill_litter_super
,
1916 struct vfsmount
*selinuxfs_mount
;
1917 static struct kobject
*selinuxfs_kobj
;
1919 static int __init
init_sel_fs(void)
1923 if (!selinux_enabled
)
1926 selinuxfs_kobj
= kobject_create_and_add("selinux", fs_kobj
);
1927 if (!selinuxfs_kobj
)
1930 err
= register_filesystem(&sel_fs_type
);
1932 kobject_put(selinuxfs_kobj
);
1936 selinuxfs_mount
= kern_mount(&sel_fs_type
);
1937 if (IS_ERR(selinuxfs_mount
)) {
1938 printk(KERN_ERR
"selinuxfs: could not mount!\n");
1939 err
= PTR_ERR(selinuxfs_mount
);
1940 selinuxfs_mount
= NULL
;
1946 __initcall(init_sel_fs
);
1948 #ifdef CONFIG_SECURITY_SELINUX_DISABLE
1949 void exit_sel_fs(void)
1951 kobject_put(selinuxfs_kobj
);
1952 unregister_filesystem(&sel_fs_type
);