Skip to contentSkip to conversation

makedumpfile: Add support of mm randomization

PATCH Superseded Baoquan He 3 participants 15 messages Aug 29, 2016 – Oct 4, 2016

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Baoquan He

author
#0 lore raw

cover makedumpfile: Add support of mm randomization

Hi Atsushi and Thomas,

This is a draft patchset. I just checked x86_64 implementation according to Thomas's mm randomization related patches. Not sure if this will affect other ARCH or XEN. Especially for patch 1/3 and patch 2/3, just a original idea. I tested on x86_64, passed.

And also kernel patch need be adjusted so that number_table.X of makedumpfile can be used. Will add comment to Thomas's kernel patch.

Baoquan He (3):
makedumpfile: Get info->kernel_version from SYMBOL(init_uts_ns)
earlier
makedumpfile: Move get_versiondep_info calling earlier
makedumpfile: Add support for MM randomization

 arch/x86_64.c  | 26 +++++++++-----------------
 makedumpfile.c | 45 ++++++++++++++++++++++++++++++++++++---------
 makedumpfile.h |  3 +++
 3 files changed, 48 insertions(+), 26 deletions(-)
Signature · 7 lines
2.5.5


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
author
#1 lore raw

PATCH 1/3 makedumpfile: Get info->kernel_version from SYMBOL(init_uts_ns) earlier

The current code assign value to info->kernel_version in check_release, this is too late and buggy. Because in check_release(), it needs call readmem, however earlier get_value_for_old_linux depends on info->kernel_version to get correct KERNEL_IMAGE_SIZE for MODULES_VADDR which is used in is_vmalloc_addr_x86_64(). This looks a weird circle.

Since we have export "OSRELEASE=%s\n" explicitly in kernel, we should always use it to get kernel version. And this breaks above weird circle. Otherwise MM randomization will come and make it worse.

---
 makedumpfile.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
makedumpfile.c +6 -6
index 21784e8..ce68d61 100644
@@ -1139,12 +1139,6 @@ check_release(void)
 		}
 	}
 
-	info->kernel_version = get_kernel_version(info->system_utsname.release);
-	if (info->kernel_version == FALSE) {
-		ERRMSG("Can't get the kernel version.\n");
-		return FALSE;
-	}
-
 	return TRUE;
 }
 
@@ -3832,6 +3826,12 @@ initial(void)
 		debug_info = TRUE;
 	}
 
+	info->kernel_version = get_kernel_version(info.release);
+	if (info->kernel_version == FALSE) {
+		ERRMSG("Can't get the kernel version.\n");
+		return FALSE;
+	}
+
 	if (!get_value_for_old_linux())
 		return FALSE;
 
Signature · 7 lines
2.5.5


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
author
#2 lore raw

PATCH 2/3 makedumpfile: Move get_versiondep_info calling earlier

In reply to Baoquan He

Because is_vmalloc_addr_x86_64 need called very early, e.g in readmem(). So we have to move get_versiondep_info calling earlier to make PAGE_OFFSET/VMALLOC_START/VMEMMAP_START get value before use them.

---
 makedumpfile.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
makedumpfile.c +3 -3
index ce68d61..2713f8a 100644
@@ -3835,6 +3835,9 @@ initial(void)
 	if (!get_value_for_old_linux())
 		return FALSE;
 
+	if (!get_versiondep_info())
+		return FALSE;
+
 	if (info->flag_mem_usage && !get_kcore_dump_loads())
 		return FALSE;
 
@@ -3986,9 +3989,6 @@ out:
 		if (!check_release())
 			return FALSE;
 
-		if (!get_versiondep_info())
-			return FALSE;
-
 		/*
 		 * NOTE: This must be done before refering to
 		 * VMALLOC'ed memory. The first 640kB contains data
Signature · 7 lines
2.5.5


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
author
#3 lore raw

PATCH 3/3 makedumpfile: Add support for MM randomization

In reply to Baoquan He

In kernel patchset "x86/mm: memory area address KASLR", PAGE_OFFSET, VMALLOC_START and VMEMMAP_START are all randomized. Please check below link:

	https://lwn.net/Articles/692289/

And these need be exported into vmcoreinfo and tell makedumpfile. In this patch get and handle them to support MM randomization.

---
 arch/x86_64.c  | 26 +++++++++-----------------
 makedumpfile.c | 29 ++++++++++++++++++++++++++++-
 makedumpfile.h |  3 +++
 3 files changed, 40 insertions(+), 18 deletions(-)
arch/x86_64.c +9 -17
index ddf7be6..ff787cc 100644
@@ -146,8 +146,9 @@ get_machdep_info_x86_64(void)
 	return TRUE;
 }
 
-int
-get_versiondep_info_x86_64(void)
+#define VMALLOC_SIZE            (0x200000000000)
+#define VMEMMAP_SIZE            (0x10000000000)
+int get_versiondep_info_x86_64(void)
 {
 	/*
 	 * On linux-2.6.26, MAX_PHYSMEM_BITS is changed to 44 from 40.
@@ -159,22 +160,13 @@ get_versiondep_info_x86_64(void)
 	else
 		info->max_physmem_bits  = _MAX_PHYSMEM_BITS_2_6_31;
 
-	if (info->kernel_version < KERNEL_VERSION(2, 6, 27))
-		info->page_offset = __PAGE_OFFSET_ORIG;
-	else
-		info->page_offset = __PAGE_OFFSET_2_6_27;
+	info->page_offset = NUMBER(page_offset);
 
-	if (info->kernel_version < KERNEL_VERSION(2, 6, 31)) {
-		info->vmalloc_start = VMALLOC_START_ORIG;
-		info->vmalloc_end   = VMALLOC_END_ORIG;
-		info->vmemmap_start = VMEMMAP_START_ORIG;
-		info->vmemmap_end   = VMEMMAP_END_ORIG;
-	} else {
-		info->vmalloc_start = VMALLOC_START_2_6_31;
-		info->vmalloc_end   = VMALLOC_END_2_6_31;
-		info->vmemmap_start = VMEMMAP_START_2_6_31;
-		info->vmemmap_end   = VMEMMAP_END_2_6_31;
-	}
+
+	info->vmalloc_start = NUMBER(vmalloc_start);
+	info->vmalloc_end   = info->vmalloc_start + VMALLOC_SIZE - 1;
+	info->vmemmap_start = NUMBER(vmemmap_start);
+	info->vmemmap_end   = info->vmemmap_start + VMEMMAP_SIZE - 1;
 
 	return TRUE;
 }
makedumpfile.c +28 -1
index 2713f8a..6b0c6ab 100644
@@ -1985,6 +1985,7 @@ get_value_for_old_linux(void)
 			NUMBER(PAGE_BUDDY_MAPCOUNT_VALUE) =
 			PAGE_BUDDY_MAPCOUNT_VALUE_v2_6_39_to_latest_version;
 	}
+	ERRMSG("info->kernel_version=%d\n", info->kernel_version);
 #ifdef __x86_64__
 	if (NUMBER(KERNEL_IMAGE_SIZE) == NOT_FOUND_NUMBER) {
 		if (info->kernel_version < KERNEL_VERSION(2, 6, 26))
@@ -1992,6 +1993,26 @@ get_value_for_old_linux(void)
 		else
 			NUMBER(KERNEL_IMAGE_SIZE) = KERNEL_IMAGE_SIZE_2_6_26;
 	}
+	if (NUMBER(page_offset) == NOT_FOUND_NUMBER) {
+		if (info->kernel_version < KERNEL_VERSION(2, 6, 27))
+			NUMBER(page_offset) = __PAGE_OFFSET_ORIG;
+		else
+			NUMBER(page_offset) = __PAGE_OFFSET_2_6_27;
+	}
+	if (NUMBER(vmalloc_start) == NOT_FOUND_NUMBER) {
+		if (info->kernel_version < KERNEL_VERSION(2, 6, 31)) {
+			NUMBER(vmalloc_start) = VMALLOC_START_ORIG;
+		} else {
+			NUMBER(vmalloc_start) = VMALLOC_START_2_6_31;
+		}
+	}
+	if (NUMBER(vmemmap_start) == NOT_FOUND_NUMBER) {
+		if (info->kernel_version < KERNEL_VERSION(2, 6, 31))
+			NUMBER(vmemmap_start) = VMEMMAP_START_ORIG;
+		else
+			NUMBER(vmemmap_start) = VMEMMAP_START_2_6_31;
+	}
+
 #endif
 	if (SIZE(pageflags) == NOT_FOUND_STRUCTURE) {
 		if (info->kernel_version >= KERNEL_VERSION(2, 6, 27))
@@ -2249,6 +2270,9 @@ write_vmcoreinfo_data(void)
 
 	WRITE_NUMBER("PAGE_BUDDY_MAPCOUNT_VALUE", PAGE_BUDDY_MAPCOUNT_VALUE);
 	WRITE_NUMBER("KERNEL_IMAGE_SIZE", KERNEL_IMAGE_SIZE);
+	WRITE_NUMBER("PAGE_OFFSET", page_offset);
+	WRITE_NUMBER("VMALLOC_START", vmalloc_start);
+	WRITE_NUMBER("VMEMMAP_START", vmemmap_start);
 
 	WRITE_NUMBER("HUGETLB_PAGE_DTOR", HUGETLB_PAGE_DTOR);
 
@@ -2595,6 +2619,9 @@ read_vmcoreinfo(void)
 
 	READ_NUMBER("PAGE_BUDDY_MAPCOUNT_VALUE", PAGE_BUDDY_MAPCOUNT_VALUE);
 	READ_NUMBER("KERNEL_IMAGE_SIZE", KERNEL_IMAGE_SIZE);
+	READ_NUMBER("PAGE_OFFSET", page_offset);
+	READ_NUMBER("VMALLOC_START", vmalloc_start);
+	READ_NUMBER("VMEMMAP_START", vmemmap_start);
 
 	READ_NUMBER("HUGETLB_PAGE_DTOR", HUGETLB_PAGE_DTOR);
 
@@ -3826,7 +3853,7 @@ initial(void)
 		debug_info = TRUE;
 	}
 
-	info->kernel_version = get_kernel_version(info.release);
+	info->kernel_version = get_kernel_version(info->release);
 	if (info->kernel_version == FALSE) {
 		ERRMSG("Can't get the kernel version.\n");
 		return FALSE;
makedumpfile.h +3 -0
index 533e5b8..0e34fae 100644
@@ -1685,6 +1685,9 @@ struct number_table {
 
 	long	PAGE_BUDDY_MAPCOUNT_VALUE;
 	long	KERNEL_IMAGE_SIZE;
+	long	page_offset;
+	long	vmalloc_start;
+	long	vmemmap_start;
 	long	SECTION_SIZE_BITS;
 	long	MAX_PHYSMEM_BITS;
 	long    HUGETLB_PAGE_DTOR;
Signature · 7 lines
2.5.5


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
author
#8 lore raw
In reply to Baoquan He

Sorry, I just copied Atsushi's mail address from an very old git commit.

CC again.

Quoted 16 lines · Baoquan He

Hi Atsushi and Thomas,

This is a draft patchset. I just checked x86_64 implementation according to Thomas's mm randomization related patches. Not sure if this will affect other ARCH or XEN. Especially for patch 1/3 and patch 2/3, just a original idea. I tested on x86_64, passed.

And also kernel patch need be adjusted so that number_table.X of makedumpfile can be used. Will add comment to Thomas's kernel patch.

Baoquan He (3):
makedumpfile: Get info->kernel_version from SYMBOL(init_uts_ns)
earlier
makedumpfile: Move get_versiondep_info calling earlier
makedumpfile: Add support for MM randomization

Quoted 13 lines
 arch/x86_64.c  | 26 +++++++++-----------------
 makedumpfile.c | 45 ++++++++++++++++++++++++++++++++++++---------
 makedumpfile.h |  3 +++
 3 files changed, 48 insertions(+), 26 deletions(-)
Signature · 7 lines
2.5.5


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#4 lore raw

RE: [PATCH 3/3] makedumpfile: Add support for MM randomization

In reply to Baoquan He

Hello Baoquan,

Thanks for your work, I have some comments below.

Quoted 42 lines

In kernel patchset "x86/mm: memory area address KASLR", PAGE_OFFSET, VMALLOC_START and VMEMMAP_START are all randomized. Please check below link:

	https://lwn.net/Articles/692289/

And these need be exported into vmcoreinfo and tell makedumpfile. In this patch get and handle them to support MM randomization.

---

arch/x86_64.c  | 26 +++++++++-----------------
makedumpfile.c | 29 ++++++++++++++++++++++++++++-
makedumpfile.h |  3 +++
3 files changed, 40 insertions(+), 18 deletions(-)
arch/x86_64.c +4 -7
index ddf7be6..ff787cc 100644
@@ -146,8 +146,9 @@ get_machdep_info_x86_64(void)
 	return TRUE;
 }
 
-int
-get_versiondep_info_x86_64(void)
+#define VMALLOC_SIZE            (0x200000000000)
+#define VMEMMAP_SIZE            (0x10000000000)
+int get_versiondep_info_x86_64(void)
 {
 	/*
 	 * On linux-2.6.26, MAX_PHYSMEM_BITS is changed to 44 from 40.
@@ -159,22 +160,13 @@ get_versiondep_info_x86_64(void)
 	else
 		info->max_physmem_bits  = _MAX_PHYSMEM_BITS_2_6_31;
 
-	if (info->kernel_version < KERNEL_VERSION(2, 6, 27))
-		info->page_offset = __PAGE_OFFSET_ORIG;
-	else
-		info->page_offset = __PAGE_OFFSET_2_6_27;
+	info->page_offset = NUMBER(page_offset);
 
-	if (info->kernel_version < KERNEL_VERSION(2, 6, 31)) {

arch/x86_64.c get_versiondep_info_x86_64(void) · line 177

Quoted 10 lines
arch/x86_64.c +0 -10
-		info->vmalloc_start = VMALLOC_START_ORIG;
-		info->vmalloc_end   = VMALLOC_END_ORIG;
-		info->vmemmap_start = VMEMMAP_START_ORIG;
-		info->vmemmap_end   = VMEMMAP_END_ORIG;
-	} else {
-		info->vmalloc_start = VMALLOC_START_2_6_31;
-		info->vmalloc_end   = VMALLOC_END_2_6_31;
-		info->vmemmap_start = VMEMMAP_START_2_6_31;
-		info->vmemmap_end   = VMEMMAP_END_2_6_31;
-	}

These *_END_* are no longer used, it's better to remove the definitions of them.

Quoted 13 lines
arch/x86_64.c +5 -0
+
+	info->vmalloc_start = NUMBER(vmalloc_start);
+	info->vmalloc_end   = info->vmalloc_start + VMALLOC_SIZE - 1;
+	info->vmemmap_start = NUMBER(vmemmap_start);
+	info->vmemmap_end   = info->vmemmap_start + VMEMMAP_SIZE - 1;
 
 	return TRUE;
 }
makedumpfile.c +0 -0
index 2713f8a..6b0c6ab 100644

makedumpfile.c get_value_for_old_linux(void) · line 1988

Quoted 4 lines
makedumpfile.c +1 -0
@@ -1985,6 +1985,7 @@ get_value_for_old_linux(void)
 			NUMBER(PAGE_BUDDY_MAPCOUNT_VALUE) =
 			PAGE_BUDDY_MAPCOUNT_VALUE_v2_6_39_to_latest_version;
 	}
+	ERRMSG("info->kernel_version=%d\n", info->kernel_version);

Is this just a debug message ?

Quoted 17 lines
makedumpfile.c +10 -0
 #ifdef __x86_64__
 	if (NUMBER(KERNEL_IMAGE_SIZE) == NOT_FOUND_NUMBER) {
 		if (info->kernel_version < KERNEL_VERSION(2, 6, 26))
@@ -1992,6 +1993,26 @@ get_value_for_old_linux(void)
 		else
 			NUMBER(KERNEL_IMAGE_SIZE) = KERNEL_IMAGE_SIZE_2_6_26;
 	}
+	if (NUMBER(page_offset) == NOT_FOUND_NUMBER) {
+		if (info->kernel_version < KERNEL_VERSION(2, 6, 27))
+			NUMBER(page_offset) = __PAGE_OFFSET_ORIG;
+		else
+			NUMBER(page_offset) = __PAGE_OFFSET_2_6_27;
+	}
+	if (NUMBER(vmalloc_start) == NOT_FOUND_NUMBER) {
+		if (info->kernel_version < KERNEL_VERSION(2, 6, 31)) {
+			NUMBER(vmalloc_start) = VMALLOC_START_ORIG;
+		} else {

makedumpfile.c get_value_for_old_linux(void) · line 2015

Quoted 10 lines
makedumpfile.c +10 -0
+			NUMBER(vmalloc_start) = VMALLOC_START_2_6_31;
+		}
+	}
+	if (NUMBER(vmemmap_start) == NOT_FOUND_NUMBER) {
+		if (info->kernel_version < KERNEL_VERSION(2, 6, 31))
+			NUMBER(vmemmap_start) = VMEMMAP_START_ORIG;
+		else
+			NUMBER(vmemmap_start) = VMEMMAP_START_2_6_31;
+	}
+

(I should have said this when you post the early kaslr patch.) This logic is only for x86_64, I don't like to take it out to here(general pass) with #ifdef. Is there any necessity to write this code here ?

Quoted 24 lines
makedumpfile.c +6 -0
 #endif
 	if (SIZE(pageflags) == NOT_FOUND_STRUCTURE) {
 		if (info->kernel_version >= KERNEL_VERSION(2, 6, 27))
@@ -2249,6 +2270,9 @@ write_vmcoreinfo_data(void)
 
 	WRITE_NUMBER("PAGE_BUDDY_MAPCOUNT_VALUE", PAGE_BUDDY_MAPCOUNT_VALUE);
 	WRITE_NUMBER("KERNEL_IMAGE_SIZE", KERNEL_IMAGE_SIZE);
+	WRITE_NUMBER("PAGE_OFFSET", page_offset);
+	WRITE_NUMBER("VMALLOC_START", vmalloc_start);
+	WRITE_NUMBER("VMEMMAP_START", vmemmap_start);
 
 	WRITE_NUMBER("HUGETLB_PAGE_DTOR", HUGETLB_PAGE_DTOR);
 
@@ -2595,6 +2619,9 @@ read_vmcoreinfo(void)
 
 	READ_NUMBER("PAGE_BUDDY_MAPCOUNT_VALUE", PAGE_BUDDY_MAPCOUNT_VALUE);
 	READ_NUMBER("KERNEL_IMAGE_SIZE", KERNEL_IMAGE_SIZE);
+	READ_NUMBER("PAGE_OFFSET", page_offset);
+	READ_NUMBER("VMALLOC_START", vmalloc_start);
+	READ_NUMBER("VMEMMAP_START", vmemmap_start);
 
 	READ_NUMBER("HUGETLB_PAGE_DTOR", HUGETLB_PAGE_DTOR);
 

makedumpfile.c initial(void) · line 3856

Quoted 5 lines
makedumpfile.c +1 -1
@@ -3826,7 +3853,7 @@ initial(void)
 		debug_info = TRUE;
 	}
 
-	info->kernel_version = get_kernel_version(info.release);
+	info->kernel_version = get_kernel_version(info->release);

Why don't you write "info->release" in [PATCH 1/3] ?

Thanks,
Atsushi Kumagai

Quoted 21 lines
makedumpfile.c +0 -0
 	if (info->kernel_version == FALSE) {
 		ERRMSG("Can't get the kernel version.\n");
 		return FALSE;
makedumpfile.h +3 -1
index 533e5b8..0e34fae 100644
@@ -1685,6 +1685,9 @@ struct number_table {
 
 	long	PAGE_BUDDY_MAPCOUNT_VALUE;
 	long	KERNEL_IMAGE_SIZE;
+	long	page_offset;
+	long	vmalloc_start;
+	long	vmemmap_start;
 	long	SECTION_SIZE_BITS;
 	long	MAX_PHYSMEM_BITS;
 	long    HUGETLB_PAGE_DTOR;
--

2.5.5

Quoted 4 lines

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#9 lore raw
In reply to Baoquan He

Hi, Baoquan

Quoted 16 lines · Baoquan He

Hi Atsushi and Thomas,

This is a draft patchset. I just checked x86_64 implementation according to Thomas's mm randomization related patches. Not sure if this will affect other ARCH or XEN. Especially for patch 1/3 and patch 2/3, just a original idea. I tested on x86_64, passed.

And also kernel patch need be adjusted so that number_table.X of makedumpfile can be used. Will add comment to Thomas's kernel patch.

Baoquan He (3):
makedumpfile: Get info->kernel_version from SYMBOL(init_uts_ns)
earlier
makedumpfile: Move get_versiondep_info calling earlier
makedumpfile: Add support for MM randomization

Quoted 5 lines
 arch/x86_64.c  | 26 +++++++++-----------------
 makedumpfile.c | 45 ++++++++++++++++++++++++++++++++++++---------
 makedumpfile.h |  3 +++
 3 files changed, 48 insertions(+), 26 deletions(-)

With these patch applied, I still get a makedumpfile failure below in Fedora:
Kernel applied your patch to export the 3 symbols.

kdump: saving vmcore-dmesg.txt complete
kdump: saving vmcore
kdump: saving vmcore failed
[FAILED] Failed to start Kdump Vmcore Save Service.

Thanks
Dave

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#10 lore raw

Fix email address of Atsushi Kumagai..

Quoted 28 lines · Dave Young

Hi, Baoquan

Quoted 16 lines · Baoquan He

Hi Atsushi and Thomas,

This is a draft patchset. I just checked x86_64 implementation according to Thomas's mm randomization related patches. Not sure if this will affect other ARCH or XEN. Especially for patch 1/3 and patch 2/3, just a original idea. I tested on x86_64, passed.

And also kernel patch need be adjusted so that number_table.X of makedumpfile can be used. Will add comment to Thomas's kernel patch.

Baoquan He (3):
makedumpfile: Get info->kernel_version from SYMBOL(init_uts_ns)
earlier
makedumpfile: Move get_versiondep_info calling earlier
makedumpfile: Add support for MM randomization

Quoted 5 lines
 arch/x86_64.c  | 26 +++++++++-----------------
 makedumpfile.c | 45 ++++++++++++++++++++++++++++++++++++---------
 makedumpfile.h |  3 +++
 3 files changed, 48 insertions(+), 26 deletions(-)

With these patch applied, I still get a makedumpfile failure below in Fedora:
Kernel applied your patch to export the 3 symbols.

Quoted 7 lines

kdump: saving vmcore-dmesg.txt complete
kdump: saving vmcore
kdump: saving vmcore failed
[FAILED] Failed to start Kdump Vmcore Save Service.

Thanks
Dave

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

author
#11 lore raw
Quoted 7 lines · Dave Young

Fix email address of Atsushi Kumagai..

Quoted 4 lines · Dave Young

Hi, Baoquan

Quoted 1 line · Baoquan He

Hi Atsushi and Thomas,

Did you apply below kexec patch either?

kexec/arch/i386: Add support for KASLR memory randomization

Please search it in kexec mailing list, Thomas posted it.

Quoted 24 lines
Quoted 24 lines
Quoted 15 lines

This is a draft patchset. I just checked x86_64 implementation according to Thomas's mm randomization related patches. Not sure if this will affect other ARCH or XEN. Especially for patch 1/3 and patch 2/3, just a original idea. I tested on x86_64, passed.

And also kernel patch need be adjusted so that number_table.X of makedumpfile can be used. Will add comment to Thomas's kernel patch.

Baoquan He (3):
makedumpfile: Get info->kernel_version from SYMBOL(init_uts_ns)
earlier
makedumpfile: Move get_versiondep_info calling earlier
makedumpfile: Add support for MM randomization

Quoted 5 lines
 arch/x86_64.c  | 26 +++++++++-----------------
 makedumpfile.c | 45 ++++++++++++++++++++++++++++++++++++---------
 makedumpfile.h |  3 +++
 3 files changed, 48 insertions(+), 26 deletions(-)

With these patch applied, I still get a makedumpfile failure below in Fedora:
Kernel applied your patch to export the 3 symbols.

Quoted 7 lines
Quoted 7 lines

kdump: saving vmcore-dmesg.txt complete
kdump: saving vmcore
kdump: saving vmcore failed
[FAILED] Failed to start Kdump Vmcore Save Service.

Thanks
Dave

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

author
#13 lore raw
Quoted 9 lines · Dave Young

Hi,

Quoted 5 lines

Did you apply below kexec patch either?

kexec/arch/i386: Add support for KASLR memory randomization

Please search it in kexec mailing list, Thomas posted it.

Yes, applied.

message-level 31 could help to find out what's happening in makedumpfile.

Quoted 3 lines

Thanks
Dave

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#14 lore raw
Quoted 5 lines · Baoquan He
Quoted 4 lines · Dave Young

Hi,

Quoted 2 lines

Did you apply below kexec patch either?

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

kexec/arch/i386: Add support for KASLR memory randomization

Please search it in kexec mailing list, Thomas posted it.

Yes, applied.

message-level 31 could help to find out what's happening in makedumpfile.

It works after reapplying them to devel branch.

Thanks
Dave

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

author
#5 lore raw

Re: [PATCH 3/3] makedumpfile: Add support for MM randomization

In reply to Atsushi Kumagai

Hi Atsushi,

Thanks a lot for your reviewing!

I am very sorry for so late response, just focused on other issue earlier.

Quoted 45 lines · Atsushi Kumagai

Hello Baoquan,

Thanks for your work, I have some comments below.

Quoted 41 lines

In kernel patchset "x86/mm: memory area address KASLR", PAGE_OFFSET, VMALLOC_START and VMEMMAP_START are all randomized. Please check below link:

	https://lwn.net/Articles/692289/

And these need be exported into vmcoreinfo and tell makedumpfile. In this patch get and handle them to support MM randomization.

---

arch/x86_64.c  | 26 +++++++++-----------------
makedumpfile.c | 29 ++++++++++++++++++++++++++++-
makedumpfile.h |  3 +++
3 files changed, 40 insertions(+), 18 deletions(-)
arch/x86_64.c +4 -6
index ddf7be6..ff787cc 100644
@@ -146,8 +146,9 @@ get_machdep_info_x86_64(void)
 	return TRUE;
 }
 
-int
-get_versiondep_info_x86_64(void)
+#define VMALLOC_SIZE            (0x200000000000)
+#define VMEMMAP_SIZE            (0x10000000000)
+int get_versiondep_info_x86_64(void)
 {
 	/*
 	 * On linux-2.6.26, MAX_PHYSMEM_BITS is changed to 44 from 40.
@@ -159,22 +160,13 @@ get_versiondep_info_x86_64(void)
 	else
 		info->max_physmem_bits  = _MAX_PHYSMEM_BITS_2_6_31;
 
-	if (info->kernel_version < KERNEL_VERSION(2, 6, 27))
-		info->page_offset = __PAGE_OFFSET_ORIG;
-	else
-		info->page_offset = __PAGE_OFFSET_2_6_27;
+	info->page_offset = NUMBER(page_offset);
 
Quoted 14 lines

arch/x86_64.c get_versiondep_info_x86_64(void) · line 177

Quoted 11 lines
arch/x86_64.c +0 -11
-	if (info->kernel_version < KERNEL_VERSION(2, 6, 31)) {
-		info->vmalloc_start = VMALLOC_START_ORIG;
-		info->vmalloc_end   = VMALLOC_END_ORIG;
-		info->vmemmap_start = VMEMMAP_START_ORIG;
-		info->vmemmap_end   = VMEMMAP_END_ORIG;
-	} else {
-		info->vmalloc_start = VMALLOC_START_2_6_31;
-		info->vmalloc_end   = VMALLOC_END_2_6_31;
-		info->vmemmap_start = VMEMMAP_START_2_6_31;
-		info->vmemmap_end   = VMEMMAP_END_2_6_31;
-	}

These *_END_* are no longer used, it's better to remove the definitions of them.

Seems is_vmalloc_addr_x86_64 still needs VMALLOC_END and VMEMMAP_END to make a judgement.

Quoted 7 lines
Quoted 7 lines
arch/x86_64.c +5 -0
+
+	info->vmalloc_start = NUMBER(vmalloc_start);
+	info->vmalloc_end   = info->vmalloc_start + VMALLOC_SIZE - 1;
+	info->vmemmap_start = NUMBER(vmemmap_start);
+	info->vmemmap_end   = info->vmemmap_start + VMEMMAP_SIZE - 1;
 
Quoted 13 lines

makedumpfile.c get_value_for_old_linux(void) · line 1988

Quoted 11 lines
arch/x86_64.c +0 -0
 	return TRUE;
 }
makedumpfile.c +1 -0
index 2713f8a..6b0c6ab 100644
@@ -1985,6 +1985,7 @@ get_value_for_old_linux(void)
 			NUMBER(PAGE_BUDDY_MAPCOUNT_VALUE) =
 			PAGE_BUDDY_MAPCOUNT_VALUE_v2_6_39_to_latest_version;
 	}
+	ERRMSG("info->kernel_version=%d\n", info->kernel_version);

Is this just a debug message ?

Yes, sorry for this. Will remove it.

Quoted 25 lines
Quoted 25 lines
makedumpfile.c +17 -0
 #ifdef __x86_64__
 	if (NUMBER(KERNEL_IMAGE_SIZE) == NOT_FOUND_NUMBER) {
 		if (info->kernel_version < KERNEL_VERSION(2, 6, 26))
@@ -1992,6 +1993,26 @@ get_value_for_old_linux(void)
 		else
 			NUMBER(KERNEL_IMAGE_SIZE) = KERNEL_IMAGE_SIZE_2_6_26;
 	}
+	if (NUMBER(page_offset) == NOT_FOUND_NUMBER) {
+		if (info->kernel_version < KERNEL_VERSION(2, 6, 27))
+			NUMBER(page_offset) = __PAGE_OFFSET_ORIG;
+		else
+			NUMBER(page_offset) = __PAGE_OFFSET_2_6_27;
+	}
+	if (NUMBER(vmalloc_start) == NOT_FOUND_NUMBER) {
+		if (info->kernel_version < KERNEL_VERSION(2, 6, 31)) {
+			NUMBER(vmalloc_start) = VMALLOC_START_ORIG;
+		} else {
+			NUMBER(vmalloc_start) = VMALLOC_START_2_6_31;
+		}
+	}
+	if (NUMBER(vmemmap_start) == NOT_FOUND_NUMBER) {
+		if (info->kernel_version < KERNEL_VERSION(2, 6, 31))
+			NUMBER(vmemmap_start) = VMEMMAP_START_ORIG;
+		else
Quoted 8 lines

makedumpfile.c get_value_for_old_linux(void) · line 2015

Quoted 3 lines
makedumpfile.c +3 -0
+			NUMBER(vmemmap_start) = VMEMMAP_START_2_6_31;
+	}
+

(I should have said this when you post the early kaslr patch.) This logic is only for x86_64, I don't like to take it out to here(general pass) with #ifdef. Is there any necessity to write this code here ?

Yes, you are right. I plan to put them into get_versiondep_info_x86_64.

Quoted 24 lines
Quoted 24 lines
makedumpfile.c +6 -0
 #endif
 	if (SIZE(pageflags) == NOT_FOUND_STRUCTURE) {
 		if (info->kernel_version >= KERNEL_VERSION(2, 6, 27))
@@ -2249,6 +2270,9 @@ write_vmcoreinfo_data(void)
 
 	WRITE_NUMBER("PAGE_BUDDY_MAPCOUNT_VALUE", PAGE_BUDDY_MAPCOUNT_VALUE);
 	WRITE_NUMBER("KERNEL_IMAGE_SIZE", KERNEL_IMAGE_SIZE);
+	WRITE_NUMBER("PAGE_OFFSET", page_offset);
+	WRITE_NUMBER("VMALLOC_START", vmalloc_start);
+	WRITE_NUMBER("VMEMMAP_START", vmemmap_start);
 
 	WRITE_NUMBER("HUGETLB_PAGE_DTOR", HUGETLB_PAGE_DTOR);
 
@@ -2595,6 +2619,9 @@ read_vmcoreinfo(void)
 
 	READ_NUMBER("PAGE_BUDDY_MAPCOUNT_VALUE", PAGE_BUDDY_MAPCOUNT_VALUE);
 	READ_NUMBER("KERNEL_IMAGE_SIZE", KERNEL_IMAGE_SIZE);
+	READ_NUMBER("PAGE_OFFSET", page_offset);
+	READ_NUMBER("VMALLOC_START", vmalloc_start);
+	READ_NUMBER("VMEMMAP_START", vmemmap_start);
 
 	READ_NUMBER("HUGETLB_PAGE_DTOR", HUGETLB_PAGE_DTOR);
 
Quoted 8 lines

makedumpfile.c initial(void) · line 3856

Quoted 6 lines
makedumpfile.c +1 -1
@@ -3826,7 +3853,7 @@ initial(void)
 		debug_info = TRUE;
 	}
 
-	info->kernel_version = get_kernel_version(info.release);
+	info->kernel_version = get_kernel_version(info->release);

Why don't you write "info->release" in [PATCH 1/3] ?

Yes, will do.

Thanks for your comments and great suggestions!

Thanks
Baoquan

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#6 lore raw

RE: [PATCH 3/3] makedumpfile: Add support for MM randomization

Quoted 28 lines
Quoted 12 lines
Quoted 12 lines
	/*
	 * On linux-2.6.26, MAX_PHYSMEM_BITS is changed to 44 from 40.
arch/x86_64.c +1 -4
@@ -159,22 +160,13 @@ get_versiondep_info_x86_64(void)
 	else
 		info->max_physmem_bits  = _MAX_PHYSMEM_BITS_2_6_31;
 
-	if (info->kernel_version < KERNEL_VERSION(2, 6, 27))
-		info->page_offset = __PAGE_OFFSET_ORIG;
-	else
-		info->page_offset = __PAGE_OFFSET_2_6_27;
+	info->page_offset = NUMBER(page_offset);
 
Quoted 14 lines

arch/x86_64.c get_versiondep_info_x86_64(void) · line 177

Quoted 11 lines
arch/x86_64.c +0 -11
-	if (info->kernel_version < KERNEL_VERSION(2, 6, 31)) {
-		info->vmalloc_start = VMALLOC_START_ORIG;
-		info->vmalloc_end   = VMALLOC_END_ORIG;
-		info->vmemmap_start = VMEMMAP_START_ORIG;
-		info->vmemmap_end   = VMEMMAP_END_ORIG;
-	} else {
-		info->vmalloc_start = VMALLOC_START_2_6_31;
-		info->vmalloc_end   = VMALLOC_END_2_6_31;
-		info->vmemmap_start = VMEMMAP_START_2_6_31;
-		info->vmemmap_end   = VMEMMAP_END_2_6_31;
-	}

These *_END_* are no longer used, it's better to remove the definitions of them.

Quoted 2 lines

Seems is_vmalloc_addr_x86_64 still needs VMALLOC_END and VMEMMAP_END to make a judgement.

Yes, VMALLOC_END and VMEMMAP_END are necessary, but what I mentioned were VMALLOC_END_ORIG, VMEMMAP_END_ORIG , VMALLOC_END_2_6_31 and VMEMMAP_END_2_6_31. The symbols were used only to initialize info->vmalloc_end and info->vmemmap_end, so they will be unnecessary by this patch.

Quoted 5 lines
Quoted 5 lines

arch/x86_64.c get_versiondep_info_x86_64(void) · line 169

Quoted 5 lines
arch/x86_64.c +5 -0
+
+	info->vmalloc_start = NUMBER(vmalloc_start);
+	info->vmalloc_end   = info->vmalloc_start + VMALLOC_SIZE - 1;
+	info->vmemmap_start = NUMBER(vmemmap_start);
+	info->vmemmap_end   = info->vmemmap_start + VMEMMAP_SIZE - 1;

Thanks,
Atsushi Kumagai

Quoted 87 lines
Quoted 5 lines
Quoted 5 lines
(quoted diff) +0 -0
 	return TRUE;
 }
makedumpfile.c +0 -1
index 2713f8a..6b0c6ab 100644
--- a/makedumpfile.c
Quoted 8 lines

makedumpfile.c get_value_for_old_linux(void) · line 1988

Quoted 6 lines

+++ b/makedumpfile.c

makedumpfile.c +1 -0
@@ -1985,6 +1985,7 @@ get_value_for_old_linux(void)
 			NUMBER(PAGE_BUDDY_MAPCOUNT_VALUE) =
 			PAGE_BUDDY_MAPCOUNT_VALUE_v2_6_39_to_latest_version;
 	}
+	ERRMSG("info->kernel_version=%d\n", info->kernel_version);

Is this just a debug message ?

Yes, sorry for this. Will remove it.

Quoted 25 lines
Quoted 25 lines
makedumpfile.c +17 -0
 #ifdef __x86_64__
 	if (NUMBER(KERNEL_IMAGE_SIZE) == NOT_FOUND_NUMBER) {
 		if (info->kernel_version < KERNEL_VERSION(2, 6, 26))
@@ -1992,6 +1993,26 @@ get_value_for_old_linux(void)
 		else
 			NUMBER(KERNEL_IMAGE_SIZE) = KERNEL_IMAGE_SIZE_2_6_26;
 	}
+	if (NUMBER(page_offset) == NOT_FOUND_NUMBER) {
+		if (info->kernel_version < KERNEL_VERSION(2, 6, 27))
+			NUMBER(page_offset) = __PAGE_OFFSET_ORIG;
+		else
+			NUMBER(page_offset) = __PAGE_OFFSET_2_6_27;
+	}
+	if (NUMBER(vmalloc_start) == NOT_FOUND_NUMBER) {
+		if (info->kernel_version < KERNEL_VERSION(2, 6, 31)) {
+			NUMBER(vmalloc_start) = VMALLOC_START_ORIG;
+		} else {
+			NUMBER(vmalloc_start) = VMALLOC_START_2_6_31;
+		}
+	}
+	if (NUMBER(vmemmap_start) == NOT_FOUND_NUMBER) {
+		if (info->kernel_version < KERNEL_VERSION(2, 6, 31))
+			NUMBER(vmemmap_start) = VMEMMAP_START_ORIG;
+		else
Quoted 8 lines

makedumpfile.c get_value_for_old_linux(void) · line 2015

Quoted 3 lines
makedumpfile.c +3 -0
+			NUMBER(vmemmap_start) = VMEMMAP_START_2_6_31;
+	}
+

(I should have said this when you post the early kaslr patch.) This logic is only for x86_64, I don't like to take it out to here(general pass) with #ifdef. Is there any necessity to write this code here ?

Yes, you are right. I plan to put them into get_versiondep_info_x86_64.

Quoted 24 lines
Quoted 24 lines
makedumpfile.c +6 -0
 #endif
 	if (SIZE(pageflags) == NOT_FOUND_STRUCTURE) {
 		if (info->kernel_version >= KERNEL_VERSION(2, 6, 27))
@@ -2249,6 +2270,9 @@ write_vmcoreinfo_data(void)
 
 	WRITE_NUMBER("PAGE_BUDDY_MAPCOUNT_VALUE", PAGE_BUDDY_MAPCOUNT_VALUE);
 	WRITE_NUMBER("KERNEL_IMAGE_SIZE", KERNEL_IMAGE_SIZE);
+	WRITE_NUMBER("PAGE_OFFSET", page_offset);
+	WRITE_NUMBER("VMALLOC_START", vmalloc_start);
+	WRITE_NUMBER("VMEMMAP_START", vmemmap_start);
 
 	WRITE_NUMBER("HUGETLB_PAGE_DTOR", HUGETLB_PAGE_DTOR);
 
@@ -2595,6 +2619,9 @@ read_vmcoreinfo(void)
 
 	READ_NUMBER("PAGE_BUDDY_MAPCOUNT_VALUE", PAGE_BUDDY_MAPCOUNT_VALUE);
 	READ_NUMBER("KERNEL_IMAGE_SIZE", KERNEL_IMAGE_SIZE);
+	READ_NUMBER("PAGE_OFFSET", page_offset);
+	READ_NUMBER("VMALLOC_START", vmalloc_start);
+	READ_NUMBER("VMEMMAP_START", vmemmap_start);
 
 	READ_NUMBER("HUGETLB_PAGE_DTOR", HUGETLB_PAGE_DTOR);
 
Quoted 8 lines

makedumpfile.c initial(void) · line 3856

Quoted 6 lines
makedumpfile.c +1 -1
@@ -3826,7 +3853,7 @@ initial(void)
 		debug_info = TRUE;
 	}
 
-	info->kernel_version = get_kernel_version(info.release);
+	info->kernel_version = get_kernel_version(info->release);

Why don't you write "info->release" in [PATCH 1/3] ?

Yes, will do.

Thanks for your comments and great suggestions!

Quoted 7 lines

Thanks
Baoquan

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

author
#7 lore raw

Re: [PATCH 3/3] makedumpfile: Add support for MM randomization

Quoted 28 lines · Atsushi Kumagai
Quoted 28 lines
Quoted 26 lines
Quoted 13 lines
	/*
	 * On linux-2.6.26, MAX_PHYSMEM_BITS is changed to 44 from 40.
arch/x86_64.c +1 -5
@@ -159,22 +160,13 @@ get_versiondep_info_x86_64(void)
 	else
 		info->max_physmem_bits  = _MAX_PHYSMEM_BITS_2_6_31;
 
-	if (info->kernel_version < KERNEL_VERSION(2, 6, 27))
-		info->page_offset = __PAGE_OFFSET_ORIG;
-	else
-		info->page_offset = __PAGE_OFFSET_2_6_27;
+	info->page_offset = NUMBER(page_offset);
 
-	if (info->kernel_version < KERNEL_VERSION(2, 6, 31)) {

arch/x86_64.c get_versiondep_info_x86_64(void) · line 177

Quoted 10 lines
arch/x86_64.c +0 -10
-		info->vmalloc_start = VMALLOC_START_ORIG;
-		info->vmalloc_end   = VMALLOC_END_ORIG;
-		info->vmemmap_start = VMEMMAP_START_ORIG;
-		info->vmemmap_end   = VMEMMAP_END_ORIG;
-	} else {
-		info->vmalloc_start = VMALLOC_START_2_6_31;
-		info->vmalloc_end   = VMALLOC_END_2_6_31;
-		info->vmemmap_start = VMEMMAP_START_2_6_31;
-		info->vmemmap_end   = VMEMMAP_END_2_6_31;
-	}

These *_END_* are no longer used, it's better to remove the definitions of them.

Quoted 7 lines
Quoted 2 lines

Seems is_vmalloc_addr_x86_64 still needs VMALLOC_END and VMEMMAP_END to make a judgement.

Yes, VMALLOC_END and VMEMMAP_END are necessary, but what I mentioned were VMALLOC_END_ORIG, VMEMMAP_END_ORIG , VMALLOC_END_2_6_31 and VMEMMAP_END_2_6_31. The symbols were used only to initialize info->vmalloc_end and info->vmemmap_end, so they will be unnecessary by this patch.

Yes, you are right. These unused MACRO definitions need be removed. Thanks for your reviewing.

Thanks
Baoquan

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec