linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/mm/init_32: Don't print out kernel memory layout if KASLR
@ 2020-02-26 21:50 Arvind Sankar
  2020-02-29 23:51 ` Kees Cook
  0 siblings, 1 reply; 35+ messages in thread
From: Arvind Sankar @ 2020-02-26 21:50 UTC (permalink / raw)
  To: Tobin C . Harding, Tycho Andersen
  Cc: kernel-hardening, Dave Hansen, Andy Lutomirski, Peter Zijlstra,
	x86, linux-kernel

For security, only show the virtual kernel memory layout if KASLR is
disabled.

Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
---
 arch/x86/mm/init_32.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index 23df4885bbed..53635be69102 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -788,6 +788,10 @@ void __init mem_init(void)
 	x86_init.hyper.init_after_bootmem();
 
 	mem_init_print_info(NULL);
+
+	if (kaslr_enabled())
+		goto skip_layout;
+
 	printk(KERN_INFO "virtual kernel memory layout:\n"
 		"    fixmap  : 0x%08lx - 0x%08lx   (%4ld kB)\n"
 		"  cpu_entry : 0x%08lx - 0x%08lx   (%4ld kB)\n"
@@ -827,6 +831,7 @@ void __init mem_init(void)
 		(unsigned long)&_text, (unsigned long)&_etext,
 		((unsigned long)&_etext - (unsigned long)&_text) >> 10);
 
+skip_layout:
 	/*
 	 * Check boundaries twice: Some fundamental inconsistencies can
 	 * be detected at build time already.
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* Re: [PATCH] x86/mm/init_32: Don't print out kernel memory layout if KASLR
  2020-02-26 21:50 [PATCH] x86/mm/init_32: Don't print out kernel memory layout if KASLR Arvind Sankar
@ 2020-02-29 23:51 ` Kees Cook
  2020-03-01  0:11   ` Arvind Sankar
  2020-03-01  0:22   ` [PATCH v2] x86/mm/init_32: " Arvind Sankar
  0 siblings, 2 replies; 35+ messages in thread
From: Kees Cook @ 2020-02-29 23:51 UTC (permalink / raw)
  To: Arvind Sankar
  Cc: dave.hansen, kernel-hardening, linux-kernel, luto, me, peterz,
	tycho, x86

Arvind Sankar said:
> For security, only show the virtual kernel memory layout if KASLR is
> disabled.

These have been entirely removed on other architectures, so let's
just do the same for ia32 and remove it unconditionally.

071929dbdd86 ("arm64: Stop printing the virtual memory layout")
1c31d4e96b8c ("ARM: 8820/1: mm: Stop printing the virtual memory layout")
31833332f798 ("m68k/mm: Stop printing the virtual memory layout")
fd8d0ca25631 ("parisc: Hide virtual kernel memory layout")
adb1fe9ae2ee ("mm/page_alloc: Remove kernel address exposure in free_reserved_area()")

-Kees

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] x86/mm/init_32: Don't print out kernel memory layout if KASLR
  2020-02-29 23:51 ` Kees Cook
@ 2020-03-01  0:11   ` Arvind Sankar
  2020-03-02 18:38     ` Kees Cook
  2020-03-01  0:22   ` [PATCH v2] x86/mm/init_32: " Arvind Sankar
  1 sibling, 1 reply; 35+ messages in thread
From: Arvind Sankar @ 2020-03-01  0:11 UTC (permalink / raw)
  To: Kees Cook
  Cc: Arvind Sankar, dave.hansen, kernel-hardening, linux-kernel, luto,
	me, peterz, tycho, x86

On Sat, Feb 29, 2020 at 03:51:45PM -0800, Kees Cook wrote:
> Arvind Sankar said:
> > For security, only show the virtual kernel memory layout if KASLR is
> > disabled.
> 
> These have been entirely removed on other architectures, so let's
> just do the same for ia32 and remove it unconditionally.
> 
> 071929dbdd86 ("arm64: Stop printing the virtual memory layout")
> 1c31d4e96b8c ("ARM: 8820/1: mm: Stop printing the virtual memory layout")
> 31833332f798 ("m68k/mm: Stop printing the virtual memory layout")
> fd8d0ca25631 ("parisc: Hide virtual kernel memory layout")
> adb1fe9ae2ee ("mm/page_alloc: Remove kernel address exposure in free_reserved_area()")
> 
> -Kees
> 
> -- 
> Kees Cook

microblaze (arch/microblaze/mm/init.c) and PPC32 (arch/powerpc/mm/mem.c)
appear to still print it out. I can't test those, but will resubmit
x86-32 with it removed.

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v2] x86/mm/init_32: Stop printing the virtual memory layout
  2020-02-29 23:51 ` Kees Cook
  2020-03-01  0:11   ` Arvind Sankar
@ 2020-03-01  0:22   ` Arvind Sankar
  2020-03-02 15:29     ` Tycho Andersen
  2020-03-02 18:39     ` Kees Cook
  1 sibling, 2 replies; 35+ messages in thread
From: Arvind Sankar @ 2020-03-01  0:22 UTC (permalink / raw)
  To: Tobin C . Harding, Tycho Andersen
  Cc: kernel-hardening, Kees Cook, Dave Hansen, Andy Lutomirski,
	Peter Zijlstra, x86, linux-kernel

For security, don't display the kernel's virtual memory layout.

Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
---
 arch/x86/mm/init_32.c | 38 --------------------------------------
 1 file changed, 38 deletions(-)

diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index 23df4885bbed..8ae0272c1c51 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -788,44 +788,6 @@ void __init mem_init(void)
 	x86_init.hyper.init_after_bootmem();
 
 	mem_init_print_info(NULL);
-	printk(KERN_INFO "virtual kernel memory layout:\n"
-		"    fixmap  : 0x%08lx - 0x%08lx   (%4ld kB)\n"
-		"  cpu_entry : 0x%08lx - 0x%08lx   (%4ld kB)\n"
-#ifdef CONFIG_HIGHMEM
-		"    pkmap   : 0x%08lx - 0x%08lx   (%4ld kB)\n"
-#endif
-		"    vmalloc : 0x%08lx - 0x%08lx   (%4ld MB)\n"
-		"    lowmem  : 0x%08lx - 0x%08lx   (%4ld MB)\n"
-		"      .init : 0x%08lx - 0x%08lx   (%4ld kB)\n"
-		"      .data : 0x%08lx - 0x%08lx   (%4ld kB)\n"
-		"      .text : 0x%08lx - 0x%08lx   (%4ld kB)\n",
-		FIXADDR_START, FIXADDR_TOP,
-		(FIXADDR_TOP - FIXADDR_START) >> 10,
-
-		CPU_ENTRY_AREA_BASE,
-		CPU_ENTRY_AREA_BASE + CPU_ENTRY_AREA_MAP_SIZE,
-		CPU_ENTRY_AREA_MAP_SIZE >> 10,
-
-#ifdef CONFIG_HIGHMEM
-		PKMAP_BASE, PKMAP_BASE+LAST_PKMAP*PAGE_SIZE,
-		(LAST_PKMAP*PAGE_SIZE) >> 10,
-#endif
-
-		VMALLOC_START, VMALLOC_END,
-		(VMALLOC_END - VMALLOC_START) >> 20,
-
-		(unsigned long)__va(0), (unsigned long)high_memory,
-		((unsigned long)high_memory - (unsigned long)__va(0)) >> 20,
-
-		(unsigned long)&__init_begin, (unsigned long)&__init_end,
-		((unsigned long)&__init_end -
-		 (unsigned long)&__init_begin) >> 10,
-
-		(unsigned long)&_etext, (unsigned long)&_edata,
-		((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
-
-		(unsigned long)&_text, (unsigned long)&_etext,
-		((unsigned long)&_etext - (unsigned long)&_text) >> 10);
 
 	/*
 	 * Check boundaries twice: Some fundamental inconsistencies can
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* Re: [PATCH v2] x86/mm/init_32: Stop printing the virtual memory layout
  2020-03-01  0:22   ` [PATCH v2] x86/mm/init_32: " Arvind Sankar
@ 2020-03-02 15:29     ` Tycho Andersen
  2020-03-02 18:39     ` Kees Cook
  1 sibling, 0 replies; 35+ messages in thread
From: Tycho Andersen @ 2020-03-02 15:29 UTC (permalink / raw)
  To: Arvind Sankar
  Cc: Tobin C . Harding, kernel-hardening, Kees Cook, Dave Hansen,
	Andy Lutomirski, Peter Zijlstra, x86, linux-kernel

On Sat, Feb 29, 2020 at 07:22:09PM -0500, Arvind Sankar wrote:
> For security, don't display the kernel's virtual memory layout.
> 
> Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>

Acked-by: Tycho Andersen <tycho@tycho.ws>

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] x86/mm/init_32: Don't print out kernel memory layout if KASLR
  2020-03-01  0:11   ` Arvind Sankar
@ 2020-03-02 18:38     ` Kees Cook
  2020-03-05 15:05       ` [PATCH] microblaze: Stop printing the virtual memory layout Arvind Sankar
                         ` (4 more replies)
  0 siblings, 5 replies; 35+ messages in thread
From: Kees Cook @ 2020-03-02 18:38 UTC (permalink / raw)
  To: Arvind Sankar
  Cc: dave.hansen, kernel-hardening, linux-kernel, luto, me, peterz,
	tycho, x86

On Sat, Feb 29, 2020 at 07:11:23PM -0500, Arvind Sankar wrote:
> On Sat, Feb 29, 2020 at 03:51:45PM -0800, Kees Cook wrote:
> > Arvind Sankar said:
> > > For security, only show the virtual kernel memory layout if KASLR is
> > > disabled.
> > 
> > These have been entirely removed on other architectures, so let's
> > just do the same for ia32 and remove it unconditionally.
> > 
> > 071929dbdd86 ("arm64: Stop printing the virtual memory layout")
> > 1c31d4e96b8c ("ARM: 8820/1: mm: Stop printing the virtual memory layout")
> > 31833332f798 ("m68k/mm: Stop printing the virtual memory layout")
> > fd8d0ca25631 ("parisc: Hide virtual kernel memory layout")
> > adb1fe9ae2ee ("mm/page_alloc: Remove kernel address exposure in free_reserved_area()")
> > 
> > -Kees
> > 
> > -- 
> > Kees Cook
> 
> microblaze (arch/microblaze/mm/init.c) and PPC32 (arch/powerpc/mm/mem.c)
> appear to still print it out. I can't test those, but will resubmit
> x86-32 with it removed.

Might as well fix those up too. :)

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH v2] x86/mm/init_32: Stop printing the virtual memory layout
  2020-03-01  0:22   ` [PATCH v2] x86/mm/init_32: " Arvind Sankar
  2020-03-02 15:29     ` Tycho Andersen
@ 2020-03-02 18:39     ` Kees Cook
  2020-03-05 15:01       ` [PATCH v3] " Arvind Sankar
  1 sibling, 1 reply; 35+ messages in thread
From: Kees Cook @ 2020-03-02 18:39 UTC (permalink / raw)
  To: Arvind Sankar
  Cc: Tobin C . Harding, Tycho Andersen, kernel-hardening, Dave Hansen,
	Andy Lutomirski, Peter Zijlstra, x86, linux-kernel

On Sat, Feb 29, 2020 at 07:22:09PM -0500, Arvind Sankar wrote:
> For security, don't display the kernel's virtual memory layout.
> 
> Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>

If this needs a v3, I'd just list the commits I mentioned for further
justification. But regardless:

Acked-by: Kees Cook <keescook@chromium.org>

-Kees

> ---
>  arch/x86/mm/init_32.c | 38 --------------------------------------
>  1 file changed, 38 deletions(-)
> 
> diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
> index 23df4885bbed..8ae0272c1c51 100644
> --- a/arch/x86/mm/init_32.c
> +++ b/arch/x86/mm/init_32.c
> @@ -788,44 +788,6 @@ void __init mem_init(void)
>  	x86_init.hyper.init_after_bootmem();
>  
>  	mem_init_print_info(NULL);
> -	printk(KERN_INFO "virtual kernel memory layout:\n"
> -		"    fixmap  : 0x%08lx - 0x%08lx   (%4ld kB)\n"
> -		"  cpu_entry : 0x%08lx - 0x%08lx   (%4ld kB)\n"
> -#ifdef CONFIG_HIGHMEM
> -		"    pkmap   : 0x%08lx - 0x%08lx   (%4ld kB)\n"
> -#endif
> -		"    vmalloc : 0x%08lx - 0x%08lx   (%4ld MB)\n"
> -		"    lowmem  : 0x%08lx - 0x%08lx   (%4ld MB)\n"
> -		"      .init : 0x%08lx - 0x%08lx   (%4ld kB)\n"
> -		"      .data : 0x%08lx - 0x%08lx   (%4ld kB)\n"
> -		"      .text : 0x%08lx - 0x%08lx   (%4ld kB)\n",
> -		FIXADDR_START, FIXADDR_TOP,
> -		(FIXADDR_TOP - FIXADDR_START) >> 10,
> -
> -		CPU_ENTRY_AREA_BASE,
> -		CPU_ENTRY_AREA_BASE + CPU_ENTRY_AREA_MAP_SIZE,
> -		CPU_ENTRY_AREA_MAP_SIZE >> 10,
> -
> -#ifdef CONFIG_HIGHMEM
> -		PKMAP_BASE, PKMAP_BASE+LAST_PKMAP*PAGE_SIZE,
> -		(LAST_PKMAP*PAGE_SIZE) >> 10,
> -#endif
> -
> -		VMALLOC_START, VMALLOC_END,
> -		(VMALLOC_END - VMALLOC_START) >> 20,
> -
> -		(unsigned long)__va(0), (unsigned long)high_memory,
> -		((unsigned long)high_memory - (unsigned long)__va(0)) >> 20,
> -
> -		(unsigned long)&__init_begin, (unsigned long)&__init_end,
> -		((unsigned long)&__init_end -
> -		 (unsigned long)&__init_begin) >> 10,
> -
> -		(unsigned long)&_etext, (unsigned long)&_edata,
> -		((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
> -
> -		(unsigned long)&_text, (unsigned long)&_etext,
> -		((unsigned long)&_etext - (unsigned long)&_text) >> 10);
>  
>  	/*
>  	 * Check boundaries twice: Some fundamental inconsistencies can
> -- 
> 2.24.1
> 

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v3] x86/mm/init_32: Stop printing the virtual memory layout
  2020-03-02 18:39     ` Kees Cook
@ 2020-03-05 15:01       ` Arvind Sankar
  2020-03-05 17:28         ` Kees Cook
                           ` (2 more replies)
  0 siblings, 3 replies; 35+ messages in thread
From: Arvind Sankar @ 2020-03-05 15:01 UTC (permalink / raw)
  To: Kees Cook
  Cc: Tobin C . Harding, Tycho Andersen, kernel-hardening, Dave Hansen,
	Andy Lutomirski, Peter Zijlstra, x86, linux-kernel

For security, don't display the kernel's virtual memory layout.

Kees Cook points out:
"These have been entirely removed on other architectures, so let's
just do the same for ia32 and remove it unconditionally."

071929dbdd86 ("arm64: Stop printing the virtual memory layout")
1c31d4e96b8c ("ARM: 8820/1: mm: Stop printing the virtual memory layout")
31833332f798 ("m68k/mm: Stop printing the virtual memory layout")
fd8d0ca25631 ("parisc: Hide virtual kernel memory layout")
adb1fe9ae2ee ("mm/page_alloc: Remove kernel address exposure in free_reserved_area()")

Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
---
 arch/x86/mm/init_32.c | 38 --------------------------------------
 1 file changed, 38 deletions(-)

diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index 23df4885bbed..8ae0272c1c51 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -788,44 +788,6 @@ void __init mem_init(void)
 	x86_init.hyper.init_after_bootmem();
 
 	mem_init_print_info(NULL);
-	printk(KERN_INFO "virtual kernel memory layout:\n"
-		"    fixmap  : 0x%08lx - 0x%08lx   (%4ld kB)\n"
-		"  cpu_entry : 0x%08lx - 0x%08lx   (%4ld kB)\n"
-#ifdef CONFIG_HIGHMEM
-		"    pkmap   : 0x%08lx - 0x%08lx   (%4ld kB)\n"
-#endif
-		"    vmalloc : 0x%08lx - 0x%08lx   (%4ld MB)\n"
-		"    lowmem  : 0x%08lx - 0x%08lx   (%4ld MB)\n"
-		"      .init : 0x%08lx - 0x%08lx   (%4ld kB)\n"
-		"      .data : 0x%08lx - 0x%08lx   (%4ld kB)\n"
-		"      .text : 0x%08lx - 0x%08lx   (%4ld kB)\n",
-		FIXADDR_START, FIXADDR_TOP,
-		(FIXADDR_TOP - FIXADDR_START) >> 10,
-
-		CPU_ENTRY_AREA_BASE,
-		CPU_ENTRY_AREA_BASE + CPU_ENTRY_AREA_MAP_SIZE,
-		CPU_ENTRY_AREA_MAP_SIZE >> 10,
-
-#ifdef CONFIG_HIGHMEM
-		PKMAP_BASE, PKMAP_BASE+LAST_PKMAP*PAGE_SIZE,
-		(LAST_PKMAP*PAGE_SIZE) >> 10,
-#endif
-
-		VMALLOC_START, VMALLOC_END,
-		(VMALLOC_END - VMALLOC_START) >> 20,
-
-		(unsigned long)__va(0), (unsigned long)high_memory,
-		((unsigned long)high_memory - (unsigned long)__va(0)) >> 20,
-
-		(unsigned long)&__init_begin, (unsigned long)&__init_end,
-		((unsigned long)&__init_end -
-		 (unsigned long)&__init_begin) >> 10,
-
-		(unsigned long)&_etext, (unsigned long)&_edata,
-		((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
-
-		(unsigned long)&_text, (unsigned long)&_etext,
-		((unsigned long)&_etext - (unsigned long)&_text) >> 10);
 
 	/*
 	 * Check boundaries twice: Some fundamental inconsistencies can
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH] microblaze: Stop printing the virtual memory layout
  2020-03-02 18:38     ` Kees Cook
@ 2020-03-05 15:05       ` Arvind Sankar
  2020-03-05 20:50         ` Tycho Andersen
  2020-03-09 10:09         ` Michal Simek
  2020-03-05 15:06       ` [PATCH] nds32/mm: " Arvind Sankar
                         ` (3 subsequent siblings)
  4 siblings, 2 replies; 35+ messages in thread
From: Arvind Sankar @ 2020-03-05 15:05 UTC (permalink / raw)
  To: Kees Cook
  Cc: Tobin C . Harding, Tycho Andersen, kernel-hardening,
	Michal Simek, linux-kernel

For security, don't display the kernel's virtual memory layout.

Kees Cook points out:
"These have been entirely removed on other architectures, so let's
just do the same for ia32 and remove it unconditionally."

071929dbdd86 ("arm64: Stop printing the virtual memory layout")
1c31d4e96b8c ("ARM: 8820/1: mm: Stop printing the virtual memory layout")
31833332f798 ("m68k/mm: Stop printing the virtual memory layout")
fd8d0ca25631 ("parisc: Hide virtual kernel memory layout")
adb1fe9ae2ee ("mm/page_alloc: Remove kernel address exposure in free_reserved_area()")

Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
---
 arch/microblaze/mm/init.c | 12 ------------
 1 file changed, 12 deletions(-)

diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c
index 1056f1674065..8323651bf7ec 100644
--- a/arch/microblaze/mm/init.c
+++ b/arch/microblaze/mm/init.c
@@ -201,18 +201,6 @@ void __init mem_init(void)
 #endif
 
 	mem_init_print_info(NULL);
-#ifdef CONFIG_MMU
-	pr_info("Kernel virtual memory layout:\n");
-	pr_info("  * 0x%08lx..0x%08lx  : fixmap\n", FIXADDR_START, FIXADDR_TOP);
-#ifdef CONFIG_HIGHMEM
-	pr_info("  * 0x%08lx..0x%08lx  : highmem PTEs\n",
-		PKMAP_BASE, PKMAP_ADDR(LAST_PKMAP));
-#endif /* CONFIG_HIGHMEM */
-	pr_info("  * 0x%08lx..0x%08lx  : early ioremap\n",
-		ioremap_bot, ioremap_base);
-	pr_info("  * 0x%08lx..0x%08lx  : vmalloc & ioremap\n",
-		(unsigned long)VMALLOC_START, VMALLOC_END);
-#endif
 	mem_init_done = 1;
 }
 
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH] nds32/mm: Stop printing the virtual memory layout
  2020-03-02 18:38     ` Kees Cook
  2020-03-05 15:05       ` [PATCH] microblaze: Stop printing the virtual memory layout Arvind Sankar
@ 2020-03-05 15:06       ` Arvind Sankar
  2020-03-05 20:50         ` Tycho Andersen
  2020-03-05 15:08       ` [PATCH] powerpc/32: " Arvind Sankar
                         ` (2 subsequent siblings)
  4 siblings, 1 reply; 35+ messages in thread
From: Arvind Sankar @ 2020-03-05 15:06 UTC (permalink / raw)
  To: Kees Cook
  Cc: Tobin C . Harding, Tycho Andersen, kernel-hardening, Nick Hu,
	Greentime Hu, Vincent Chen, linux-kernel

For security, don't display the kernel's virtual memory layout.

Kees Cook points out:
"These have been entirely removed on other architectures, so let's
just do the same for ia32 and remove it unconditionally."

071929dbdd86 ("arm64: Stop printing the virtual memory layout")
1c31d4e96b8c ("ARM: 8820/1: mm: Stop printing the virtual memory layout")
31833332f798 ("m68k/mm: Stop printing the virtual memory layout")
fd8d0ca25631 ("parisc: Hide virtual kernel memory layout")
adb1fe9ae2ee ("mm/page_alloc: Remove kernel address exposure in free_reserved_area()")

Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
---
 arch/nds32/mm/init.c | 30 ------------------------------
 1 file changed, 30 deletions(-)

diff --git a/arch/nds32/mm/init.c b/arch/nds32/mm/init.c
index 0be3833f6814..1c1e79b4407c 100644
--- a/arch/nds32/mm/init.c
+++ b/arch/nds32/mm/init.c
@@ -205,36 +205,6 @@ void __init mem_init(void)
 	memblock_free_all();
 	mem_init_print_info(NULL);
 
-	pr_info("virtual kernel memory layout:\n"
-		"    fixmap  : 0x%08lx - 0x%08lx   (%4ld kB)\n"
-#ifdef CONFIG_HIGHMEM
-		"    pkmap   : 0x%08lx - 0x%08lx   (%4ld kB)\n"
-#endif
-		"    consist : 0x%08lx - 0x%08lx   (%4ld MB)\n"
-		"    vmalloc : 0x%08lx - 0x%08lx   (%4ld MB)\n"
-		"    lowmem  : 0x%08lx - 0x%08lx   (%4ld MB)\n"
-		"      .init : 0x%08lx - 0x%08lx   (%4ld kB)\n"
-		"      .data : 0x%08lx - 0x%08lx   (%4ld kB)\n"
-		"      .text : 0x%08lx - 0x%08lx   (%4ld kB)\n",
-		FIXADDR_START, FIXADDR_TOP, (FIXADDR_TOP - FIXADDR_START) >> 10,
-#ifdef CONFIG_HIGHMEM
-		PKMAP_BASE, PKMAP_BASE + LAST_PKMAP * PAGE_SIZE,
-		(LAST_PKMAP * PAGE_SIZE) >> 10,
-#endif
-		CONSISTENT_BASE, CONSISTENT_END,
-		((CONSISTENT_END) - (CONSISTENT_BASE)) >> 20, VMALLOC_START,
-		(unsigned long)VMALLOC_END, (VMALLOC_END - VMALLOC_START) >> 20,
-		(unsigned long)__va(memory_start), (unsigned long)high_memory,
-		((unsigned long)high_memory -
-		 (unsigned long)__va(memory_start)) >> 20,
-		(unsigned long)&__init_begin, (unsigned long)&__init_end,
-		((unsigned long)&__init_end -
-		 (unsigned long)&__init_begin) >> 10, (unsigned long)&_etext,
-		(unsigned long)&_edata,
-		((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
-		(unsigned long)&_text, (unsigned long)&_etext,
-		((unsigned long)&_etext - (unsigned long)&_text) >> 10);
-
 	/*
 	 * Check boundaries twice: Some fundamental inconsistencies can
 	 * be detected at build time already.
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH] powerpc/32: Stop printing the virtual memory layout
  2020-03-02 18:38     ` Kees Cook
  2020-03-05 15:05       ` [PATCH] microblaze: Stop printing the virtual memory layout Arvind Sankar
  2020-03-05 15:06       ` [PATCH] nds32/mm: " Arvind Sankar
@ 2020-03-05 15:08       ` Arvind Sankar
  2020-03-05 20:50         ` Tycho Andersen
  2022-03-09 19:35         ` Christophe Leroy
  2020-03-05 15:10       ` [PATCH] sh: " Arvind Sankar
  2020-03-05 15:11       ` [PATCH] xtensa/mm: " Arvind Sankar
  4 siblings, 2 replies; 35+ messages in thread
From: Arvind Sankar @ 2020-03-05 15:08 UTC (permalink / raw)
  To: Kees Cook
  Cc: Tobin C . Harding, Tycho Andersen, kernel-hardening,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	linuxppc-dev, linux-kernel

For security, don't display the kernel's virtual memory layout.

Kees Cook points out:
"These have been entirely removed on other architectures, so let's
just do the same for ia32 and remove it unconditionally."

071929dbdd86 ("arm64: Stop printing the virtual memory layout")
1c31d4e96b8c ("ARM: 8820/1: mm: Stop printing the virtual memory layout")
31833332f798 ("m68k/mm: Stop printing the virtual memory layout")
fd8d0ca25631 ("parisc: Hide virtual kernel memory layout")
adb1fe9ae2ee ("mm/page_alloc: Remove kernel address exposure in free_reserved_area()")

Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
---
 arch/powerpc/mm/mem.c | 17 -----------------
 1 file changed, 17 deletions(-)

diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index ef7b1119b2e2..df2c143b6bf7 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -331,23 +331,6 @@ void __init mem_init(void)
 #endif
 
 	mem_init_print_info(NULL);
-#ifdef CONFIG_PPC32
-	pr_info("Kernel virtual memory layout:\n");
-#ifdef CONFIG_KASAN
-	pr_info("  * 0x%08lx..0x%08lx  : kasan shadow mem\n",
-		KASAN_SHADOW_START, KASAN_SHADOW_END);
-#endif
-	pr_info("  * 0x%08lx..0x%08lx  : fixmap\n", FIXADDR_START, FIXADDR_TOP);
-#ifdef CONFIG_HIGHMEM
-	pr_info("  * 0x%08lx..0x%08lx  : highmem PTEs\n",
-		PKMAP_BASE, PKMAP_ADDR(LAST_PKMAP));
-#endif /* CONFIG_HIGHMEM */
-	if (ioremap_bot != IOREMAP_TOP)
-		pr_info("  * 0x%08lx..0x%08lx  : early ioremap\n",
-			ioremap_bot, IOREMAP_TOP);
-	pr_info("  * 0x%08lx..0x%08lx  : vmalloc & ioremap\n",
-		VMALLOC_START, VMALLOC_END);
-#endif /* CONFIG_PPC32 */
 }
 
 void free_initmem(void)
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH] sh: Stop printing the virtual memory layout
  2020-03-02 18:38     ` Kees Cook
                         ` (2 preceding siblings ...)
  2020-03-05 15:08       ` [PATCH] powerpc/32: " Arvind Sankar
@ 2020-03-05 15:10       ` Arvind Sankar
  2020-03-05 15:18         ` John Paul Adrian Glaubitz
  2020-03-05 15:11       ` [PATCH] xtensa/mm: " Arvind Sankar
  4 siblings, 1 reply; 35+ messages in thread
From: Arvind Sankar @ 2020-03-05 15:10 UTC (permalink / raw)
  To: Kees Cook
  Cc: Tobin C . Harding, Tycho Andersen, kernel-hardening,
	Yoshinori Sato, Rich Felker, linux-sh, linux-kernel

For security, don't display the kernel's virtual memory layout.

Kees Cook points out:
"These have been entirely removed on other architectures, so let's
just do the same for ia32 and remove it unconditionally."

071929dbdd86 ("arm64: Stop printing the virtual memory layout")
1c31d4e96b8c ("ARM: 8820/1: mm: Stop printing the virtual memory layout")
31833332f798 ("m68k/mm: Stop printing the virtual memory layout")
fd8d0ca25631 ("parisc: Hide virtual kernel memory layout")
adb1fe9ae2ee ("mm/page_alloc: Remove kernel address exposure in free_reserved_area()")

Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
---
 arch/sh/mm/init.c | 41 -----------------------------------------
 1 file changed, 41 deletions(-)

diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c
index d1b1ff2be17a..e68a1106e99b 100644
--- a/arch/sh/mm/init.c
+++ b/arch/sh/mm/init.c
@@ -360,47 +360,6 @@ void __init mem_init(void)
 	vsyscall_init();
 
 	mem_init_print_info(NULL);
