Skip to content

Commit b987c75

Browse files
committed
Merge tag 'ecryptfs-4.7-rc7-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tyhicks/ecryptfs
Pull eCryptfs fixes from Tyler Hicks: "Provide a more concise fix for CVE-2016-1583: - Additionally fixes linux-stable regressions caused by the cherry-picking of the original fix Some very minor changes that have queued up: - Fix typos in code comments - Remove unnecessary check for NULL before destroying kmem_cache" * tag 'ecryptfs-4.7-rc7-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tyhicks/ecryptfs: ecryptfs: don't allow mmap when the lower fs doesn't support it Revert "ecryptfs: forbid opening files without mmap handler" ecryptfs: fix spelling mistakes eCryptfs: fix typos in comment ecryptfs: drop null test before destroy functions
2 parents b89c44b + f0fe970 commit b987c75

File tree

4 files changed

+23
-20
lines changed

4 files changed

+23
-20
lines changed

fs/ecryptfs/crypto.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
* ecryptfs_to_hex
4646
* @dst: Buffer to take hex character representation of contents of
4747
* src; must be at least of size (src_size * 2)
48-
* @src: Buffer to be converted to a hex string respresentation
48+
* @src: Buffer to be converted to a hex string representation
4949
* @src_size: number of bytes to convert
5050
*/
5151
void ecryptfs_to_hex(char *dst, char *src, size_t src_size)
@@ -60,7 +60,7 @@ void ecryptfs_to_hex(char *dst, char *src, size_t src_size)
6060
* ecryptfs_from_hex
6161
* @dst: Buffer to take the bytes from src hex; must be at least of
6262
* size (src_size / 2)
63-
* @src: Buffer to be converted from a hex string respresentation to raw value
63+
* @src: Buffer to be converted from a hex string representation to raw value
6464
* @dst_size: size of dst buffer, or number of hex characters pairs to convert
6565
*/
6666
void ecryptfs_from_hex(char *dst, char *src, int dst_size)
@@ -953,7 +953,7 @@ struct ecryptfs_cipher_code_str_map_elem {
953953
};
954954

955955
/* Add support for additional ciphers by adding elements here. The
956-
* cipher_code is whatever OpenPGP applicatoins use to identify the
956+
* cipher_code is whatever OpenPGP applications use to identify the
957957
* ciphers. List in order of probability. */
958958
static struct ecryptfs_cipher_code_str_map_elem
959959
ecryptfs_cipher_code_str_map[] = {
@@ -1410,7 +1410,7 @@ int ecryptfs_read_and_validate_xattr_region(struct dentry *dentry,
14101410
*
14111411
* Common entry point for reading file metadata. From here, we could
14121412
* retrieve the header information from the header region of the file,
1413-
* the xattr region of the file, or some other repostory that is
1413+
* the xattr region of the file, or some other repository that is
14141414
* stored separately from the file itself. The current implementation
14151415
* supports retrieving the metadata information from the file contents
14161416
* and from the xattr region.

fs/ecryptfs/file.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,22 @@ static int read_or_initialize_metadata(struct dentry *dentry)
169169
return rc;
170170
}
171171

172+
static int ecryptfs_mmap(struct file *file, struct vm_area_struct *vma)
173+
{
174+
struct file *lower_file = ecryptfs_file_to_lower(file);
175+
/*
176+
* Don't allow mmap on top of file systems that don't support it
177+
* natively. If FILESYSTEM_MAX_STACK_DEPTH > 2 or ecryptfs
178+
* allows recursive mounting, this will need to be extended.
179+
*/
180+
if (!lower_file->f_op->mmap)
181+
return -ENODEV;
182+
return generic_file_mmap(file, vma);
183+
}
184+
172185
/**
173186
* ecryptfs_open
174-
* @inode: inode speciying file to open
187+
* @inode: inode specifying file to open
175188
* @file: Structure to return filled in
176189
*
177190
* Opens the file specified by inode.
@@ -240,7 +253,7 @@ static int ecryptfs_open(struct inode *inode, struct file *file)
240253

241254
/**
242255
* ecryptfs_dir_open
243-
* @inode: inode speciying file to open
256+
* @inode: inode specifying file to open
244257
* @file: Structure to return filled in
245258
*
246259
* Opens the file specified by inode.
@@ -403,7 +416,7 @@ const struct file_operations ecryptfs_main_fops = {
403416
#ifdef CONFIG_COMPAT
404417
.compat_ioctl = ecryptfs_compat_ioctl,
405418
#endif
406-
.mmap = generic_file_mmap,
419+
.mmap = ecryptfs_mmap,
407420
.open = ecryptfs_open,
408421
.flush = ecryptfs_flush,
409422
.release = ecryptfs_release,

fs/ecryptfs/kthread.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include <linux/slab.h>
2626
#include <linux/wait.h>
2727
#include <linux/mount.h>
28-
#include <linux/file.h>
2928
#include "ecryptfs_kernel.h"
3029

3130
struct ecryptfs_open_req {
@@ -148,7 +147,7 @@ int ecryptfs_privileged_open(struct file **lower_file,
148147
flags |= IS_RDONLY(d_inode(lower_dentry)) ? O_RDONLY : O_RDWR;
149148
(*lower_file) = dentry_open(&req.path, flags, cred);
150149
if (!IS_ERR(*lower_file))
151-
goto have_file;
150+
goto out;
152151
if ((flags & O_ACCMODE) == O_RDONLY) {
153152
rc = PTR_ERR((*lower_file));
154153
goto out;
@@ -166,16 +165,8 @@ int ecryptfs_privileged_open(struct file **lower_file,
166165
mutex_unlock(&ecryptfs_kthread_ctl.mux);
167166
wake_up(&ecryptfs_kthread_ctl.wait);
168167
wait_for_completion(&req.done);
169-
if (IS_ERR(*lower_file)) {
168+
if (IS_ERR(*lower_file))
170169
rc = PTR_ERR(*lower_file);
171-
goto out;
172-
}
173-
have_file:
174-
if ((*lower_file)->f_op->mmap == NULL) {
175-
fput(*lower_file);
176-
*lower_file = NULL;
177-
rc = -EMEDIUMTYPE;
178-
}
179170
out:
180171
return rc;
181172
}

fs/ecryptfs/main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -738,8 +738,7 @@ static void ecryptfs_free_kmem_caches(void)
738738
struct ecryptfs_cache_info *info;
739739

740740
info = &ecryptfs_cache_infos[i];
741-
if (*(info->cache))
742-
kmem_cache_destroy(*(info->cache));
741+
kmem_cache_destroy(*(info->cache));
743742
}
744743
}
745744

0 commit comments

Comments
 (0)