summaryrefslogtreecommitdiff
path: root/include/linux/highmem.h
diff options
context:
space:
mode:
authorFabio M. De Francesco <fmdefrancesco@gmail.com>2022-05-09 18:20:51 -0700
committerAndrew Morton <akpm@linux-foundation.org>2022-05-13 07:20:06 -0700
commitf38adfef7e6bfe681d6602b6668be31fe1310ed0 (patch)
treebbc24e92abab0dddbee031911eeb7d3705f788ae /include/linux/highmem.h
parent3c81b3bb0a33e2b555edb8d7eb99a7ae4f17d8bb (diff)
downloadlwn-f38adfef7e6bfe681d6602b6668be31fe1310ed0.tar.gz
lwn-f38adfef7e6bfe681d6602b6668be31fe1310ed0.zip
mm/highmem: VM_BUG_ON() if offset + len > PAGE_SIZE
Add VM_BUG_ON() bounds checking to make sure that, if "offset + len> PAGE_SIZE", memset() does not corrupt data in adjacent pages. Mainly to match all the similar functions in highmem.h. Link: https://lkml.kernel.org/r/20220426193020.8710-1-fmdefrancesco@gmail.com Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com> Reviewed-by: Andrew Morton <akpm@linux-foundation.org> Cc: Ira Weiny <ira.weiny@intel.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org> Cc: Peter Collingbourne <pcc@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'include/linux/highmem.h')
-rw-r--r--include/linux/highmem.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/include/linux/highmem.h b/include/linux/highmem.h
index 39bb9b47fa9c..67720bfd6ade 100644
--- a/include/linux/highmem.h
+++ b/include/linux/highmem.h
@@ -358,6 +358,8 @@ static inline void memcpy_to_page(struct page *page, size_t offset,
static inline void memzero_page(struct page *page, size_t offset, size_t len)
{
char *addr = kmap_local_page(page);
+
+ VM_BUG_ON(offset + len > PAGE_SIZE);
memset(addr + offset, 0, len);
flush_dcache_page(page);
kunmap_local(addr);