-	pr_info("virtual kernel memory layout:\n"
-		"    fixmap  : 0x%08lx - 0x%08lx   (%4ld kB)\n"
-#ifdef CONFIG_HIGHMEM
-		"    pkmap   : 0x%08lx - 0x%08lx   (%4ld kB)\n"
-#endif
-		"    vmalloc : 0x%08lx - 0x%08lx   (%4ld MB)\n"
-		"    lowmem  : 0x%08lx - 0x%08lx   (%4ld MB) (cached)\n"
-#ifdef CONFIG_UNCACHED_MAPPING
-		"            : 0x%08lx - 0x%08lx   (%4ld MB) (uncached)\n"
-#endif
-		"      .init : 0x%08lx - 0x%08lx   (%4ld kB)\n"
-		"      .data : 0x%08lx - 0x%08lx   (%4ld kB)\n"
-		"      .text : 0x%08lx - 0x%08lx   (%4ld kB)\n",
-		FIXADDR_START, FIXADDR_TOP,
-		(FIXADDR_TOP - FIXADDR_START) >> 10,
-
-#ifdef CONFIG_HIGHMEM
-		PKMAP_BASE, PKMAP_BASE+LAST_PKMAP*PAGE_SIZE,
-		(LAST_PKMAP*PAGE_SIZE) >> 10,
-#endif
-
-		(unsigned long)VMALLOC_START, VMALLOC_END,
-		(VMALLOC_END - VMALLOC_START) >> 20,
-
-		(unsigned long)memory_start, (unsigned long)high_memory,
-		((unsigned long)high_memory - (unsigned long)memory_start) >> 20,
-
-#ifdef CONFIG_UNCACHED_MAPPING
-		uncached_start, uncached_end, uncached_size >> 20,
-#endif
-
-		(unsigned long)&__init_begin, (unsigned long)&__init_end,
-		((unsigned long)&__init_end -
-		 (unsigned long)&__init_begin) >> 10,
-
-		(unsigned long)&_etext, (unsigned long)&_edata,
-		((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
-
-		(unsigned long)&_text, (unsigned long)&_etext,
-		((unsigned long)&_etext - (unsigned long)&_text) >> 10);
-
 	mem_init_done = 1;
 }
 
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH] xtensa/mm: Stop printing the virtual memory layout
  2020-03-02 18:38     ` Kees Cook
                         ` (3 preceding siblings ...)
  2020-03-05 15:10       ` [PATCH] sh: " Arvind Sankar
@ 2020-03-05 15:11       ` Arvind Sankar
  2020-03-05 20:51         ` Tycho Andersen
  2020-03-06  7:54         ` Max Filippov
  4 siblings, 2 replies; 35+ messages in thread
From: Arvind Sankar @ 2020-03-05 15:11 UTC (permalink / raw)
  To: Kees Cook
  Cc: Tobin C . Harding, Tycho Andersen, kernel-hardening,
	Chris Zankel, Max Filippov, linux-xtensa, linux-kernel

For security, don't display the kernel's virtual memory layout.

Kees Cook points out:
"These have been entirely removed on other architectures, so let's
just do the same for ia32 and remove it unconditionally."

071929dbdd86 ("arm64: Stop printing the virtual memory layout")
1c31d4e96b8c ("ARM: 8820/1: mm: Stop printing the virtual memory layout")
31833332f798 ("m68k/mm: Stop printing the virtual memory layout")
fd8d0ca25631 ("parisc: Hide virtual kernel memory layout")
adb1fe9ae2ee ("mm/page_alloc: Remove kernel address exposure in free_reserved_area()")

Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
---
 arch/xtensa/mm/init.c | 46 -------------------------------------------
 1 file changed, 46 deletions(-)

diff --git a/arch/xtensa/mm/init.c b/arch/xtensa/mm/init.c
index 19c625e6d81f..7ba3f1fce8ec 100644
--- a/arch/xtensa/mm/init.c
+++ b/arch/xtensa/mm/init.c
@@ -155,52 +155,6 @@ void __init mem_init(void)
 	memblock_free_all();
 
 	mem_init_print_info(NULL);
-	pr_info("virtual kernel memory layout:\n"
-#ifdef CONFIG_KASAN
-		"    kasan   : 0x%08lx - 0x%08lx  (%5lu MB)\n"
-#endif
-#ifdef CONFIG_MMU
-		"    vmalloc : 0x%08lx - 0x%08lx  (%5lu MB)\n"
-#endif
-#ifdef CONFIG_HIGHMEM
-		"    pkmap   : 0x%08lx - 0x%08lx  (%5lu kB)\n"
-		"    fixmap  : 0x%08lx - 0x%08lx  (%5lu kB)\n"
-#endif
-		"    lowmem  : 0x%08lx - 0x%08lx  (%5lu MB)\n"
-		"    .text   : 0x%08lx - 0x%08lx  (%5lu kB)\n"
-		"    .rodata : 0x%08lx - 0x%08lx  (%5lu kB)\n"
-		"    .data   : 0x%08lx - 0x%08lx  (%5lu kB)\n"
-		"    .init   : 0x%08lx - 0x%08lx  (%5lu kB)\n"
-		"    .bss    : 0x%08lx - 0x%08lx  (%5lu kB)\n",
-#ifdef CONFIG_KASAN
-		KASAN_SHADOW_START, KASAN_SHADOW_START + KASAN_SHADOW_SIZE,
-		KASAN_SHADOW_SIZE >> 20,
-#endif
-#ifdef CONFIG_MMU
-		VMALLOC_START, VMALLOC_END,
-		(VMALLOC_END - VMALLOC_START) >> 20,
-#ifdef CONFIG_HIGHMEM
-		PKMAP_BASE, PKMAP_BASE + LAST_PKMAP * PAGE_SIZE,
-		(LAST_PKMAP*PAGE_SIZE) >> 10,
-		FIXADDR_START, FIXADDR_TOP,
-		(FIXADDR_TOP - FIXADDR_START) >> 10,
-#endif
-		PAGE_OFFSET, PAGE_OFFSET +
-		(max_low_pfn - min_low_pfn) * PAGE_SIZE,
-#else
-		min_low_pfn * PAGE_SIZE, max_low_pfn * PAGE_SIZE,
-#endif
-		((max_low_pfn - min_low_pfn) * PAGE_SIZE) >> 20,
-		(unsigned long)_text, (unsigned long)_etext,
-		(unsigned long)(_etext - _text) >> 10,
-		(unsigned long)__start_rodata, (unsigned long)__end_rodata,
-		(unsigned long)(__end_rodata - __start_rodata) >> 10,
-		(unsigned long)_sdata, (unsigned long)_edata,
-		(unsigned long)(_edata - _sdata) >> 10,
-		(unsigned long)__init_begin, (unsigned long)__init_end,
-		(unsigned long)(__init_end - __init_begin) >> 10,
-		(unsigned long)__bss_start, (unsigned long)__bss_stop,
-		(unsigned long)(__bss_stop - __bss_start) >> 10);
 }
 
 static void __init parse_memmap_one(char *p)
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 35+ messages in thread

* Re: [PATCH] sh: Stop printing the virtual memory layout
  2020-03-05 15:10       ` [PATCH] sh: " Arvind Sankar
@ 2020-03-05 15:18         ` John Paul Adrian Glaubitz
  2020-03-05 15:38           ` Joe Perches
                             ` (2 more replies)
  0 siblings, 3 replies; 35+ messages in thread
From: John Paul Adrian Glaubitz @ 2020-03-05 15:18 UTC (permalink / raw)
  To: Arvind Sankar, Kees Cook
  Cc: Tobin C . Harding, Tycho Andersen, kernel-hardening,
	Yoshinori Sato, Rich Felker, linux-sh, linux-kernel

On 3/5/20 4:10 PM, Arvind Sankar wrote:
> For security, don't display the kernel's virtual memory layout.
> 
> Kees Cook points out:
> "These have been entirely removed on other architectures, so let's
> just do the same for ia32 and remove it unconditionally."
> 
> 071929dbdd86 ("arm64: Stop printing the virtual memory layout")
> 1c31d4e96b8c ("ARM: 8820/1: mm: Stop printing the virtual memory layout")
> 31833332f798 ("m68k/mm: Stop printing the virtual memory layout")
> fd8d0ca25631 ("parisc: Hide virtual kernel memory layout")
> adb1fe9ae2ee ("mm/page_alloc: Remove kernel address exposure in free_reserved_area()")
Aww, why wasn't this made configurable? I found these memory map printouts
very useful for development.

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaubitz@debian.org
`. `'   Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] sh: Stop printing the virtual memory layout
  2020-03-05 15:18         ` John Paul Adrian Glaubitz
@ 2020-03-05 15:38           ` Joe Perches
  2020-03-05 15:41             ` John Paul Adrian Glaubitz
  2020-03-06  8:04           ` Geert Uytterhoeven
  2020-03-08 12:17           ` Kaiwan N Billimoria
  2 siblings, 1 reply; 35+ messages in thread
From: Joe Perches @ 2020-03-05 15:38 UTC (permalink / raw)
  To: John Paul Adrian Glaubitz, Arvind Sankar, Kees Cook
  Cc: Tobin C . Harding, Tycho Andersen, kernel-hardening,
	Yoshinori Sato, Rich Felker, linux-sh, linux-kernel

On Thu, 2020-03-05 at 16:18 +0100, John Paul Adrian Glaubitz wrote:
> On 3/5/20 4:10 PM, Arvind Sankar wrote:
> > For security, don't display the kernel's virtual memory layout.
> > 
> > Kees Cook points out:
> > "These have been entirely removed on other architectures, so let's
> > just do the same for ia32 and remove it unconditionally."
> > 
> > 071929dbdd86 ("arm64: Stop printing the virtual memory layout")
> > 1c31d4e96b8c ("ARM: 8820/1: mm: Stop printing the virtual memory layout")
> > 31833332f798 ("m68k/mm: Stop printing the virtual memory layout")
> > fd8d0ca25631 ("parisc: Hide virtual kernel memory layout")
> > adb1fe9ae2ee ("mm/page_alloc: Remove kernel address exposure in free_reserved_area()")
> Aww, why wasn't this made configurable? I found these memory map printouts
> very useful for development.

It could be changed from pr_info to pr_devel.

A #define DEBUG would have to be added to emit it.




^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] sh: Stop printing the virtual memory layout
  2020-03-05 15:38           ` Joe Perches
@ 2020-03-05 15:41             ` John Paul Adrian Glaubitz
  2020-03-05 15:46               ` Arvind Sankar
  0 siblings, 1 reply; 35+ messages in thread
From: John Paul Adrian Glaubitz @ 2020-03-05 15:41 UTC (permalink / raw)
  To: Joe Perches, Arvind Sankar, Kees Cook
  Cc: Tobin C . Harding, Tycho Andersen, kernel-hardening,
	Yoshinori Sato, Rich Felker, linux-sh, linux-kernel

On 3/5/20 4:38 PM, Joe Perches wrote:
>> Aww, why wasn't this made configurable? I found these memory map printouts
>> very useful for development.
> 
> It could be changed from pr_info to pr_devel.
> 
> A #define DEBUG would have to be added to emit it.

Well, from the discussion it seems the decision to cut it out has already been
made, so I guess it's too late :(.

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaubitz@debian.org
`. `'   Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] sh: Stop printing the virtual memory layout
  2020-03-05 15:41             ` John Paul Adrian Glaubitz
@ 2020-03-05 15:46               ` Arvind Sankar
  2020-03-05 15:49                 ` John Paul Adrian Glaubitz
  2020-03-05 17:34                 ` Kees Cook
  0 siblings, 2 replies; 35+ messages in thread
