aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHyunchul Lee <cheol.lee@lge.com>2017-03-03 02:44:03 -0500
committerRichard Weinberger <richard@nod.at>2017-05-08 14:48:23 -0400
commit8326c1eec2449f0e868f7b19a5fa7bfa0386ab48 (patch)
tree6e960532202962d3b1cda2ce0a8e6a0737518eb5
parent997d30cb7490eb1ac37a3fb02a222fabf1f25fa9 (diff)
ubifs: Add CONFIG_UBIFS_FS_SECURITY to disable/enable security labels
When write syscall is called, every time security label is searched to determine that file's privileges should be changed. If LSM(Linux Security Model) is not used, this is useless. So introduce CONFIG_UBIFS_SECURITY to disable security labels. it's default value is "y". Signed-off-by: Hyunchul Lee <cheol.lee@lge.com> Signed-off-by: Richard Weinberger <richard@nod.at>
-rw-r--r--fs/ubifs/Kconfig13
-rw-r--r--fs/ubifs/ubifs.h14
-rw-r--r--fs/ubifs/xattr.c6
3 files changed, 31 insertions, 2 deletions
diff --git a/fs/ubifs/Kconfig b/fs/ubifs/Kconfig
index b0d0623c83ed..83a961bf7280 100644
--- a/fs/ubifs/Kconfig
+++ b/fs/ubifs/Kconfig
@@ -61,3 +61,16 @@ config UBIFS_FS_ENCRYPTION
61 feature is similar to ecryptfs, but it is more memory 61 feature is similar to ecryptfs, but it is more memory
62 efficient since it avoids caching the encrypted and 62 efficient since it avoids caching the encrypted and
63 decrypted pages in the page cache. 63 decrypted pages in the page cache.
64
65config UBIFS_FS_SECURITY
66 bool "UBIFS Security Labels"
67 depends on UBIFS_FS
68 default y
69 help
70 Security labels provide an access control facility to support Linux
71 Security Models (LSMs) accepted by AppArmor, SELinux, Smack and TOMOYO
72 Linux. This option enables an extended attribute handler for file
73 security labels in the ubifs filesystem, so that it requires enabling
74 the extended attribute support in advance.
75
76 If you are not using a security module, say N.
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index 4d57e488038e..abdd11634ba4 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -1756,13 +1756,23 @@ int ubifs_check_dir_empty(struct inode *dir);
1756/* xattr.c */ 1756/* xattr.c */
1757extern const struct xattr_handler *ubifs_xattr_handlers[]; 1757extern const struct xattr_handler *ubifs_xattr_handlers[];
1758ssize_t ubifs_listxattr(struct dentry *dentry, char *buffer, size_t size); 1758ssize_t ubifs_listxattr(struct dentry *dentry, char *buffer, size_t size);
1759int ubifs_init_security(struct inode *dentry, struct inode *inode,
1760 const struct qstr *qstr);
1761int ubifs_xattr_set(struct inode *host, const char *name, const void *value, 1759int ubifs_xattr_set(struct inode *host, const char *name, const void *value,
1762 size_t size, int flags); 1760 size_t size, int flags);
1763ssize_t ubifs_xattr_get(struct inode *host, const char *name, void *buf, 1761ssize_t ubifs_xattr_get(struct inode *host, const char *name, void *buf,
1764 size_t size); 1762 size_t size);
1765 1763
1764#ifdef CONFIG_UBIFS_FS_SECURITY
1765extern int ubifs_init_security(struct inode *dentry, struct inode *inode,
1766 const struct qstr *qstr);
1767#else
1768static inline int ubifs_init_security(struct inode *dentry,
1769 struct inode *inode, const struct qstr *qstr)
1770{
1771 return 0;
1772}
1773#endif
1774
1775
1766/* super.c */ 1776/* super.c */
1767struct inode *ubifs_iget(struct super_block *sb, unsigned long inum); 1777struct inode *ubifs_iget(struct super_block *sb, unsigned long inum);
1768 1778
diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c
index efe00fcb8b75..de88732c680c 100644
--- a/fs/ubifs/xattr.c
+++ b/fs/ubifs/xattr.c
@@ -559,6 +559,7 @@ out_free:
559 return err; 559 return err;
560} 560}
561 561
562#ifdef CONFIG_UBIFS_FS_SECURITY
562static int init_xattrs(struct inode *inode, const struct xattr *xattr_array, 563static int init_xattrs(struct inode *inode, const struct xattr *xattr_array,
563 void *fs_info) 564 void *fs_info)
564{ 565{
@@ -599,6 +600,7 @@ int ubifs_init_security(struct inode *dentry, struct inode *inode,
599 } 600 }
600 return err; 601 return err;
601} 602}
603#endif
602 604
603static int xattr_get(const struct xattr_handler *handler, 605static int xattr_get(const struct xattr_handler *handler,
604 struct dentry *dentry, struct inode *inode, 606 struct dentry *dentry, struct inode *inode,
@@ -639,15 +641,19 @@ static const struct xattr_handler ubifs_trusted_xattr_handler = {
639 .set = xattr_set, 641 .set = xattr_set,
640}; 642};
641 643
644#ifdef CONFIG_UBIFS_FS_SECURITY
642static const struct xattr_handler ubifs_security_xattr_handler = { 645static const struct xattr_handler ubifs_security_xattr_handler = {
643 .prefix = XATTR_SECURITY_PREFIX, 646 .prefix = XATTR_SECURITY_PREFIX,
644 .get = xattr_get, 647 .get = xattr_get,
645 .set = xattr_set, 648 .set = xattr_set,
646}; 649};
650#endif
647 651
648const struct xattr_handler *ubifs_xattr_handlers[] = { 652const struct xattr_handler *ubifs_xattr_handlers[] = {
649 &ubifs_user_xattr_handler, 653 &ubifs_user_xattr_handler,
650 &ubifs_trusted_xattr_handler, 654 &ubifs_trusted_xattr_handler,
655#ifdef CONFIG_UBIFS_FS_SECURITY
651 &ubifs_security_xattr_handler, 656 &ubifs_security_xattr_handler,
657#endif
652 NULL 658 NULL
653}; 659};