Skip to content

Commit 8326c1e

Browse files
hyeoncheolrichardweinberger
authored andcommitted
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 <[email protected]> Signed-off-by: Richard Weinberger <[email protected]>
1 parent 997d30c commit 8326c1e

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

fs/ubifs/Kconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,16 @@ config UBIFS_FS_ENCRYPTION
6161
feature is similar to ecryptfs, but it is more memory
6262
efficient since it avoids caching the encrypted and
6363
decrypted pages in the page cache.
64+
65+
config 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.

fs/ubifs/ubifs.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,13 +1756,23 @@ int ubifs_check_dir_empty(struct inode *dir);
17561756
/* xattr.c */
17571757
extern const struct xattr_handler *ubifs_xattr_handlers[];
17581758
ssize_t ubifs_listxattr(struct dentry *dentry, char *buffer, size_t size);
1759-
int ubifs_init_security(struct inode *dentry, struct inode *inode,
1760-
const struct qstr *qstr);
17611759
int ubifs_xattr_set(struct inode *host, const char *name, const void *value,
17621760
size_t size, int flags);
17631761
ssize_t ubifs_xattr_get(struct inode *host, const char *name, void *buf,
17641762
size_t size);
17651763

1764+
#ifdef CONFIG_UBIFS_FS_SECURITY
1765+
extern int ubifs_init_security(struct inode *dentry, struct inode *inode,
1766+
const struct qstr *qstr);
1767+
#else
1768+
static 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+
17661776
/* super.c */
17671777
struct inode *ubifs_iget(struct super_block *sb, unsigned long inum);
17681778

fs/ubifs/xattr.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,7 @@ static int ubifs_xattr_remove(struct inode *host, const char *name)
559559
return err;
560560
}
561561

562+
#ifdef CONFIG_UBIFS_FS_SECURITY
562563
static int init_xattrs(struct inode *inode, const struct xattr *xattr_array,
563564
void *fs_info)
564565
{
@@ -599,6 +600,7 @@ int ubifs_init_security(struct inode *dentry, struct inode *inode,
599600
}
600601
return err;
601602
}
603+
#endif
602604

603605
static int xattr_get(const struct xattr_handler *handler,
604606
struct dentry *dentry, struct inode *inode,
@@ -639,15 +641,19 @@ static const struct xattr_handler ubifs_trusted_xattr_handler = {
639641
.set = xattr_set,
640642
};
641643

644+
#ifdef CONFIG_UBIFS_FS_SECURITY
642645
static const struct xattr_handler ubifs_security_xattr_handler = {
643646
.prefix = XATTR_SECURITY_PREFIX,
644647
.get = xattr_get,
645648
.set = xattr_set,
646649
};
650+
#endif
647651

648652
const struct xattr_handler *ubifs_xattr_handlers[] = {
649653
&ubifs_user_xattr_handler,
650654
&ubifs_trusted_xattr_handler,
655+
#ifdef CONFIG_UBIFS_FS_SECURITY
651656
&ubifs_security_xattr_handler,
657+
#endif
652658
NULL
653659
};

0 commit comments

Comments
 (0)