Re: [PATCH 2/2] x86/KASLR/64: Determine kernel text mapping size at runtime

From: Baoquan He
Date: Thu Dec 08 2016 - 03:25:37 EST


On 12/08/16 at 02:17pm, Alexnader Kuleshov wrote:
> Hello,
>
> On 12-08-16, Baoquan He wrote:
> > #define KERNEL_MAPPING_SIZE_EXT (1024 * 1024 * 1024)
> > -#if defined(CONFIG_RANDOMIZE_BASE)
> > -#define KERNEL_IMAGE_SIZE KERNEL_MAPPING_SIZE_EXT
> > -#else
> > -#define KERNEL_IMAGE_SIZE (512 * 1024 * 1024)
> > -#endif
> > +#define KERNEL_MAPPING_SIZE kernel_mapping_size

Thanks for telling. I forget testing this case. Checking.

>
> After applying these patches I'm getting:
>
> CC arch/x86/kernel/setup.o
> In file included from ./arch/x86/include/asm/page_types.h:47:0,
> from ./arch/x86/include/asm/page.h:8,
> from ./arch/x86/include/asm/thread_info.h:11,
> from ./include/linux/thread_info.h:58,
> from ./arch/x86/include/asm/preempt.h:6,
> from ./include/linux/preempt.h:59,
> from ./include/linux/spinlock.h:50,
> from ./include/linux/seqlock.h:35,
> from ./include/linux/time.h:5,
> from ./include/uapi/linux/timex.h:56,
> from ./include/linux/timex.h:56,
> from ./include/linux/sched.h:19,
> from arch/x86/kernel/setup.c:24:
> arch/x86/kernel/setup.c: In function âdump_kernel_offsetâ:
> ./arch/x86/include/asm/page_64_types.h:67:29: error: âkernel_mapping_sizeâ undeclared (first use in this function)
> #define KERNEL_MAPPING_SIZE kernel_mapping_size
> ^
> ./arch/x86/include/asm/pgtable_64_types.h:69:48: note: in expansion of macro âKERNEL_MAPPING_SIZEâ
> #define MODULES_VADDR (__START_KERNEL_map + KERNEL_MAPPING_SIZE)
> ^~~~~~~~~~~~~~~~~~~
> ./include/linux/printk.h:271:35: note: in expansion of macro âMODULES_VADDRâ
> printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
> ^~~~~~~~~~~
> arch/x86/kernel/setup.c:826:3: note: in expansion of macro âpr_emergâ
> pr_emerg("Kernel Offset: 0x%lx from 0x%lx (relocation range: 0x%lx-0x%lx)\n",
> ^~~~~~~~
> ./arch/x86/include/asm/page_64_types.h:67:29: note: each undeclared identifier is reported only once for each function it appears in
> #define KERNEL_MAPPING_SIZE kernel_mapping_size
> ^
> ./arch/x86/include/asm/pgtable_64_types.h:69:48: note: in expansion of macro âKERNEL_MAPPING_SIZEâ
> #define MODULES_VADDR (__START_KERNEL_map + KERNEL_MAPPING_SIZE)
> ^~~~~~~~~~~~~~~~~~~
> ./include/linux/printk.h:271:35: note: in expansion of macro âMODULES_VADDRâ
> printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
> ^~~~~~~~~~~
> arch/x86/kernel/setup.c:826:3: note: in expansion of macro âpr_emergâ
> pr_emerg("Kernel Offset: 0x%lx from 0x%lx (relocation range: 0x%lx-0x%lx)\n",
> ^~~~~~~~
> scripts/Makefile.build:293: recipe for target 'arch/x86/kernel/setup.o' failed
> make[2]: *** [arch/x86/kernel/setup.o] Error 1
> scripts/Makefile.build:544: recipe for target 'arch/x86/kernel' failed
> make[1]: *** [arch/x86/kernel] Error 2
> Makefile:988: recipe for target 'arch/x86' failed
> make: *** [arch/x86] Error 2
>
> here with disabled CONFIG_RANDOMIZE_MEMORY.