Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1395409 > unrolled thread

[PATCH v6 0/11] x86/KASLR: Randomize virtual address separately

Started byKees Cook <keescook@chromium.org>
First post2016-05-06 00:20 +0200
Last post2016-05-07 08:40 +0200
Articles 4 on this page of 24 — 7 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v6 0/11] x86/KASLR: Randomize virtual address separately Kees Cook <keescook@chromium.org> - 2016-05-06 00:20 +0200
    [PATCH v6 04/11] x86/KASLR: Build identity mappings on demand Kees Cook <keescook@chromium.org> - 2016-05-06 00:20 +0200
      Re: [PATCH v6 04/11] x86/KASLR: Build identity mappings on demand Ingo Molnar <mingo@kernel.org> - 2016-05-06 09:10 +0200
        Re: [PATCH v6 04/11] x86/KASLR: Build identity mappings on demand Kees Cook <keescook@chromium.org> - 2016-05-06 19:50 +0200
    [PATCH v6 05/11] x86/KASLR: Add slot_area to manage random_addr slots Kees Cook <keescook@chromium.org> - 2016-05-06 00:20 +0200
    [PATCH v6 02/11] x86/KASLR: Consolidate mem_avoid entries Kees Cook <keescook@chromium.org> - 2016-05-06 00:20 +0200
      [tip:x86/boot] x86/KASLR: Consolidate mem_avoid[] entries tip-bot for Yinghai Lu <tipbot@zytor.com> - 2016-05-06 09:50 +0200
        Re: [tip:x86/boot] x86/KASLR: Consolidate mem_avoid[] entries Borislav Petkov <bp@alien8.de> - 2016-05-06 18:10 +0200
          Re: [tip:x86/boot] x86/KASLR: Consolidate mem_avoid[] entries Kees Cook <keescook@chromium.org> - 2016-05-06 20:20 +0200
            Re: [tip:x86/boot] x86/KASLR: Consolidate mem_avoid[] entries Borislav Petkov <bp@alien8.de> - 2016-05-06 21:40 +0200
    [PATCH v6 10/11] x86/KASLR: Add physical address randomization >4G Kees Cook <keescook@chromium.org> - 2016-05-06 00:20 +0200
      Re: [PATCH v6 10/11] x86/KASLR: Add physical address randomization  >4G Baoquan He <bhe@redhat.com> - 2016-05-06 10:30 +0200
        Re: [PATCH v6 10/11] x86/KASLR: Add physical address randomization >4G Kees Cook <keescook@chromium.org> - 2016-05-06 17:40 +0200
          Re: [PATCH v6 10/11] x86/KASLR: Add physical address randomization  >4G Baoquan He <bhe@redhat.com> - 2016-05-08 11:20 +0200
    [PATCH v6 06/11] x86/KASLR: Return earliest overlap when avoiding regions Kees Cook <keescook@chromium.org> - 2016-05-06 00:20 +0200
    [PATCH v6 01/11] x86/boot: Clean up pointer casting Kees Cook <keescook@chromium.org> - 2016-05-06 00:20 +0200
      [tip:x86/boot] x86/boot: Clean up pointer casting tip-bot for Kees Cook <tipbot@zytor.com> - 2016-05-06 09:50 +0200
        Re: [tip:x86/boot] x86/boot: Clean up pointer casting Borislav Petkov <bp@alien8.de> - 2016-05-06 11:00 +0200
          Re: [tip:x86/boot] x86/boot: Clean up pointer casting Ingo Molnar <mingo@kernel.org> - 2016-05-06 12:20 +0200
            Re: [tip:x86/boot] x86/boot: Clean up pointer casting Kees Cook <keescook@chromium.org> - 2016-05-06 17:30 +0200
          Re: [tip:x86/boot] x86/boot: Clean up pointer casting Ingo Molnar <mingo@kernel.org> - 2016-05-06 12:40 +0200
            Re: [tip:x86/boot] x86/boot: Clean up pointer casting Borislav Petkov <bp@alien8.de> - 2016-05-06 12:50 +0200
              [PATCH -v1.1] x86/boot: Simplify pointer casting in  choose_random_location() Borislav Petkov <bp@alien8.de> - 2016-05-06 14:00 +0200
                [tip:x86/boot] x86/boot: Simplify pointer casting in  choose_random_location() tip-bot for Borislav Petkov <tipbot@zytor.com> - 2016-05-07 08:40 +0200

