diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-19 21:15:12 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-19 21:15:12 -0500 |
commit | 298647e31af52e795867a399fa049cebd88067ff (patch) | |
tree | 5584eff4756b695e88a627ba2639c956b7e715c2 /fs | |
parent | 5c68eac68bea2fc908b20b6df8654d50bd1a5d36 (diff) | |
parent | 942080643bce061c3dd9d5718d3b745dcb39a8bc (diff) |
Merge tag 'ecryptfs-3.19-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tyhicks/ecryptfs
Pull eCryptfs fixes from Tyler Hicks:
"Fixes for filename decryption and encrypted view plus a cleanup
- The filename decryption routines were, at times, writing a zero
byte one character past the end of the filename buffer
- The encrypted view feature attempted, and failed, to roll its own
form of enforcing a read-only mount instead of letting the VFS
enforce it"
* tag 'ecryptfs-3.19-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tyhicks/ecryptfs:
eCryptfs: Remove buggy and unnecessary write in file name decode routine
eCryptfs: Remove unnecessary casts when parsing packet lengths
eCryptfs: Force RO mount when encrypted view is enabled
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ecryptfs/crypto.c | 1 | ||||
-rw-r--r-- | fs/ecryptfs/file.c | 12 | ||||
-rw-r--r-- | fs/ecryptfs/keystore.c | 6 | ||||
-rw-r--r-- | fs/ecryptfs/main.c | 16 |
4 files changed, 16 insertions, 19 deletions
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c index c2d6604667b0..719e1ce1c609 100644 --- a/fs/ecryptfs/crypto.c +++ b/fs/ecryptfs/crypto.c | |||
@@ -1917,7 +1917,6 @@ ecryptfs_decode_from_filename(unsigned char *dst, size_t *dst_size, | |||
1917 | break; | 1917 | break; |
1918 | case 2: | 1918 | case 2: |
1919 | dst[dst_byte_offset++] |= (src_byte); | 1919 | dst[dst_byte_offset++] |= (src_byte); |
1920 | dst[dst_byte_offset] = 0; | ||
1921 | current_bit_offset = 0; | 1920 | current_bit_offset = 0; |
1922 | break; | 1921 | break; |
1923 | } | 1922 | } |
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c index 80154ec4f8c2..6f4e659f508f 100644 --- a/fs/ecryptfs/file.c +++ b/fs/ecryptfs/file.c | |||
@@ -190,23 +190,11 @@ static int ecryptfs_open(struct inode *inode, struct file *file) | |||
190 | { | 190 | { |
191 | int rc = 0; | 191 | int rc = 0; |
192 | struct ecryptfs_crypt_stat *crypt_stat = NULL; | 192 | struct ecryptfs_crypt_stat *crypt_stat = NULL; |
193 | struct ecryptfs_mount_crypt_stat *mount_crypt_stat; | ||
194 | struct dentry *ecryptfs_dentry = file->f_path.dentry; | 193 | struct dentry *ecryptfs_dentry = file->f_path.dentry; |
195 | /* Private value of ecryptfs_dentry allocated in | 194 | /* Private value of ecryptfs_dentry allocated in |
196 | * ecryptfs_lookup() */ | 195 | * ecryptfs_lookup() */ |
197 | struct ecryptfs_file_info *file_info; | 196 | struct ecryptfs_file_info *file_info; |
198 | 197 | ||
199 | mount_crypt_stat = &ecryptfs_superblock_to_private( | ||
200 | ecryptfs_dentry->d_sb)->mount_crypt_stat; | ||
201 | if ((mount_crypt_stat->flags & ECRYPTFS_ENCRYPTED_VIEW_ENABLED) | ||
202 | && ((file->f_flags & O_WRONLY) || (file->f_flags & O_RDWR) | ||
203 | || (file->f_flags & O_CREAT) || (file->f_flags & O_TRUNC) | ||
204 | || (file->f_flags & O_APPEND))) { | ||
205 | printk(KERN_WARNING "Mount has encrypted view enabled; " | ||
206 | "files may only be read\n"); | ||
207 | rc = -EPERM; | ||
208 | goto out; | ||
209 | } | ||
210 | /* Released in ecryptfs_release or end of function if failure */ | 198 | /* Released in ecryptfs_release or end of function if failure */ |
211 | file_info = kmem_cache_zalloc(ecryptfs_file_info_cache, GFP_KERNEL); | 199 | file_info = kmem_cache_zalloc(ecryptfs_file_info_cache, GFP_KERNEL); |
212 | ecryptfs_set_file_private(file, file_info); | 200 | ecryptfs_set_file_private(file, file_info); |
diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c index 635e8e16a5b7..917bd5c9776a 100644 --- a/fs/ecryptfs/keystore.c +++ b/fs/ecryptfs/keystore.c | |||
@@ -100,12 +100,12 @@ int ecryptfs_parse_packet_length(unsigned char *data, size_t *size, | |||
100 | (*size) = 0; | 100 | (*size) = 0; |
101 | if (data[0] < 192) { | 101 | if (data[0] < 192) { |
102 | /* One-byte length */ | 102 | /* One-byte length */ |
103 | (*size) = (unsigned char)data[0]; | 103 | (*size) = data[0]; |
104 | (*length_size) = 1; | 104 | (*length_size) = 1; |
105 | } else if (data[0] < 224) { | 105 | } else if (data[0] < 224) { |
106 | /* Two-byte length */ | 106 | /* Two-byte length */ |
107 | (*size) = (((unsigned char)(data[0]) - 192) * 256); | 107 | (*size) = (data[0] - 192) * 256; |
108 | (*size) += ((unsigned char)(data[1]) + 192); | 108 | (*size) += data[1] + 192; |
109 | (*length_size) = 2; | 109 | (*length_size) = 2; |
110 | } else if (data[0] == 255) { | 110 | } else if (data[0] == 255) { |
111 | /* If support is added, adjust ECRYPTFS_MAX_PKT_LEN_SIZE */ | 111 | /* If support is added, adjust ECRYPTFS_MAX_PKT_LEN_SIZE */ |
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c index c4cd1fd86cc2..d9eb84bda559 100644 --- a/fs/ecryptfs/main.c +++ b/fs/ecryptfs/main.c | |||
@@ -493,6 +493,7 @@ static struct dentry *ecryptfs_mount(struct file_system_type *fs_type, int flags | |||
493 | { | 493 | { |
494 | struct super_block *s; | 494 | struct super_block *s; |
495 | struct ecryptfs_sb_info *sbi; | 495 | struct ecryptfs_sb_info *sbi; |
496 | struct ecryptfs_mount_crypt_stat *mount_crypt_stat; | ||
496 | struct ecryptfs_dentry_info *root_info; | 497 | struct ecryptfs_dentry_info *root_info; |
497 | const char *err = "Getting sb failed"; | 498 | const char *err = "Getting sb failed"; |
498 | struct inode *inode; | 499 | struct inode *inode; |
@@ -511,6 +512,7 @@ static struct dentry *ecryptfs_mount(struct file_system_type *fs_type, int flags | |||
511 | err = "Error parsing options"; | 512 | err = "Error parsing options"; |
512 | goto out; | 513 | goto out; |
513 | } | 514 | } |
515 | mount_crypt_stat = &sbi->mount_crypt_stat; | ||
514 | 516 | ||
515 | s = sget(fs_type, NULL, set_anon_super, flags, NULL); | 517 | s = sget(fs_type, NULL, set_anon_super, flags, NULL); |
516 | if (IS_ERR(s)) { | 518 | if (IS_ERR(s)) { |
@@ -557,11 +559,19 @@ static struct dentry *ecryptfs_mount(struct file_system_type *fs_type, int flags | |||
557 | 559 | ||
558 | /** | 560 | /** |
559 | * Set the POSIX ACL flag based on whether they're enabled in the lower | 561 | * Set the POSIX ACL flag based on whether they're enabled in the lower |
560 | * mount. Force a read-only eCryptfs mount if the lower mount is ro. | 562 | * mount. |
561 | * Allow a ro eCryptfs mount even when the lower mount is rw. | ||
562 | */ | 563 | */ |
563 | s->s_flags = flags & ~MS_POSIXACL; | 564 | s->s_flags = flags & ~MS_POSIXACL; |
564 | s->s_flags |= path.dentry->d_sb->s_flags & (MS_RDONLY | MS_POSIXACL); | 565 | s->s_flags |= path.dentry->d_sb->s_flags & MS_POSIXACL; |
566 | |||
567 | /** | ||
568 | * Force a read-only eCryptfs mount when: | ||
569 | * 1) The lower mount is ro | ||
570 | * 2) The ecryptfs_encrypted_view mount option is specified | ||
571 | */ | ||
572 | if (path.dentry->d_sb->s_flags & MS_RDONLY || | ||
573 | mount_crypt_stat->flags & ECRYPTFS_ENCRYPTED_VIEW_ENABLED) | ||
574 | s->s_flags |= MS_RDONLY; | ||
565 | 575 | ||
566 | s->s_maxbytes = path.dentry->d_sb->s_maxbytes; | 576 | s->s_maxbytes = path.dentry->d_sb->s_maxbytes; |
567 | s->s_blocksize = path.dentry->d_sb->s_blocksize; | 577 | s->s_blocksize = path.dentry->d_sb->s_blocksize; |