Skip to content

Commit f0fe970

Browse files
jeffmahoneytyhicks
authored andcommitted
ecryptfs: don't allow mmap when the lower fs doesn't support it
There are legitimate reasons to disallow mmap on certain files, notably in sysfs or procfs. We shouldn't emulate mmap support on file systems that don't offer support natively. CVE-2016-1583 Signed-off-by: Jeff Mahoney <jeffm@suse.com> Cc: stable@vger.kernel.org [tyhicks: clean up f_op check by using ecryptfs_file_to_lower()] Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
1 parent 78c4e17 commit f0fe970

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

fs/ecryptfs/file.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,19 @@ 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
174187
* @inode: inode specifying file to open
@@ -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,

0 commit comments

Comments
 (0)