Linux/linux ffc8599arch/x86/kernel aperture_64.c, fs/proc kcore.c

x86/gart: Exclude GART aperture from kcore

On machines where the GART aperture is mapped over physical RAM,
/proc/kcore contains the GART aperture range. Accessing the GART range via
/proc/kcore results in a kernel crash.

vmcore used to have the same issue, until it was fixed with commit
2a3e83c6f96c ("x86/gart: Exclude GART aperture from vmcore")', leveraging
existing hook infrastructure in vmcore to let /proc/vmcore return zeroes
when attempting to read the aperture region, and so it won't read from the
actual memory.

Apply the same workaround for kcore. First implement the same hook
infrastructure for kcore, then reuse the hook functions introduced in the
previous vmcore fix. Just with some minor adjustment, rename some functions
for more general usage, and simplify the hook infrastructure a bit as there
is no module usage yet.

Suggested-by: Baoquan He <bhe at redhat.com>
Signed-off-by: Kairui Song <kasong at redhat.com>
Signed-off-by: Thomas Gleixner <tglx at linutronix.de>
Reviewed-by: Jiri Bohac <jbohac at suse.cz>
Acked-by: Baoquan He <bhe at redhat.com>
Cc: Borislav Petkov <bp at alien8.de>
Cc: "H. Peter Anvin" <hpa at zytor.com>
Cc: Alexey Dobriyan <adobriyan at gmail.com>
Cc: Andrew Morton <akpm at linux-foundation.org>
Cc: Omar Sandoval <osandov at fb.com>
Cc: Dave Young <dyoung at redhat.com>
Link: https://lkml.kernel.org/r/20190308030508.13548-1-kasong@redhat.com


DeltaFile
+27-0fs/proc/kcore.c
+13-7arch/x86/kernel/aperture_64.c
+2-0include/linux/kcore.h
+42-73 files

UnifiedSplitRaw