From: Arvind Sankar @ 2020-03-05 15:46 UTC (permalink / raw)
  To: John Paul Adrian Glaubitz
  Cc: Joe Perches, Arvind Sankar, Kees Cook, Tobin C . Harding,
	Tycho Andersen, kernel-hardening, Yoshinori Sato, Rich Felker,
	linux-sh, linux-kernel

On Thu, Mar 05, 2020 at 04:41:05PM +0100, John Paul Adrian Glaubitz wrote:
> On 3/5/20 4:38 PM, Joe Perches wrote:
> >> Aww, why wasn't this made configurable? I found these memory map printouts
> >> very useful for development.
> > 
> > It could be changed from pr_info to pr_devel.
> > 
> > A #define DEBUG would have to be added to emit it.
> 
> Well, from the discussion it seems the decision to cut it out has already been
> made, so I guess it's too late :(.
> 
> Adrian
> 
> -- 
>  .''`.  John Paul Adrian Glaubitz
> : :' :  Debian Developer - glaubitz@debian.org
> `. `'   Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
>   `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

Not really too late. I can do s/pr_info/pr_devel and resubmit.

parisc for eg actually hides this in #if 0 rather than deleting the
code.

Kees, you fine with that?

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] sh: Stop printing the virtual memory layout
  2020-03-05 15:46               ` Arvind Sankar
@ 2020-03-05 15:49                 ` John Paul Adrian Glaubitz
  2020-03-05 15:56                   ` Arvind Sankar
  2020-03-05 17:34                 ` Kees Cook
  1 sibling, 1 reply; 35+ messages in thread
From: John Paul Adrian Glaubitz @ 2020-03-05 15:49 UTC (permalink / raw)
  To: Arvind Sankar
  Cc: Joe Perches, Kees Cook, Tobin C . Harding, Tycho Andersen,
	kernel-hardening, Yoshinori Sato, Rich Felker, linux-sh,
	linux-kernel

On 3/5/20 4:46 PM, Arvind Sankar wrote:
> Not really too late. I can do s/pr_info/pr_devel and resubmit.
> 
> parisc for eg actually hides this in #if 0 rather than deleting the
> code.
> 
> Kees, you fine with that?

But wasn't it removed for all the other architectures already? Or are these
changes not in Linus' tree yet?

Adrian

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - glaubitz@debian.org
`. `'   Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] sh: Stop printing the virtual memory layout
  2020-03-05 15:49                 ` John Paul Adrian Glaubitz
@ 2020-03-05 15:56                   ` Arvind Sankar
  2020-03-05 20:51                     ` Tycho Andersen
  0 siblings, 1 reply; 35+ messages in thread
From: Arvind Sankar @ 2020-03-05 15:56 UTC (permalink / raw)
  To: John Paul Adrian Glaubitz
  Cc: Arvind Sankar, Joe Perches, Kees Cook, Tobin C . Harding,
	Tycho Andersen, kernel-hardening, Yoshinori Sato, Rich Felker,
	linux-sh, linux-kernel

On Thu, Mar 05, 2020 at 04:49:22PM +0100, John Paul Adrian Glaubitz wrote:
> On 3/5/20 4:46 PM, Arvind Sankar wrote:
> > Not really too late. I can do s/pr_info/pr_devel and resubmit.
> > 
> > parisc for eg actually hides this in #if 0 rather than deleting the
> > code.
> > 
> > Kees, you fine with that?
> 
> But wasn't it removed for all the other architectures already? Or are these
> changes not in Linus' tree yet?
> 
> Adrian

The ones mentioned in the commit message, yes, those are long gone. But
I don't see any reason why the remaining ones (there are 6 left that I
submitted patches just now for) couldn't switch to pr_devel instead.

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH v3] x86/mm/init_32: Stop printing the virtual memory layout
  2020-03-05 15:01       ` [PATCH v3] " Arvind Sankar
@ 2020-03-05 17:28         ` Kees Cook
  2020-03-05 20:49         ` Tycho Andersen
  2020-03-05 23:00         ` [tip: x86/mm] x86/mm/init/32: " tip-bot2 for Arvind Sankar
  2 siblings, 0 replies; 35+ messages in thread
From: Kees Cook @ 2020-03-05 17:28 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Tobin C . Harding, Tycho Andersen, Arvind Sankar,
	kernel-hardening, Dave Hansen, Andy Lutomirski, Peter Zijlstra,
	x86, linux-kernel

On Thu, Mar 05, 2020 at 10:01:52AM -0500, Arvind Sankar wrote:
> For security, don't display the kernel's virtual memory layout.
> 
> Kees Cook points out:
> "These have been entirely removed on other architectures, so let's
> just do the same for ia32 and remove it unconditionally."
> 
> 071929dbdd86 ("arm64: Stop printing the virtual memory layout")
> 1c31d4e96b8c ("ARM: 8820/1: mm: Stop printing the virtual memory layout")
> 31833332f798 ("m68k/mm: Stop printing the virtual memory layout")
> fd8d0ca25631 ("parisc: Hide virtual kernel memory layout")
> adb1fe9ae2ee ("mm/page_alloc: Remove kernel address exposure in free_reserved_area()")
> 
> Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>

Thanks!

(*randomly choosing an x86 maintainer to aim this patch at; hi Thomas!*)

Acked-by: Kees Cook <keescook@chromium.org>

-Kees

> ---
>  arch/x86/mm/init_32.c | 38 --------------------------------------
>  1 file changed, 38 deletions(-)
> 
> diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
> index 23df4885bbed..8ae0272c1c51 100644
> --- a/arch/x86/mm/init_32.c
> +++ b/arch/x86/mm/init_32.c
> @@ -788,44 +788,6 @@ void __init mem_init(void)
>  	x86_init.hyper.init_after_bootmem();
>  
>  	mem_init_print_info(NULL);
> -	printk(KERN_INFO "virtual kernel memory layout:\n"
> -		"    fixmap  : 0x%08lx - 0x%08lx   (%4ld kB)\n"
> -		"  cpu_entry : 0x%08lx - 0x%08lx   (%4ld kB)\n"
> -#ifdef CONFIG_HIGHMEM
> -		"    pkmap   : 0x%08lx - 0x%08lx   (%4ld kB)\n"
> -#endif
> -		"    vmalloc : 0x%08lx - 0x%08lx   (%4ld MB)\n"
> -		"    lowmem  : 0x%08lx - 0x%08lx   (%4ld MB)\n"
> -		"      .init : 0x%08lx - 0x%08lx   (%4ld kB)\n"
> -		"      .data : 0x%08lx - 0x%08lx   (%4ld kB)\n"
> -		"      .text : 0x%08lx - 0x%08lx   (%4ld kB)\n",
> -		FIXADDR_START, FIXADDR_TOP,
> -		(FIXADDR_TOP - FIXADDR_START) >> 10,
> -
> -		CPU_ENTRY_AREA_BASE,
> -		CPU_ENTRY_AREA_BASE + CPU_ENTRY_AREA_MAP_SIZE,
> -		CPU_ENTRY_AREA_MAP_SIZE >> 10,
> -
> -#ifdef CONFIG_HIGHMEM
> -		PKMAP_BASE, PKMAP_BASE+LAST_PKMAP*PAGE_SIZE,
> -		(LAST_PKMAP*PAGE_SIZE) >> 10,
> -#endif
> -
> -		VMALLOC_START, VMALLOC_END,
> -		(VMALLOC_END - VMALLOC_START) >> 20,
> -
> -		(unsigned long)__va(0), (unsigned long)high_memory,
> -		((unsigned long)high_memory - (unsigned long)__va(0)) >> 20,
> -
> -		(unsigned long)&__init_begin, (unsigned long)&__init_end,
> -		((unsigned long)&__init_end -
> -		 (unsigned long)&__init_begin) >> 10,
> -
> -		(unsigned long)&_etext, (unsigned long)&_edata,
> -		((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
> -
> -		(unsigned long)&_text, (unsigned long)&_etext,
> -		((unsigned long)&_etext - (unsigned long)&_text) >> 10);
>  
>  	/*
>  	 * Check boundaries twice: Some fundamental inconsistencies can
> -- 
> 2.24.1
> 

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] sh: Stop printing the virtual memory layout
  2020-03-05 15:46               ` Arvind Sankar
  2020-03-05 15:49                 ` John Paul Adrian Glaubitz
@ 2020-03-05 17:34                 ` Kees Cook
  1 sibling, 0 replies; 35+ messages in thread
From: Kees Cook @ 2020-03-05 17:34 UTC (permalink / raw)
  To: Arvind Sankar
  Cc: John Paul Adrian Glaubitz, Joe Perches, Tobin C . Harding,
	Tycho Andersen, kernel-hardening, Yoshinori Sato, Rich Felker,
	linux-sh, linux-kernel

On Thu, Mar 05, 2020 at 10:46:58AM -0500, Arvind Sankar wrote:
> On Thu, Mar 05, 2020 at 04:41:05PM +0100, John Paul Adrian Glaubitz wrote:
> > On 3/5/20 4:38 PM, Joe Perches wrote:
> > >> Aww, why wasn't this made configurable? I found these memory map printouts
> > >> very useful for development.
> > > 
> > > It could be changed from pr_info to pr_devel.
> > > 
> > > A #define DEBUG would have to be added to emit it.
> > 
> > Well, from the discussion it seems the decision to cut it out has already been
> > made, so I guess it's too late :(.
> > 
> > Adrian
> > 
> > -- 
> >  .''`.  John Paul Adrian Glaubitz
> > : :' :  Debian Developer - glaubitz@debian.org
> > `. `'   Freie Universitaet Berlin - glaubitz@physik.fu-berlin.de
> >   `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
> 
> Not really too late. I can do s/pr_info/pr_devel and resubmit.
> 
> parisc for eg actually hides this in #if 0 rather than deleting the
> code.
> 
> Kees, you fine with that?

I don't mind pr_devel(). ("#if 0" tends to lead to code-rot since it's
not subjected to syntax checking in case the names of things change.)
That said, it's really up to the arch maintainers.

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH v3] x86/mm/init_32: Stop printing the virtual memory layout
  2020-03-05 15:01       ` [PATCH v3] " Arvind Sankar
  2020-03-05 17:28         ` Kees Cook
@ 2020-03-05 20:49         ` Tycho Andersen
  2020-03-05 23:00         ` [tip: x86/mm] x86/mm/init/32: " tip-bot2 for Arvind Sankar
  2 siblings, 0 replies; 35+ messages in thread
From: Tycho Andersen @ 2020-03-05 20:49 UTC (permalink / raw)
  To: Arvind Sankar
  Cc: Kees Cook, Tobin C . Harding, kernel-hardening, Dave Hansen,
	Andy Lutomirski, Peter Zijlstra, x86, linux-kernel

On Thu, Mar 05, 2020 at 10:01:52AM -0500, Arvind Sankar wrote:
> For security, don't display the kernel's virtual memory layout.
> 
> Kees Cook points out:
> "These have been entirely removed on other architectures, so let's
> just do the same for ia32 and remove it unconditionally."
> 
> 071929dbdd86 ("arm64: Stop printing the virtual memory layout")
> 1c31d4e96b8c ("ARM: 8820/1: mm: Stop printing the virtual memory layout")
> 31833332f798 ("m68k/mm: Stop printing the virtual memory layout")
> fd8d0ca25631 ("parisc: Hide virtual kernel memory layout")
> adb1fe9ae2ee ("mm/page_alloc: Remove kernel address exposure in free_reserved_area()")
> 
> Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>

Acked-by: Tycho Andersen <tycho@tycho.ws>

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] microblaze: Stop printing the virtual memory layout
  2020-03-05 15:05       ` [PATCH] microblaze: Stop printing the virtual memory layout Arvind Sankar
@ 2020-03-05 20:50         ` Tycho Andersen
  2020-03-09 10:09         ` Michal Simek
  1 sibling, 0 replies; 35+ messages in thread
From: Tycho Andersen @ 2020-03-05 20:50 UTC (permalink / raw)
  To: Arvind Sankar
  Cc: Kees Cook, Tobin C . Harding, kernel-hardening, Michal Simek,
	linux-kernel

On Thu, Mar 05, 2020 at 10:05:03AM -0500, Arvind Sankar wrote:
> For security, don't display the kernel's virtual memory layout.
> 
> Kees Cook points out:
> "These have been entirely removed on other architectures, so let's
> just do the same for ia32 and remove it unconditionally."
> 
> 071929dbdd86 ("arm64: Stop printing the virtual memory layout")
> 1c31d4e96b8c ("ARM: 8820/1: mm: Stop printing the virtual memory layout")
> 31833332f798 ("m68k/mm: Stop printing the virtual memory layout")
> fd8d0ca25631 ("parisc: Hide virtual kernel memory layout")
> adb1fe9ae2ee ("mm/page_alloc: Remove kernel address exposure in free_reserved_area()")
> 
> Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>

Acked-by: Tycho Andersen <tycho@tycho.ws>

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] nds32/mm: Stop printing the virtual memory layout
  2020-03-05 15:06       ` [PATCH] nds32/mm: " Arvind Sankar
@ 2020-03-05 20:50         ` Tycho Andersen
  0 siblings, 0 replies; 35+ messages in thread
From: Tycho Andersen @ 2020-03-05 20:50 UTC (permalink / raw)
  To: Arvind Sankar
  Cc: Kees Cook, Tobin C . Harding, kernel-hardening, Nick Hu,
	Greentime Hu, Vincent Chen, linux-kernel

On Thu, Mar 05, 2020 at 10:06:39AM -0500, Arvind Sankar wrote:
> For security, don't display the kernel's virtual memory layout.
> 
> Kees Cook points out:
> "These have been entirely removed on other architectures, so let's
> just do the same for ia32 and remove it unconditionally."
> 
> 071929dbdd86 ("arm64: Stop printing the virtual memory layout")
> 1c31d4e96b8c ("ARM: 8820/1: mm: Stop printing the virtual memory layout")
> 31833332f798 ("m68k/mm: Stop printing the virtual memory layout")
> fd8d0ca25631 ("parisc: Hide virtual kernel memory layout")
> adb1fe9ae2ee ("mm/page_alloc: Remove kernel address exposure in free_reserved_area()")
> 
> Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>

Acked-by: Tycho Andersen <tycho@tycho.ws>

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] powerpc/32: Stop printing the virtual memory layout
  2020-03-05 15:08       ` [PATCH] powerpc/32: " Arvind Sankar
@ 2020-03-05 20:50         ` Tycho Andersen
  2022-03-09 19:35         ` Christophe Leroy
  1 sibling, 0 replies; 35+ messages in thread
From: Tycho Andersen @ 2020-03-05 20:50 UTC (permalink / raw)
  To: Arvind Sankar
  Cc: Kees Cook, Tobin C . Harding, kernel-hardening,
	Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
	linuxppc-dev, linux-kernel

On Thu, Mar 05, 2020 at 10:08:37AM -0500, Arvind Sankar wrote:
> For security, don't display the kernel's virtual memory layout.
> 
> Kees Cook points out:
> "These have been entirely removed on other architectures, so let's
> just do the same for ia32 and remove it unconditionally."
> 
> 071929dbdd86 ("arm64: Stop printing the virtual memory layout")
> 1c31d4e96b8c ("ARM: 8820/1: mm: Stop printing the virtual memory layout")
> 31833332f798 ("m68k/mm: Stop printing the virtual memory layout")
> fd8d0ca25631 ("parisc: Hide virtual kernel memory layout")
> adb1fe9ae2ee ("mm/page_alloc: Remove kernel address exposure in free_reserved_area()")
> 
> Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>

Acked-by: Tycho Andersen <tycho@tycho.ws>

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] xtensa/mm: Stop printing the virtual memory layout
  2020-03-05 15:11       ` [PATCH] xtensa/mm: " Arvind Sankar
@ 2020-03-05 20:51         ` Tycho Andersen
  2020-03-06  7:54         ` Max Filippov
  1 sibling, 0 replies; 35+ messages in thread
From: Tycho Andersen @ 2020-03-05 20:51 UTC (permalink / raw)
  To: Arvind Sankar
  Cc: Kees Cook, Tobin C . Harding, kernel-hardening, Chris Zankel,
	Max Filippov, linux-xtensa, linux-kernel

On Thu, Mar 05, 2020 at 10:11:44AM -0500, Arvind Sankar wrote:
> For security, don't display the kernel's virtual memory layout.
> 
> Kees Cook points out:
> "These have been entirely removed on other architectures, so let's
> just do the same for ia32 and remove it unconditionally."
> 
> 071929dbdd86 ("arm64: Stop printing the virtual memory layout")
> 1c31d4e96b8c ("ARM: 8820/1: mm: Stop printing the virtual memory layout")
> 31833332f798 ("m68k/mm: Stop printing the virtual memory layout")
> fd8d0ca25631 ("parisc: Hide virtual kernel memory layout")
> adb1fe9ae2ee ("mm/page_alloc: Remove kernel address exposure in free_reserved_area()")
> 
> Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>

Acked-by: Tycho Andersen <tycho@tycho.ws>

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] sh: Stop printing the virtual memory layout
  2020-03-05 15:56                   ` Arvind Sankar
@ 2020-03-05 20:51                     ` Tycho Andersen
  2020-03-05 20:56                       ` John Paul Adrian Glaubitz
  2020-03-05 21:17                       ` Kees Cook
  0 siblings, 2 replies; 35+ messages in thread
From: Tycho Andersen @ 2020-03-05 20:51 UTC (permalink / raw)
  To: Arvind Sankar
  Cc: John Paul Adrian Glaubitz, Joe Perches, Kees Cook,
	Tobin C . Harding, kernel-hardening, Yoshinori Sato, Rich Felker,
	linux-sh, linux-kernel

On Thu, Mar 05, 2020 at 10:56:29AM -0500, Arvind Sankar wrote:
> On Thu, Mar 05, 2020 at 04:49:22PM +0100, John Paul Adrian Glaubitz wrote:
> > On 3/5/20 4:46 PM, Arvind Sankar wrote:
> > > Not really too late. I can do s/pr_info/pr_devel and resubmit.
> > > 
> > > parisc for eg actually hides this in #if 0 rather than deleting the
> > > code.
> > > 
> > > Kees, you fine with that?
> > 
> > But wasn't it removed for all the other architectures already? Or are these
> > changes not in Linus' tree yet?
> > 
> > Adrian
> 
> The ones mentioned in the commit message, yes, those are long gone. But
> I don't see any reason why the remaining ones (there are 6 left that I
> submitted patches just now for) couldn't switch to pr_devel instead.

If you do happen to re-send with pr_debug() instead, feel free to add
my ack to that series as well. But in any case, this one is also:

Acked-by: Tycho Andersen <tycho@tycho.ws>

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] sh: Stop printing the virtual memory layout
  2020-03-05 20:51                     ` Tycho Andersen
@ 2020-03-05 20:56                       ` John Paul Adrian Glaubitz
  2020-03-05 21:17                       ` Kees Cook
  1 sibling, 0 replies; 35+ messages in thread
From: John Paul Adrian Glaubitz @ 2020-03-05 20:56 UTC (permalink / raw)
  To: Tycho Andersen
  Cc: Arvind Sankar, Joe Perches, Kees Cook, Tobin C . Harding,
	kernel-hardening, Yoshinori Sato, Rich Felker, linux-sh,
	linux-kernel



> On Mar 5, 2020, at 9:52 PM, Tycho Andersen <tycho@tycho.ws> wrote:
> 
> On Thu, Mar 05, 2020 at 10:56:29AM -0500, Arvind Sankar wrote:
>>> On Thu, Mar 05, 2020 at 04:49:22PM +0100, John Paul Adrian Glaubitz wrote:
>>> On 3/5/20 4:46 PM, Arvind Sankar wrote:
>>>> Not really too late. I can do s/pr_info/pr_devel and resubmit.
>>>> 
>>>> parisc for eg actually hides this in #if 0 rather than deleting the
>>>> code.
>>>> 
>>>> Kees, you fine with that?
>>> 
>>> But wasn't it removed for all the other architectures already? Or are these
>>> changes not in Linus' tree yet?
>>> 
>>> Adrian
>> 
>> The ones mentioned in the commit message, yes, those are long gone. But
>> I don't see any reason why the remaining ones (there are 6 left that I
>> submitted patches just now for) couldn't switch to pr_devel instead.
> 
> If you do happen to re-send with pr_debug() instead, feel free to add
> my ack to that series as well.

Since it already got removed for most other architectures, I don’t think it makes much sense to keep it for consistency.

I just didn’t understand why it was made configurable for debugging purposes in the first place.

Also, many distributions disable access to the kernel buffer for unprivileged users anyway.

Adrian

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] sh: Stop printing the virtual memory layout
  2020-03-05 20:51                     ` Tycho Andersen
  2020-03-05 20:56                       ` John Paul Adrian Glaubitz
@ 2020-03-05 21:17                       ` Kees Cook
  1 sibling, 0 replies; 35+ messages in thread
From: Kees Cook @ 2020-03-05 21:17 UTC (permalink / raw)
  To: Tycho Andersen
  Cc: Arvind Sankar, John Paul Adrian Glaubitz, Joe Perches,
	Tobin C . Harding, kernel-hardening, Yoshinori Sato, Rich Felker,
	linux-sh, linux-kernel

On Thu, Mar 05, 2020 at 01:51:58PM -0700, Tycho Andersen wrote:
> On Thu, Mar 05, 2020 at 10:56:29AM -0500, Arvind Sankar wrote:
> > On Thu, Mar 05, 2020 at 04:49:22PM +0100, John Paul Adrian Glaubitz wrote:
> > > On 3/5/20 4:46 PM, Arvind Sankar wrote:
> > > > Not really too late. I can do s/pr_info/pr_devel and resubmit.
> > > > 
> > > > parisc for eg actually hides this in #if 0 rather than deleting the
> > > > code.
> > > > 
> > > > Kees, you fine with that?
> > > 
> > > But wasn't it removed for all the other architectures already? Or are these
> > > changes not in Linus' tree yet?
> > > 
> > > Adrian
> > 
> > The ones mentioned in the commit message, yes, those are long gone. But
> > I don't see any reason why the remaining ones (there are 6 left that I
> > submitted patches just now for) couldn't switch to pr_devel instead.
> 
> If you do happen to re-send with pr_debug() instead, feel free to add

(FYI, pr_devel() was suggested, not pr_debug() -- the former is
compile-time enabled with DEBUG and the latter can be enabled dynamically
in some cases in the kernel, so pr_debug() should not be used.)

> my ack to that series as well. But in any case, this one is also:
> 
> Acked-by: Tycho Andersen <tycho@tycho.ws>

Same for me. :) Consider the series:

Acked-by: Kees Cook <keescook@chromium.org>

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 35+ messages in thread

* [tip: x86/mm] x86/mm/init/32: Stop printing the virtual memory layout
  2020-03-05 15:01       ` [PATCH v3] " Arvind Sankar
  2020-03-05 17:28         ` Kees Cook
  2020-03-05 20:49         ` Tycho Andersen
@ 2020-03-05 23:00         ` tip-bot2 for Arvind Sankar
  2 siblings, 0 replies; 35+ messages in thread
From: tip-bot2 for Arvind Sankar @ 2020-03-05 23:00 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Arvind Sankar, Thomas Gleixner, Tycho Andersen, Kees Cook, x86, LKML

The following commit has been merged into the x86/mm branch of tip:

Commit-ID:     681ff0181bbfb183e32bc6beb6ec076304470479
Gitweb:        https://git.kernel.org/tip/681ff0181bbfb183e32bc6beb6ec076304470479
Author:        Arvind Sankar <nivedita@alum.mit.edu>
AuthorDate:    Thu, 05 Mar 2020 10:01:52 -05:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Thu, 05 Mar 2020 23:53:55 +01:00

x86/mm/init/32: Stop printing the virtual memory layout

For security reasons, don't display the kernel's virtual memory layout.

Kees Cook points out:
"These have been entirely removed on other architectures, so let's
just do the same for ia32 and remove it unconditionally."

071929dbdd86 ("arm64: Stop printing the virtual memory layout")
1c31d4e96b8c ("ARM: 8820/1: mm: Stop printing the virtual memory layout")
31833332f798 ("m68k/mm: Stop printing the virtual memory layout")
fd8d0ca25631 ("parisc: Hide virtual kernel memory layout")
adb1fe9ae2ee ("mm/page_alloc: Remove kernel address exposure in free_reserved_area()")

Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Tycho Andersen <tycho@tycho.ws>
Acked-by: Kees Cook <keescook@chromium.org>
Link: https://lkml.kernel.org/r/20200305150152.831697-1-nivedita@alum.mit.edu

---
 arch/x86/mm/init_32.c | 38 --------------------------------------
 1 file changed, 38 deletions(-)

diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index 23df488..8ae0272 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -788,44 +788,6 @@ void __init mem_init(void)
 	x86_init.hyper.init_after_bootmem();
 
 	mem_init_print_info(NULL);
-	printk(KERN_INFO "virtual kernel memory layout:\n"
-		"    fixmap  : 0x%08lx - 0x%08lx   (%4ld kB)\n"
-		"  cpu_entry : 0x%08lx - 0x%08lx   (%4ld kB)\n"
-#ifdef CONFIG_HIGHMEM
-		"    pkmap   : 0x%08lx - 0x%08lx   (%4ld kB)\n"
-#endif
-		"    vmalloc : 0x%08lx - 0x%08lx   (%4ld MB)\n"
-		"    lowmem  : 0x%08lx - 0x%08lx   (%4ld MB)\n"
-		"      .init : 0x%08lx - 0x%08lx   (%4ld kB)\n"
-		"      .data : 0x%08lx - 0x%08lx   (%4ld kB)\n"
-		"      .text : 0x%08lx - 0x%08lx   (%4ld kB)\n",
-		FIXADDR_START, FIXADDR_TOP,
-		(FIXADDR_TOP - FIXADDR_START) >> 10,
-
-		CPU_ENTRY_AREA_BASE,
-		CPU_ENTRY_AREA_BASE + CPU_ENTRY_AREA_MAP_SIZE,
-		CPU_ENTRY_AREA_MAP_SIZE >> 10,
-
-#ifdef CONFIG_HIGHMEM
-		PKMAP_BASE, PKMAP_BASE+LAST_PKMAP*PAGE_SIZE,
-		(LAST_PKMAP*PAGE_SIZE) >> 10,
-#endif
-
-		VMALLOC_START, VMALLOC_END,
-		(VMALLOC_END - VMALLOC_START) >> 20,
-
-		(unsigned long)__va(0), (unsigned long)high_memory,
-		((unsigned long)high_memory - (unsigned long)__va(0)) >> 20,
-
-		(unsigned long)&__init_begin, (unsigned long)&__init_end,
-		((unsigned long)&__init_end -
-		 (unsigned long)&__init_begin) >> 10,
-
-		(unsigned long)&_etext, (unsigned long)&_edata,
-		((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
-
-		(unsigned long)&_text, (unsigned long)&_etext,
-		((unsigned long)&_etext - (unsigned long)&_text) >> 10);
 
 	/*
 	 * Check boundaries twice: Some fundamental inconsistencies can

^ permalink raw reply related	[flat|nested] 35+ messages in thread

* Re: [PATCH] xtensa/mm: Stop printing the virtual memory layout
  2020-03-05 15:11       ` [PATCH] xtensa/mm: " Arvind Sankar
  2020-03-05 20:51         ` Tycho Andersen
@ 2020-03-06  7:54         ` Max Filippov
  1 sibling, 0 replies; 35+ messages in thread
From: Max Filippov @ 2020-03-06  7:54 UTC (permalink / raw)
  To: Arvind Sankar
  Cc: Kees Cook, Tobin C . Harding, Tycho Andersen, kernel-hardening,
	Chris Zankel, open list:TENSILICA XTENSA PORT (xtensa),
	LKML

On Thu, Mar 5, 2020 at 7:11 AM Arvind Sankar <nivedita@alum.mit.edu> wrote:
>
> For security, don't display the kernel's virtual memory layout.

Given that primary users of xtensa linux kernels are developers
removing this information, and even disabling it by default doesn't
sound reasonable to me.

-- 
Thanks.
-- Max

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] sh: Stop printing the virtual memory layout
  2020-03-05 15:18         ` John Paul Adrian Glaubitz
  2020-03-05 15:38           ` Joe Perches
@ 2020-03-06  8:04           ` Geert Uytterhoeven
  2020-03-08 12:17           ` Kaiwan N Billimoria
  2 siblings, 0 replies; 35+ messages in thread
From: Geert Uytterhoeven @ 2020-03-06  8:04 UTC (permalink / raw)
  To: John Paul Adrian Glaubitz
  Cc: Arvind Sankar, Kees Cook, Tobin C . Harding, Tycho Andersen,
	kernel-hardening, Yoshinori Sato, Rich Felker, Linux-sh list,
	Linux Kernel Mailing List

Hi Adrian,

On Thu, Mar 5, 2020 at 4:18 PM John Paul Adrian Glaubitz
<glaubitz@physik.fu-berlin.de> wrote:
> On 3/5/20 4:10 PM, Arvind Sankar wrote:
> > For security, don't display the kernel's virtual memory layout.
> >
> > Kees Cook points out:
> > "These have been entirely removed on other architectures, so let's
> > just do the same for ia32 and remove it unconditionally."
> >
> > 071929dbdd86 ("arm64: Stop printing the virtual memory layout")
> > 1c31d4e96b8c ("ARM: 8820/1: mm: Stop printing the virtual memory layout")
> > 31833332f798 ("m68k/mm: Stop printing the virtual memory layout")
> > fd8d0ca25631 ("parisc: Hide virtual kernel memory layout")
> > adb1fe9ae2ee ("mm/page_alloc: Remove kernel address exposure in free_reserved_area()")
> Aww, why wasn't this made configurable? I found these memory map printouts
> very useful for development.

In most of the above (but not in this patch), "%p" was used to print
addresses, which started showing useless hashed addresses since commit
ad67b74d2469d9b8 ("printk: hash addresses printed with %p").

Instead of changing them all to print usable addresses instead, it was
agreed upon to just remove them.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] sh: Stop printing the virtual memory layout
  2020-03-05 15:18         ` John Paul Adrian Glaubitz
  2020-03-05 15:38           ` Joe Perches
  2020-03-06  8:04           ` Geert Uytterhoeven
@ 2020-03-08 12:17           ` Kaiwan N Billimoria
  2 siblings, 0 replies; 35+ messages in thread
From: Kaiwan N Billimoria @ 2020-03-08 12:17 UTC (permalink / raw)
  To: John Paul Adrian Glaubitz
  Cc: Arvind Sankar, Kees Cook, Tobin C . Harding, Tycho Andersen,
	Kernel Hardening, Yoshinori Sato, Rich Felker, linux-sh,
	Linux Kernel Mailing List

On Thu, Mar 5, 2020 at 8:48 PM John Paul Adrian Glaubitz
<glaubitz@physik.fu-berlin.de> wrote:
>
> On 3/5/20 4:10 PM, Arvind Sankar wrote:
> > For security, don't display the kernel's virtual memory layout.
> >
> > Kees Cook points out:
> > "These have been entirely removed on other architectures, so let's
> > just do the same for ia32 and remove it unconditionally."
> >
> > 071929dbdd86 ("arm64: Stop printing the virtual memory layout")
> > 1c31d4e96b8c ("ARM: 8820/1: mm: Stop printing the virtual memory layout")
> > 31833332f798 ("m68k/mm: Stop printing the virtual memory layout")
> > fd8d0ca25631 ("parisc: Hide virtual kernel memory layout")
> > adb1fe9ae2ee ("mm/page_alloc: Remove kernel address exposure in free_reserved_area()")
> Aww, why wasn't this made configurable? I found these memory map printouts
> very useful for development.

Same here! IMO, the kernel segment layout is useful for devs/debug purposes.
Perhaps:
a) all these printk's could be gathered into one function and invoked
only when DEBUG (or equivalent) is defined?
b) else, the s/pr_info/pr_devel approach with %pK should be good?
-Kaiwan.

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] microblaze: Stop printing the virtual memory layout
  2020-03-05 15:05       ` [PATCH] microblaze: Stop printing the virtual memory layout Arvind Sankar
  2020-03-05 20:50         ` Tycho Andersen
@ 2020-03-09 10:09         ` Michal Simek
  1 sibling, 0 replies; 35+ messages in thread
From: Michal Simek @ 2020-03-09 10:09 UTC (permalink / raw)
  To: Arvind Sankar, Kees Cook
  Cc: Tobin C . Harding, Tycho Andersen, kernel-hardening, linux-kernel


[-- Attachment #1.1: Type: text/plain, Size: 1928 bytes --]

On 05. 03. 20 16:05, Arvind Sankar wrote:
> For security, don't display the kernel's virtual memory layout.
> 
> Kees Cook points out:
> "These have been entirely removed on other architectures, so let's
> just do the same for ia32 and remove it unconditionally."
> 
> 071929dbdd86 ("arm64: Stop printing the virtual memory layout")
> 1c31d4e96b8c ("ARM: 8820/1: mm: Stop printing the virtual memory layout")
> 31833332f798 ("m68k/mm: Stop printing the virtual memory layout")
> fd8d0ca25631 ("parisc: Hide virtual kernel memory layout")
> adb1fe9ae2ee ("mm/page_alloc: Remove kernel address exposure in free_reserved_area()")
> 
> Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>
> ---
>  arch/microblaze/mm/init.c | 12 ------------
>  1 file changed, 12 deletions(-)
> 
> diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c
> index 1056f1674065..8323651bf7ec 100644
> --- a/arch/microblaze/mm/init.c
> +++ b/arch/microblaze/mm/init.c
> @@ -201,18 +201,6 @@ void __init mem_init(void)
>  #endif
>  
>  	mem_init_print_info(NULL);
> -#ifdef CONFIG_MMU
> -	pr_info("Kernel virtual memory layout:\n");
> -	pr_info("  * 0x%08lx..0x%08lx  : fixmap\n", FIXADDR_START, FIXADDR_TOP);
> -#ifdef CONFIG_HIGHMEM
> -	pr_info("  * 0x%08lx..0x%08lx  : highmem PTEs\n",
> -		PKMAP_BASE, PKMAP_ADDR(LAST_PKMAP));
> -#endif /* CONFIG_HIGHMEM */
> -	pr_info("  * 0x%08lx..0x%08lx  : early ioremap\n",
> -		ioremap_bot, ioremap_base);
> -	pr_info("  * 0x%08lx..0x%08lx  : vmalloc & ioremap\n",
> -		(unsigned long)VMALLOC_START, VMALLOC_END);
> -#endif
>  	mem_init_done = 1;
>  }
>  
> 

Applied.
M

-- 
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH] powerpc/32: Stop printing the virtual memory layout
  2020-03-05 15:08       ` [PATCH] powerpc/32: " Arvind Sankar
  2020-03-05 20:50         ` Tycho Andersen
@ 2022-03-09 19:35         ` Christophe Leroy
  1 sibling, 0 replies; 35+ messages in thread
From: Christophe Leroy @ 2022-03-09 19:35 UTC (permalink / raw)
  To: Arvind Sankar, Kees Cook
  Cc: Tycho Andersen, kernel-hardening, linux-kernel, Paul Mackerras,
	linuxppc-dev, Tobin C . Harding



Le 05/03/2020 à 16:08, Arvind Sankar a écrit :
> For security, don't display the kernel's virtual memory layout.
> 
> Kees Cook points out:
> "These have been entirely removed on other architectures, so let's
> just do the same for ia32 and remove it unconditionally."
> 
> 071929dbdd86 ("arm64: Stop printing the virtual memory layout")
> 1c31d4e96b8c ("ARM: 8820/1: mm: Stop printing the virtual memory layout")
> 31833332f798 ("m68k/mm: Stop printing the virtual memory layout")
> fd8d0ca25631 ("parisc: Hide virtual kernel memory layout")
> adb1fe9ae2ee ("mm/page_alloc: Remove kernel address exposure in free_reserved_area()")
> 
> Signed-off-by: Arvind Sankar <nivedita@alum.mit.edu>

This patch doesn't apply anymore.

This patch is referenced in https://github.com/linuxppc/issues/issues/390

> ---
>   arch/powerpc/mm/mem.c | 17 -----------------
>   1 file changed, 17 deletions(-)
> 
> diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
> index ef7b1119b2e2..df2c143b6bf7 100644
> --- a/arch/powerpc/mm/mem.c
> +++ b/arch/powerpc/mm/mem.c
> @@ -331,23 +331,6 @@ void __init mem_init(void)
>   #endif
>   
>   	mem_init_print_info(NULL);
> -#ifdef CONFIG_PPC32
> -	pr_info("Kernel virtual memory layout:\n");
> -#ifdef CONFIG_KASAN
> -	pr_info("  * 0x%08lx..0x%08lx  : kasan shadow mem\n",
> -		KASAN_SHADOW_START, KASAN_SHADOW_END);
> -#endif
> -	pr_info("  * 0x%08lx..0x%08lx  : fixmap\n", FIXADDR_START, FIXADDR_TOP);
> -#ifdef CONFIG_HIGHMEM
> -	pr_info("  * 0x%08lx..0x%08lx  : highmem PTEs\n",
> -		PKMAP_BASE, PKMAP_ADDR(LAST_PKMAP));
> -#endif /* CONFIG_HIGHMEM */
> -	if (ioremap_bot != IOREMAP_TOP)
> -		pr_info("  * 0x%08lx..0x%08lx  : early ioremap\n",
> -			ioremap_bot, IOREMAP_TOP);
> -	pr_info("  * 0x%08lx..0x%08lx  : vmalloc & ioremap\n",
> -		VMALLOC_START, VMALLOC_END);
> -#endif /* CONFIG_PPC32 */
>   }
>   
>   void free_initmem(void)

^ permalink raw reply	[flat|nested] 35+ messages in thread

end of thread, other threads:[~2022-03-09 19:35 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-26 21:50 [PATCH] x86/mm/init_32: Don't print out kernel memory layout if KASLR Arvind Sankar
2020-02-29 23:51 ` Kees Cook
2020-03-01  0:11   ` Arvind Sankar
2020-03-02 18:38     ` Kees Cook
2020-03-05 15:05       ` [PATCH] microblaze: Stop printing the virtual memory layout Arvind Sankar
2020-03-05 20:50         ` Tycho Andersen
2020-03-09 10:09         ` Michal Simek
2020-03-05 15:06       ` [PATCH] nds32/mm: " Arvind Sankar
2020-03-05 20:50         ` Tycho Andersen
2020-03-05 15:08       ` [PATCH] powerpc/32: " Arvind Sankar
2020-03-05 20:50         ` Tycho Andersen
2022-03-09 19:35         ` Christophe Leroy
2020-03-05 15:10       ` [PATCH] sh: " Arvind Sankar
2020-03-05 15:18         ` John Paul Adrian Glaubitz
2020-03-05 15:38           ` Joe Perches
2020-03-05 15:41             ` John Paul Adrian Glaubitz
2020-03-05 15:46               ` Arvind Sankar
2020-03-05 15:49                 ` John Paul Adrian Glaubitz
2020-03-05 15:56                   ` Arvind Sankar
2020-03-05 20:51                     ` Tycho Andersen
2020-03-05 20:56                       ` John Paul Adrian Glaubitz
2020-03-05 21:17                       ` Kees Cook
2020-03-05 17:34                 ` Kees Cook
2020-03-06  8:04           ` Geert Uytterhoeven
2020-03-08 12:17           ` Kaiwan N Billimoria
2020-03-05 15:11       ` [PATCH] xtensa/mm: " Arvind Sankar
2020-03-05 20:51         ` Tycho Andersen
2020-03-06  7:54         ` Max Filippov
2020-03-01  0:22   ` [PATCH v2] x86/mm/init_32: " Arvind Sankar
2020-03-02 15:29     ` Tycho Andersen
2020-03-02 18:39     ` Kees Cook
2020-03-05 15:01       ` [PATCH v3] " Arvind Sankar
2020-03-05 17:28         ` Kees Cook
2020-03-05 20:49         ` Tycho Andersen
2020-03-05 23:00         ` [tip: x86/mm] x86/mm/init/32: " tip-bot2 for Arvind Sankar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).