+ mm-cma-fix-incorrect-type-conversion-for-size-during-dma-allocation.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: mm: cma: fix incorrect type conversion for size during dma allocation
has been added to the -mm tree.  Its filename is
     mm-cma-fix-incorrect-type-conversion-for-size-during-dma-allocation.patch

This patch should soon appear at
    http://ozlabs.org/~akpm/mmots/broken-out/mm-cma-fix-incorrect-type-conversion-for-size-during-dma-allocation.patch
and later at
    http://ozlabs.org/~akpm/mmotm/broken-out/mm-cma-fix-incorrect-type-conversion-for-size-during-dma-allocation.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: Rohit Vaswani <rvaswani@xxxxxxxxxxxxxx>
Subject: mm: cma: fix incorrect type conversion for size during dma allocation

This was found during userspace fuzzing test when a large size dma cma
allocation is made by driver(like ion) through userspace.

 show_stack+0x10/0x1c
 dump_stack+0x74/0xc8
 kasan_report_error+0x2b0/0x408
 kasan_report+0x34/0x40
 __asan_storeN+0x15c/0x168
 memset+0x20/0x44
 __dma_alloc_coherent+0x114/0x18c

Signed-off-by: Rohit Vaswani <rvaswani@xxxxxxxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
Cc: Marek Szyprowski <m.szyprowski@xxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 drivers/base/dma-contiguous.c  |    2 +-
 include/linux/cma.h            |    2 +-
 include/linux/dma-contiguous.h |    4 ++--
 mm/cma.c                       |    4 ++--
 4 files changed, 6 insertions(+), 6 deletions(-)

diff -puN drivers/base/dma-contiguous.c~mm-cma-fix-incorrect-type-conversion-for-size-during-dma-allocation drivers/base/dma-contiguous.c
--- a/drivers/base/dma-contiguous.c~mm-cma-fix-incorrect-type-conversion-for-size-during-dma-allocation
+++ a/drivers/base/dma-contiguous.c
@@ -187,7 +187,7 @@ int __init dma_contiguous_reserve_area(p
  * 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 -puN include/linux/cma.h~mm-cma-fix-incorrect-type-conversion-for-size-during-dma-allocation include/linux/cma.h
--- a/include/linux/cma.h~mm-cma-fix-incorrect-type-conversion-for-size-during-dma-allocation
+++ a/include/linux/cma.h
@@ -26,6 +26,6 @@ extern int __init cma_declare_contiguous
 extern int cma_init_reserved_mem(phys_addr_t base, phys_addr_t size,
 					unsigned int order_per_bit,
 					struct cma **res_cma);
-extern struct page *cma_alloc(struct cma *cma, unsigned 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, const struct page *pages, unsigned int count);
 #endif
diff -puN include/linux/dma-contiguous.h~mm-cma-fix-incorrect-type-conversion-for-size-during-dma-allocation include/linux/dma-contiguous.h
--- a/include/linux/dma-contiguous.h~mm-cma-fix-incorrect-type-conversion-for-size-during-dma-allocation
+++ a/include/linux/dma-contiguous.h
@@ -111,7 +111,7 @@ static inline int dma_declare_contiguous
 	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
 }
 
 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 -puN mm/cma.c~mm-cma-fix-incorrect-type-conversion-for-size-during-dma-allocation mm/cma.c
--- a/mm/cma.c~mm-cma-fix-incorrect-type-conversion-for-size-during-dma-allocation
+++ a/mm/cma.c
@@ -361,7 +361,7 @@ err:
  * This function allocates part of contiguous memory on specific
  * contiguous memory area.
  */
-struct page *cma_alloc(struct cma *cma, unsigned int count, unsigned int align)
+struct page *cma_alloc(struct cma *cma, size_t count, unsigned int align)
 {
 	unsigned long mask, offset, pfn, start = 0;
 	unsigned long bitmap_maxno, bitmap_no, bitmap_count;
@@ -371,7 +371,7 @@ struct page *cma_alloc(struct cma *cma,
 	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)
_

Patches currently in -mm which might be from rvaswani@xxxxxxxxxxxxxx are

mm-cma-fix-incorrect-type-conversion-for-size-during-dma-allocation.patch

--
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Newbies FAQ]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Photo]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux