diff options
author | Ajay Dudani <adudani@google.com> | 2016-08-08 17:03:05 -0700 |
---|---|---|
committer | Ajay Dudani <adudani@google.com> | 2016-08-08 17:09:38 -0700 |
commit | 4bb39d612578e4ba3a0ef78fda84cab8de210e6c (patch) | |
tree | 3ed6f0247f54768ccc1886b92de43a18f7e4871a | |
parent | 111908a6a0b9e6be040cb34989de0b76a94851a1 (diff) |
ashmem: Validate ashmem memory with fops pointerandroid-7.0.0_r0.11
Validate the ashmem memory entry against f_op pointer
rather then comparing its name with path of the dentry.
This is to avoid any invalid access to ashmem area in cases
where some one deliberately set the dentry name to /ashmem.
Change-Id: I549c7743e63a416d2422236ca28834e64546fc93
Signed-off-by: Sunil Khatri <sunilkh@codeaurora.org>
-rw-r--r-- | drivers/staging/android/ashmem.c | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c index 808acd4b90dd..ee79ac8d90d6 100644 --- a/drivers/staging/android/ashmem.c +++ b/drivers/staging/android/ashmem.c @@ -766,11 +766,28 @@ static long compat_ashmem_ioctl(struct file *file, unsigned int cmd, unsigned lo } #endif +static const struct file_operations ashmem_fops = { + .owner = THIS_MODULE, + .open = ashmem_open, + .release = ashmem_release, + .read = ashmem_read, + .llseek = ashmem_llseek, + .mmap = ashmem_mmap, + .unlocked_ioctl = ashmem_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = compat_ashmem_ioctl, +#endif +}; + +static struct miscdevice ashmem_misc = { + .minor = MISC_DYNAMIC_MINOR, + .name = "ashmem", + .fops = &ashmem_fops, +}; + static int is_ashmem_file(struct file *file) { - char fname[256], *name; - name = dentry_path(file->f_dentry, fname, 256); - return strcmp(name, "/ashmem") ? 0 : 1; + return (file->f_op == &ashmem_fops); } int get_ashmem_file(int fd, struct file **filp, struct file **vm_file, @@ -819,25 +836,6 @@ void put_ashmem_file(struct file *file) } EXPORT_SYMBOL(put_ashmem_file); -static const struct file_operations ashmem_fops = { - .owner = THIS_MODULE, - .open = ashmem_open, - .release = ashmem_release, - .read = ashmem_read, - .llseek = ashmem_llseek, - .mmap = ashmem_mmap, - .unlocked_ioctl = ashmem_ioctl, -#ifdef CONFIG_COMPAT - .compat_ioctl = compat_ashmem_ioctl, -#endif -}; - -static struct miscdevice ashmem_misc = { - .minor = MISC_DYNAMIC_MINOR, - .name = "ashmem", - .fops = &ashmem_fops, -}; - static int __init ashmem_init(void) { int ret; |