Commit 88b2008e authored by Hugh Dickins's avatar Hugh Dickins Committed by Kleber Sacilotto de Souza

kaiser: tidied up kaiser_add/remove_mapping slightly

Yes, unmap_pud_range_nofree()'s declaration ought to be in a
header file really, but I'm not sure we want to use it anyway:
so for now just declare it inside kaiser_remove_mapping().
And there doesn't seem to be such a thing as unmap_p4d_range(),
even in a 5-level paging tree.
Acked-by: default avatarJiri Kosina <jkosina@suse.cz>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>

CVE-2017-5754
Signed-off-by: default avatarColin Ian King <colin.king@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent 0cf0da27
...@@ -286,8 +286,7 @@ void __init kaiser_init(void) ...@@ -286,8 +286,7 @@ void __init kaiser_init(void)
__PAGE_KERNEL); __PAGE_KERNEL);
} }
extern void unmap_pud_range_nofree(pgd_t *pgd, unsigned long start, unsigned long end); /* Add a mapping to the shadow mapping, and synchronize the mappings */
// add a mapping to the shadow-mapping, and synchronize the mappings
int kaiser_add_mapping(unsigned long addr, unsigned long size, unsigned long flags) int kaiser_add_mapping(unsigned long addr, unsigned long size, unsigned long flags)
{ {
return kaiser_add_user_map((const void *)addr, size, flags); return kaiser_add_user_map((const void *)addr, size, flags);
...@@ -295,15 +294,13 @@ int kaiser_add_mapping(unsigned long addr, unsigned long size, unsigned long fla ...@@ -295,15 +294,13 @@ int kaiser_add_mapping(unsigned long addr, unsigned long size, unsigned long fla
void kaiser_remove_mapping(unsigned long start, unsigned long size) void kaiser_remove_mapping(unsigned long start, unsigned long size)
{ {
extern void unmap_pud_range_nofree(pgd_t *pgd,
unsigned long start, unsigned long end);
unsigned long end = start + size; unsigned long end = start + size;
unsigned long addr; unsigned long addr;
for (addr = start; addr < end; addr += PGDIR_SIZE) { for (addr = start; addr < end; addr += PGDIR_SIZE) {
pgd_t *pgd = native_get_shadow_pgd(pgd_offset_k(addr)); pgd_t *pgd = native_get_shadow_pgd(pgd_offset_k(addr));
/*
* unmap_p4d_range() handles > P4D_SIZE unmaps,
* so no need to trim 'end'.
*/
unmap_pud_range_nofree(pgd, addr, end); unmap_pud_range_nofree(pgd, addr, end);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment