x86/ioremap: Use is_ioremap_addr() in iounmap()
Subsystems (4)
PATCH v4 1/1 x86/ioremap: Use is_ioremap_addr() in iounmap()
Restrict iounmap() to memory allocated in ioremap region, by using is_ioremap_addr(). Similarly to the generic iounmap() implementation.
Additionally, add warning in case there is an attempt to iounmap() invalid memory, instead of silently exiting, thus helping to avoid incorrect usage of iounmap().
Due to VMALLOC_START on i386 not being present in asm/pgtable.h, include for asm/vmalloc.h had to be added to include/linux/ioremap.h.
Reviewed-by Christoph Hellwig <[email protected]>
Reviewed-by Alistair Popple <[email protected]>
Signed-off-by Max Ramanouski <[email protected]>
--- arch/x86/mm/ioremap.c | 3 ++- include/linux/ioremap.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)
arch/x86/mm/ioremap.c +2 -1
@@ -11,6 +11,7 @@#include <linux/init.h> #include <linux/io.h> #include <linux/ioport.h> +#include <linux/ioremap.h> #include <linux/slab.h> #include <linux/vmalloc.h> #include <linux/mmiotrace.h>
@@ -457,7 +458,7 @@ void iounmap(volatile void __iomem *addr) {struct vm_struct *p, *o; -if ((void __force *)addr <= high_memory) +if (WARN_ON_ONCE (!is_ioremap_addr ((void __force *)addr)))return ;/*
include/linux/ioremap.h +1 -0
@@ -4,6 +4,7 @@#include <linux/kasan.h> #include <asm/pgtable.h> +#include <asm/vmalloc.h> #if defined(CONFIG_HAS_IOMEM ) || defined(CONFIG_GENERIC_IOREMAP )/*
Signature · 1 line
2.45.2