kernel: kmem_ptr_validate considered harmful
This is a nasty and error prone API. It is no longer used, remove it. Signed-off-by: Nick Piggin <npiggin@kernel.dk>
This commit is contained in:
21
mm/util.c
21
mm/util.c
@@ -186,27 +186,6 @@ void kzfree(const void *p)
|
||||
}
|
||||
EXPORT_SYMBOL(kzfree);
|
||||
|
||||
int kern_ptr_validate(const void *ptr, unsigned long size)
|
||||
{
|
||||
unsigned long addr = (unsigned long)ptr;
|
||||
unsigned long min_addr = PAGE_OFFSET;
|
||||
unsigned long align_mask = sizeof(void *) - 1;
|
||||
|
||||
if (unlikely(addr < min_addr))
|
||||
goto out;
|
||||
if (unlikely(addr > (unsigned long)high_memory - size))
|
||||
goto out;
|
||||
if (unlikely(addr & align_mask))
|
||||
goto out;
|
||||
if (unlikely(!kern_addr_valid(addr)))
|
||||
goto out;
|
||||
if (unlikely(!kern_addr_valid(addr + size - 1)))
|
||||
goto out;
|
||||
return 1;
|
||||
out:
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* strndup_user - duplicate an existing string from user space
|
||||
* @s: The string to duplicate
|
||||
|
Reference in New Issue
Block a user