Page 2 of 2 — ← Prev page 1 [2]


#1395760 — Re: [tip:x86/boot] x86/boot: Clean up pointer casting

FromIngo Molnar <mingo@kernel.org>
Date2016-05-06 12:40 +0200
SubjectRe: [tip:x86/boot] x86/boot: Clean up pointer casting
Message-ID<rvLkT-3iC-29@gated-at.bofh.it>
In reply to#1395713
Hm, your patch throws a lot of warnings during allnoconfig builds:

In file included from arch/x86/boot/compressed/error.c:6:0:
arch/x86/boot/compressed/misc.h: In function ‘choose_random_location’:
arch/x86/boot/compressed/misc.h:83:9: warning: return makes pointer from integer 
without a cast [-Wint-conversion]
  return output_ptr;
         ^
In file included from arch/x86/boot/compressed/early_serial_console.c:1:0:
arch/x86/boot/compressed/misc.h: In function ‘choose_random_location’:
arch/x86/boot/compressed/misc.h:83:9: warning: return makes pointer from integer 
without a cast [-Wint-conversion]
  return output_ptr;
         ^
  CC      arch/x86/boot/compressed/misc.o
In file included from arch/x86/boot/compressed/cmdline.c:1:0:
arch/x86/boot/compressed/misc.h: In function ‘choose_random_location’:
arch/x86/boot/compressed/misc.h:83:9: warning: return makes pointer from integer 
without a cast [-Wint-conversion]
  return output_ptr;
         ^
In file included from arch/x86/boot/compressed/misc.c:14:0:
arch/x86/boot/compressed/misc.h: In function ‘choose_random_location’:
arch/x86/boot/compressed/misc.h:83:9: warning: return makes pointer from integer 
without a cast [-Wint-conversion]
  return output_ptr;

Thanks,

	Ingo

[toc] | [prev] | [next] | [standalone]


#1395763 — Re: [tip:x86/boot] x86/boot: Clean up pointer casting

FromBorislav Petkov <bp@alien8.de>
Date2016-05-06 12:50 +0200
SubjectRe: [tip:x86/boot] x86/boot: Clean up pointer casting
Message-ID<rvLux-3mA-1@gated-at.bofh.it>
In reply to#1395760
On Fri, May 06, 2016 at 12:36:19PM +0200, Ingo Molnar wrote:
> 
> Hm, your patch throws a lot of warnings during allnoconfig builds:
> 
> In file included from arch/x86/boot/compressed/error.c:6:0:
> arch/x86/boot/compressed/misc.h: In function ‘choose_random_location’:
> arch/x86/boot/compressed/misc.h:83:9: warning: return makes pointer from integer 
> without a cast [-Wint-conversion]
>   return output_ptr;
>          ^

Blergh, that's when choose_random_location() is a stub and it needs to
do

	return (unsigned char *)output_ptr;

too.

Lemme run all the *config builds on the fixed version before I send you
a v2.

Thanks.

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.

[toc] | [prev] | [next] | [standalone]


#1395812 — [PATCH -v1.1] x86/boot: Simplify pointer casting in choose_random_location()

FromBorislav Petkov <bp@alien8.de>
Date2016-05-06 14:00 +0200
Subject[PATCH -v1.1] x86/boot: Simplify pointer casting in choose_random_location()
Message-ID<rvMAi-4gY-13@gated-at.bofh.it>
In reply to#1395763
From: Borislav Petkov <bp@suse.de>

Pass them down as unsigned long directly and get rid of more casting and
assignments.

Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Kees Cook <keescook@chromium.org>
---
 arch/x86/boot/compressed/kaslr.c | 17 ++++++-----------
 arch/x86/boot/compressed/misc.c  |  3 ++-
 arch/x86/boot/compressed/misc.h  | 10 +++++-----
 3 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
