[tip:x86/urgent] x86/platform/UV: Fix bug with iounmap() of the UV4 EFI System Table causing a crash

From: tip-bot for Mike Travis
Date: Wed Aug 10 2016 - 14:12:24 EST


Commit-ID: e363d24c2b997c421476c6aa00547edadf678efe
Gitweb: http://git.kernel.org/tip/e363d24c2b997c421476c6aa00547edadf678efe
Author: Mike Travis <travis@xxxxxxx>
AuthorDate: Mon, 1 Aug 2016 13:40:51 -0500
Committer: Ingo Molnar <mingo@xxxxxxxxxx>
CommitDate: Wed, 10 Aug 2016 15:55:38 +0200

x86/platform/UV: Fix bug with iounmap() of the UV4 EFI System Table causing a crash

Save the uv_systab::size field before doing the iounmap()
of the struct pointer, to avoid a NULL dereference crash.

Tested-by: Frank Ramsay <framsay@xxxxxxx>
Tested-by: John Estabrook <estabrook@xxxxxxx>
Signed-off-by: Mike Travis <travis@xxxxxxx>
Reviewed-by: Dimitri Sivanich <sivanich@xxxxxxx>
Reviewed-by: Nathan Zimmer <nzimmer@xxxxxxx>
Cc: Alex Thorlton <athorlton@xxxxxxx>
Cc: Andrew Banman <abanman@xxxxxxx>
Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Russ Anderson <rja@xxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Link: http://lkml.kernel.org/r/20160801184050.250424783@xxxxxxxxxxxxxxxxxxxxxxx
Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
---
arch/x86/platform/uv/bios_uv.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/arch/x86/platform/uv/bios_uv.c b/arch/x86/platform/uv/bios_uv.c
index 66b2166..4e9fd13 100644
--- a/arch/x86/platform/uv/bios_uv.c
+++ b/arch/x86/platform/uv/bios_uv.c
@@ -199,12 +199,14 @@ void uv_bios_init(void)
return;
}

+ /* Starting with UV4 the UV systab size is variable */
if (uv_systab->revision >= UV_SYSTAB_VERSION_UV4) {
+ int size = uv_systab->size;
+
iounmap(uv_systab);
- uv_systab = ioremap(efi.uv_systab, uv_systab->size);
+ uv_systab = ioremap(efi.uv_systab, size);
if (!uv_systab) {
- pr_err("UV: UVsystab: ioremap(%d) failed!\n",
- uv_systab->size);
+ pr_err("UV: UVsystab: ioremap(%d) failed!\n", size);
return;
}
}