highmem: Enhance is_kmap_addr() to check kmap_local_page() mappings
authorIra Weiny <ira.weiny@intel.com>
Sat, 4 Feb 2023 04:06:32 +0000 (20:06 -0800)
committerJens Wiklander <jens.wiklander@linaro.org>
Mon, 13 Feb 2023 13:16:35 +0000 (14:16 +0100)
is_kmap_addr() is only looking at the kmap() address range which may
cause check_heap_object() to miss checking an overflow on a
kmap_local_page() page.

Add a check for the kmap_local_page() address range to is_kmap_addr().

Cc: Matthew Wilcox <willy@infradead.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: "Fabio M. De Francesco" <fmdefrancesco@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Acked-by: Andrew Morton <akpm@linux-foudation.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
include/linux/highmem-internal.h

index e098f38422af58ba9dcb30caf4f3e182a412072f..a3028e400a9c65254f9f15e4071264975dc7b1d2 100644 (file)
@@ -152,7 +152,10 @@ static inline void totalhigh_pages_add(long count)
 static inline bool is_kmap_addr(const void *x)
 {
        unsigned long addr = (unsigned long)x;
-       return addr >= PKMAP_ADDR(0) && addr < PKMAP_ADDR(LAST_PKMAP);
+
+       return (addr >= PKMAP_ADDR(0) && addr < PKMAP_ADDR(LAST_PKMAP)) ||
+               (addr >= __fix_to_virt(FIX_KMAP_END) &&
+                addr < __fix_to_virt(FIX_KMAP_BEGIN));
 }
 #else /* CONFIG_HIGHMEM */