aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSunil Khatri <sunilkh@codeaurora.org>2016-06-22 14:45:31 +0530
committerdoc HD <doc.divxm@gmail.com>2016-08-11 09:40:59 +0300
commit9d8d37dfdc6187a5ba7b629012104cb5faab01f2 (patch)
tree554a9cecd7780028fc8f16f06cdeeef3b2314d67
parentece4e29f9797d1be42aa1c805c7b2a0f701bfe58 (diff)
ashmem: Validate ashmem memory with fops pointermm6.0
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: I74e50cd244f68cb13009cf2355e528485f4de34b Signed-off-by: Sunil Khatri <sunilkh@codeaurora.org>
-rw-r--r--drivers/staging/android/ashmem.c38
1 files changed, 18 insertions, 20 deletions
diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
index 4f13907543e..740b5d215b5 100644
--- a/drivers/staging/android/ashmem.c
+++ b/drivers/staging/android/ashmem.c
@@ -785,11 +785,26 @@ static long ashmem_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
return ret;
}
+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,
+ .compat_ioctl = ashmem_ioctl,
+};
+
+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,
@@ -838,23 +853,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,
- .compat_ioctl = ashmem_ioctl,
-};
-
-static struct miscdevice ashmem_misc = {
- .minor = MISC_DYNAMIC_MINOR,
- .name = "ashmem",
- .fops = &ashmem_fops,
-};
-
static int __init ashmem_init(void)
{
int ret;