aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ubifs
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-02-20 21:22:31 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-02-20 21:22:31 -0500
commit6c24337f22115d669e24ce990842dab667371b4d (patch)
tree44c41adb55182c4fe833935f3b346ed7ad7e29ca /fs/ubifs
parent786856b6d111a30d51c98526cc7a283ecc73f00f (diff)
parent6f69f0ed6136c302976f8e8f859b73d47f0c0c5c (diff)
Merge tag 'fscrypt-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/fscrypt
Pull fscrypt updates from Ted Ts'o: "Various cleanups for the file system encryption feature" * tag 'fscrypt-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/fscrypt: fscrypt: constify struct fscrypt_operations fscrypt: properly declare on-stack completion fscrypt: split supp and notsupp declarations into their own headers fscrypt: remove redundant assignment of res fscrypt: make fscrypt_operations.key_prefix a string fscrypt: remove unused 'mode' member of fscrypt_ctx ext4: don't allow encrypted operations without keys fscrypt: make test_dummy_encryption require a keyring key fscrypt: factor out bio specific functions fscrypt: pass up error codes from ->get_context() fscrypt: remove user-triggerable warning messages fscrypt: use EEXIST when file already uses different policy fscrypt: use ENOTDIR when setting encryption policy on nondirectory fscrypt: use ENOKEY when file cannot be created w/o key
Diffstat (limited to 'fs/ubifs')
-rw-r--r--fs/ubifs/crypto.c13
-rw-r--r--fs/ubifs/super.c2
-rw-r--r--fs/ubifs/ubifs.h30
3 files changed, 9 insertions, 36 deletions
diff --git a/fs/ubifs/crypto.c b/fs/ubifs/crypto.c
index 3402720f2b28..382ed428cfd2 100644
--- a/fs/ubifs/crypto.c
+++ b/fs/ubifs/crypto.c
@@ -26,15 +26,6 @@ static unsigned int ubifs_crypt_max_namelen(struct inode *inode)
26 return UBIFS_MAX_NLEN; 26 return UBIFS_MAX_NLEN;
27} 27}
28 28
29static int ubifs_key_prefix(struct inode *inode, u8 **key)
30{
31 static char prefix[] = "ubifs:";
32
33 *key = prefix;
34
35 return sizeof(prefix) - 1;
36}
37
38int ubifs_encrypt(const struct inode *inode, struct ubifs_data_node *dn, 29int ubifs_encrypt(const struct inode *inode, struct ubifs_data_node *dn,
39 unsigned int in_len, unsigned int *out_len, int block) 30 unsigned int in_len, unsigned int *out_len, int block)
40{ 31{
@@ -86,12 +77,12 @@ int ubifs_decrypt(const struct inode *inode, struct ubifs_data_node *dn,
86 return 0; 77 return 0;
87} 78}
88 79
89struct fscrypt_operations ubifs_crypt_operations = { 80const struct fscrypt_operations ubifs_crypt_operations = {
90 .flags = FS_CFLG_OWN_PAGES, 81 .flags = FS_CFLG_OWN_PAGES,
82 .key_prefix = "ubifs:",
91 .get_context = ubifs_crypt_get_context, 83 .get_context = ubifs_crypt_get_context,
92 .set_context = ubifs_crypt_set_context, 84 .set_context = ubifs_crypt_set_context,
93 .is_encrypted = __ubifs_crypt_is_encrypted, 85 .is_encrypted = __ubifs_crypt_is_encrypted,
94 .empty_dir = ubifs_crypt_empty_dir, 86 .empty_dir = ubifs_crypt_empty_dir,
95 .max_namelen = ubifs_crypt_max_namelen, 87 .max_namelen = ubifs_crypt_max_namelen,
96 .key_prefix = ubifs_key_prefix,
97}; 88};
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c
index e08aa04fc835..b73811bd7676 100644
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -2000,7 +2000,7 @@ static struct ubifs_info *alloc_ubifs_info(struct ubi_volume_desc *ubi)
2000} 2000}
2001 2001
2002#ifndef CONFIG_UBIFS_FS_ENCRYPTION 2002#ifndef CONFIG_UBIFS_FS_ENCRYPTION
2003struct fscrypt_operations ubifs_crypt_operations = { 2003const struct fscrypt_operations ubifs_crypt_operations = {
2004 .is_encrypted = __ubifs_crypt_is_encrypted, 2004 .is_encrypted = __ubifs_crypt_is_encrypted,
2005}; 2005};
2006#endif 2006#endif
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index ca72382ce6cc..f0c86f076535 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -38,7 +38,11 @@
38#include <linux/backing-dev.h> 38#include <linux/backing-dev.h>
39#include <linux/security.h> 39#include <linux/security.h>
40#include <linux/xattr.h> 40#include <linux/xattr.h>
41#include <linux/fscrypto.h> 41#ifdef CONFIG_UBIFS_FS_ENCRYPTION
42#include <linux/fscrypt_supp.h>
43#else
44#include <linux/fscrypt_notsupp.h>
45#endif
42#include <linux/random.h> 46#include <linux/random.h>
43#include "ubifs-media.h" 47#include "ubifs-media.h"
44 48
@@ -1797,28 +1801,6 @@ int ubifs_decompress(const struct ubifs_info *c, const void *buf, int len,
1797#include "key.h" 1801#include "key.h"
1798 1802
1799#ifndef CONFIG_UBIFS_FS_ENCRYPTION 1803#ifndef CONFIG_UBIFS_FS_ENCRYPTION
1800#define fscrypt_set_d_op(i)
1801#define fscrypt_get_ctx fscrypt_notsupp_get_ctx
1802#define fscrypt_release_ctx fscrypt_notsupp_release_ctx
1803#define fscrypt_encrypt_page fscrypt_notsupp_encrypt_page
1804#define fscrypt_decrypt_page fscrypt_notsupp_decrypt_page
1805#define fscrypt_decrypt_bio_pages fscrypt_notsupp_decrypt_bio_pages
1806#define fscrypt_pullback_bio_page fscrypt_notsupp_pullback_bio_page
1807#define fscrypt_restore_control_page fscrypt_notsupp_restore_control_page
1808#define fscrypt_zeroout_range fscrypt_notsupp_zeroout_range
1809#define fscrypt_ioctl_set_policy fscrypt_notsupp_ioctl_set_policy
1810#define fscrypt_ioctl_get_policy fscrypt_notsupp_ioctl_get_policy
1811#define fscrypt_has_permitted_context fscrypt_notsupp_has_permitted_context
1812#define fscrypt_inherit_context fscrypt_notsupp_inherit_context
1813#define fscrypt_get_encryption_info fscrypt_notsupp_get_encryption_info
1814#define fscrypt_put_encryption_info fscrypt_notsupp_put_encryption_info
1815#define fscrypt_setup_filename fscrypt_notsupp_setup_filename
1816#define fscrypt_free_filename fscrypt_notsupp_free_filename
1817#define fscrypt_fname_encrypted_size fscrypt_notsupp_fname_encrypted_size
1818#define fscrypt_fname_alloc_buffer fscrypt_notsupp_fname_alloc_buffer
1819#define fscrypt_fname_free_buffer fscrypt_notsupp_fname_free_buffer
1820#define fscrypt_fname_disk_to_usr fscrypt_notsupp_fname_disk_to_usr
1821#define fscrypt_fname_usr_to_disk fscrypt_notsupp_fname_usr_to_disk
1822static inline int ubifs_encrypt(const struct inode *inode, 1804static inline int ubifs_encrypt(const struct inode *inode,
1823 struct ubifs_data_node *dn, 1805 struct ubifs_data_node *dn,
1824 unsigned int in_len, unsigned int *out_len, 1806 unsigned int in_len, unsigned int *out_len,
@@ -1842,7 +1824,7 @@ int ubifs_decrypt(const struct inode *inode, struct ubifs_data_node *dn,
1842 unsigned int *out_len, int block); 1824 unsigned int *out_len, int block);
1843#endif 1825#endif
1844 1826
1845extern struct fscrypt_operations ubifs_crypt_operations; 1827extern const struct fscrypt_operations ubifs_crypt_operations;
1846 1828
1847static inline bool __ubifs_crypt_is_encrypted(struct inode *inode) 1829static inline bool __ubifs_crypt_is_encrypted(struct inode *inode)
1848{ 1830{