index 6392f0041b8a..a49f48317dad 100644
--- a/arch/x86/boot/compressed/kaslr.c
+++ b/arch/x86/boot/compressed/kaslr.c
@@ -350,20 +350,15 @@ static unsigned long find_random_addr(unsigned long minimum,
 	return slots_fetch_random();
 }
 
-unsigned char *choose_random_location(unsigned char *input_ptr,
+/*
+ * Since this function examines addresses much more numerically,
+ * it takes the input and output pointers as unsigned long.
+ */
+unsigned char *choose_random_location(unsigned long input,
 				      unsigned long input_size,
-				      unsigned char *output_ptr,
+				      unsigned long output,
 				      unsigned long output_size)
 {
-	/*
-	 * The caller of choose_random_location() uses unsigned char * for
-	 * buffer pointers since it performs decompression, elf parsing, etc.
-	 * Since this code examines addresses much more numerically,
-	 * unsigned long is used internally here. Instead of sprinkling
-	 * more casts into extract_kernel, do them here and at return.
-	 */
-	unsigned long input = (unsigned long)input_ptr;
-	unsigned long output = (unsigned long)output_ptr;
 	unsigned long choice = output;
 	unsigned long random_addr;
 
diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
index 9536d778149e..f14db4e21654 100644
--- a/arch/x86/boot/compressed/misc.c
+++ b/arch/x86/boot/compressed/misc.c
@@ -366,7 +366,8 @@ asmlinkage __visible void *extract_kernel(void *rmode, memptr heap,
 	 * the entire decompressed kernel plus relocation table, or the
 	 * entire decompressed kernel plus .bss and .brk sections.
 	 */
-	output = choose_random_location(input_data, input_len, output,
+	output = choose_random_location((unsigned long)input_data, input_len,
+					(unsigned long)output,
 					max(output_len, kernel_total_size));
 
 	/* Validate memory location choices. */
diff --git a/arch/x86/boot/compressed/misc.h b/arch/x86/boot/compressed/misc.h
index 1f23d022d241..0112005a3f23 100644
--- a/arch/x86/boot/compressed/misc.h
+++ b/arch/x86/boot/compressed/misc.h
@@ -67,20 +67,20 @@ int cmdline_find_option_bool(const char *option);
 
 #if CONFIG_RANDOMIZE_BASE
 /* kaslr.c */
-unsigned char *choose_random_location(unsigned char *input_ptr,
+unsigned char *choose_random_location(unsigned long input_ptr,
 				      unsigned long input_size,
-				      unsigned char *output_ptr,
+				      unsigned long output_ptr,
 				      unsigned long output_size);
 /* cpuflags.c */
 bool has_cpuflag(int flag);
 #else
 static inline
-unsigned char *choose_random_location(unsigned char *input_ptr,
+unsigned char *choose_random_location(unsigned long input_ptr,
 				      unsigned long input_size,
-				      unsigned char *output_ptr,
+				      unsigned long output_ptr,
 				      unsigned long output_size)
 {
-	return output_ptr;
+	return (unsigned char *)output_ptr;
 }
 #endif
 
-- 
2.7.3

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.

[toc] | [prev] | [next] | [standalone]


#1396262 — [tip:x86/boot] x86/boot: Simplify pointer casting in choose_random_location()

Fromtip-bot for Borislav Petkov <tipbot@zytor.com>
Date2016-05-07 08:40 +0200
Subject[tip:x86/boot] x86/boot: Simplify pointer casting in choose_random_location()
Message-ID<rw449-4BU-5@gated-at.bofh.it>
In reply to#1395812
Commit-ID:  549f90db68c9f8e21a40ec21c8047441984e7164
Gitweb:     http://git.kernel.org/tip/549f90db68c9f8e21a40ec21c8047441984e7164
Author:     Borislav Petkov <bp@suse.de>
AuthorDate: Fri, 6 May 2016 13:50:15 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Sat, 7 May 2016 07:38:38 +0200

x86/boot: Simplify pointer casting in choose_random_location()

Pass them down as 'unsigned long' directly and get rid of more casting and
assignments.

Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: akpm@linux-foundation.org
Cc: bhe@redhat.com
Cc: dyoung@redhat.com
Cc: linux-tip-commits@vger.kernel.org
Cc: luto@kernel.org
Cc: vgoyal@redhat.com
Cc: yinghai@kernel.org
Link: http://lkml.kernel.org/r/20160506115015.GI24044@pd.tnic
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/boot/compressed/kaslr.c | 17 ++++++-----------
 arch/x86/boot/compressed/misc.c  |  3 ++-
 arch/x86/boot/compressed/misc.h  | 10 +++++-----
 3 files changed, 13 insertions(+), 17 deletions(-)

diff --git a/arch/x86/boot/compressed/kaslr.c b/arch/x86/boot/compressed/kaslr.c
index 6392f00..ff12277 100644
--- a/arch/x86/boot/compressed/kaslr.c
+++ b/arch/x86/boot/compressed/kaslr.c
@@ -350,20 +350,15 @@ static unsigned long find_random_addr(unsigned long minimum,
 	return slots_fetch_random();
 }
 
-unsigned char *choose_random_location(unsigned char *input_ptr,
+/*
+ * Since this function examines addresses much more numerically,
+ * it takes the input and output pointers as 'unsigned long'.
+ */
+unsigned char *choose_random_location(unsigned long input,
 				      unsigned long input_size,
-				      unsigned char *output_ptr,
+				      unsigned long output,
 				      unsigned long output_size)
 {
-	/*
-	 * The caller of choose_random_location() uses unsigned char * for
-	 * buffer pointers since it performs decompression, elf parsing, etc.
-	 * Since this code examines addresses much more numerically,
-	 * unsigned long is used internally here. Instead of sprinkling
-	 * more casts into extract_kernel, do them here and at return.
-	 */
-	unsigned long input = (unsigned long)input_ptr;
-	unsigned long output = (unsigned long)output_ptr;
 	unsigned long choice = output;
 	unsigned long random_addr;
 
diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
index 9536d77..f14db4e 100644
--- a/arch/x86/boot/compressed/misc.c
+++ b/arch/x86/boot/compressed/misc.c
@@ -366,7 +366,8 @@ asmlinkage __visible void *extract_kernel(void *rmode, memptr heap,
 	 * the entire decompressed kernel plus relocation table, or the
 	 * entire decompressed kernel plus .bss and .brk sections.
 	 */
-	output = choose_random_location(input_data, input_len, output,
+	output = choose_random_location((unsigned long)input_data, input_len,
+					(unsigned long)output,
 					max(output_len, kernel_total_size));
 
 	/* Validate memory location choices. */
diff --git a/arch/x86/boot/compressed/misc.h b/arch/x86/boot/compressed/misc.h
index 1f23d02..0112005a 100644
--- a/arch/x86/boot/compressed/misc.h
+++ b/arch/x86/boot/compressed/misc.h
@@ -67,20 +67,20 @@ int cmdline_find_option_bool(const char *option);
 
 #if CONFIG_RANDOMIZE_BASE
 /* kaslr.c */
-unsigned char *choose_random_location(unsigned char *input_ptr,
+unsigned char *choose_random_location(unsigned long input_ptr,
 				      unsigned long input_size,
-				      unsigned char *output_ptr,
+				      unsigned long output_ptr,
 				      unsigned long output_size);
 /* cpuflags.c */
 bool has_cpuflag(int flag);
 #else
 static inline
-unsigned char *choose_random_location(unsigned char *input_ptr,
+unsigned char *choose_random_location(unsigned long input_ptr,
 				      unsigned long input_size,
-				      unsigned char *output_ptr,
+				      unsigned long output_ptr,
 				      unsigned long output_size)
 {
-	return output_ptr;
+	return (unsigned char *)output_ptr;
 }
 #endif
 

[toc] | [prev] | [standalone]


Page 2 of 2 — ← Prev page 1 [2]

Back to top | Article view | linux.kernel


csiph-web