lkml.org 
[lkml]   [2022]   [Apr]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH] mm/highmem: VM_BUG_ON() if offset + len > PAGE_SIZE
    Date
    Add VM_BUG_ON() bounds checking to make sure that, if "offset + len>
    PAGE_SIZE", memset() does not corrupt data in adjacent pages.

    Cc: Ira Weiny <ira.weiny@intel.com>
    Signed-off-by: Fabio M. De Francesco <fmdefrancesco@gmail.com>
    ---
    include/linux/highmem.h | 2 ++
    1 file changed, 2 insertions(+)

    diff --git a/include/linux/highmem.h b/include/linux/highmem.h
    index 6b2d59e025c5..d54dbaae9a5e 100644
    --- a/include/linux/highmem.h
    +++ b/include/linux/highmem.h
    @@ -380,6 +380,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);
    --
    2.34.1
    \
     
     \ /
      Last update: 2022-04-26 21:32    [W:2.602 / U:0.216 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site