mirror of
https://github.com/Divested-Mobile/DivestOS-Build.git
synced 2025-03-02 19:29:17 -05:00
106 lines
4.0 KiB
Diff
106 lines
4.0 KiB
Diff
From 1f8f9b566e8446c13b954220c226c58d22076f88 Mon Sep 17 00:00:00 2001
|
|
From: Rohit Vaswani <rvaswani@codeaurora.org>
|
|
Date: Thu, 17 Sep 2015 17:28:13 -0700
|
|
Subject: mm: Fix incorrect type conversion for size during dma allocation
|
|
|
|
This was found during userspace fuzzing test when a large size
|
|
allocation is made from ion
|
|
|
|
[<ffffffc00008a098>] show_stack+0x10/0x1c
|
|
[<ffffffc00119c390>] dump_stack+0x74/0xc8
|
|
[<ffffffc00020d9a0>] kasan_report_error+0x2b0/0x408
|
|
[<ffffffc00020dbd4>] kasan_report+0x34/0x40
|
|
[<ffffffc00020cfec>] __asan_storeN+0x15c/0x168
|
|
[<ffffffc00020d228>] memset+0x20/0x44
|
|
[<ffffffc00009b730>] __dma_alloc_coherent+0x114/0x18c
|
|
[<ffffffc00009c6e8>] __dma_alloc_noncoherent+0xbc/0x19c
|
|
[<ffffffc000c2b3e0>] ion_cma_allocate+0x178/0x2f0
|
|
[<ffffffc000c2b750>] ion_secure_cma_allocate+0xdc/0x190
|
|
[<ffffffc000c250dc>] ion_alloc+0x264/0xb88
|
|
[<ffffffc000c25e94>] ion_ioctl+0x1f4/0x480
|
|
[<ffffffc00022f650>] do_vfs_ioctl+0x67c/0x764
|
|
[<ffffffc00022f790>] SyS_ioctl+0x58/0x8c
|
|
|
|
Change-Id: Idc9c19977a8cc62c7d092f689d30368704b400bc
|
|
Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>
|
|
---
|
|
drivers/base/dma-contiguous.c | 2 +-
|
|
include/linux/cma.h | 3 ++-
|
|
include/linux/dma-contiguous.h | 4 ++--
|
|
mm/cma.c | 4 ++--
|
|
4 files changed, 7 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/drivers/base/dma-contiguous.c b/drivers/base/dma-contiguous.c
|
|
index 950fff9..a12ff98 100644
|
|
--- a/drivers/base/dma-contiguous.c
|
|
+++ b/drivers/base/dma-contiguous.c
|
|
@@ -187,7 +187,7 @@ int __init dma_contiguous_reserve_area(phys_addr_t size, phys_addr_t base,
|
|
* global one. Requires architecture specific dev_get_cma_area() helper
|
|
* function.
|
|
*/
|
|
-struct page *dma_alloc_from_contiguous(struct device *dev, int count,
|
|
+struct page *dma_alloc_from_contiguous(struct device *dev, size_t count,
|
|
unsigned int align)
|
|
{
|
|
if (align > CONFIG_CMA_ALIGNMENT)
|
|
diff --git a/include/linux/cma.h b/include/linux/cma.h
|
|
index a93438b..a76f8df 100644
|
|
--- a/include/linux/cma.h
|
|
+++ b/include/linux/cma.h
|
|
@@ -25,6 +25,7 @@ extern int __init cma_declare_contiguous(phys_addr_t base,
|
|
extern int cma_init_reserved_mem(phys_addr_t base,
|
|
phys_addr_t size, int order_per_bit,
|
|
struct cma **res_cma);
|
|
-extern struct page *cma_alloc(struct cma *cma, int count, unsigned int align);
|
|
+extern struct page *cma_alloc(struct cma *cma, size_t count,
|
|
+ unsigned int align);
|
|
extern bool cma_release(struct cma *cma, struct page *pages, int count);
|
|
#endif
|
|
diff --git a/include/linux/dma-contiguous.h b/include/linux/dma-contiguous.h
|
|
index 569bbd0..fec734d 100644
|
|
--- a/include/linux/dma-contiguous.h
|
|
+++ b/include/linux/dma-contiguous.h
|
|
@@ -111,7 +111,7 @@ static inline int dma_declare_contiguous(struct device *dev, phys_addr_t size,
|
|
return ret;
|
|
}
|
|
|
|
-struct page *dma_alloc_from_contiguous(struct device *dev, int count,
|
|
+struct page *dma_alloc_from_contiguous(struct device *dev, size_t count,
|
|
unsigned int order);
|
|
bool dma_release_from_contiguous(struct device *dev, struct page *pages,
|
|
int count);
|
|
@@ -144,7 +144,7 @@ int dma_declare_contiguous(struct device *dev, phys_addr_t size,
|
|
}
|
|
|
|
static inline
|
|
-struct page *dma_alloc_from_contiguous(struct device *dev, int count,
|
|
+struct page *dma_alloc_from_contiguous(struct device *dev, size_t count,
|
|
unsigned int order)
|
|
{
|
|
return NULL;
|
|
diff --git a/mm/cma.c b/mm/cma.c
|
|
index 8e9ec13..6343f77 100644
|
|
--- a/mm/cma.c
|
|
+++ b/mm/cma.c
|
|
@@ -338,7 +338,7 @@ err:
|
|
* This function allocates part of contiguous memory on specific
|
|
* contiguous memory area.
|
|
*/
|
|
-struct page *cma_alloc(struct cma *cma, int count, unsigned int align)
|
|
+struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align)
|
|
{
|
|
unsigned long mask, pfn, start = 0;
|
|
unsigned long bitmap_maxno, bitmap_no, bitmap_count;
|
|
@@ -348,7 +348,7 @@ struct page *cma_alloc(struct cma *cma, int count, unsigned int align)
|
|
if (!cma || !cma->count)
|
|
return NULL;
|
|
|
|
- pr_debug("%s(cma %p, count %d, align %d)\n", __func__, (void *)cma,
|
|
+ pr_debug("%s(cma %p, count %zu, align %d)\n", __func__, (void *)cma,
|
|
count, align);
|
|
|
|
if (!count)
|
|
--
|
|
cgit v1.1
|
|
|