* [PATCH v2 0/3] makedumpfile: Add support of mm randomization
@ 2016-10-06 9:50 Baoquan He
2016-10-06 9:50 ` [PATCH v2 1/3] makedumpfile: Get info->kernel_version from SYMBOL(init_uts_ns) earlier Baoquan He
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Baoquan He @ 2016-10-06 9:50 UTC (permalink / raw)
To: kumagai-atsushi; +Cc: dyoung, kexec, thgarnie, Baoquan He, tonli
This is v2 post.
Because of Thomas's kernel patchset, direct mapping, vmalloc and vmemmap
could have random starting address. They need be exported to VMCOREINFO
and let makedumpfile know this so that makedumpfile can identify these
memory areas correctly.
Below is the kernel patchset from Thomas:
x86/mm: memory area address KASLR
https://lwn.net/Articles/692289/
I have posted a new kernel patchset to export the base of direct mapping,
vmalloc and vmemmap. The subject is:
kexec: Export memory sections virtual addresses to vmcoreinfo
v1->v2:
According to Atsushi's comment, mainly change patch 3/3.
- Remove VMALLOC_END_ORIG, VMEMMAP_END_ORIG , VMALLOC_END_2_6_31
and VMEMMAP_END_2_6_31 since they are not needed anymore.
- Put those number table member value assignment into
get_versiondep_info_x86_64.
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 | 51 ++++++++++++++++++++++++++++++++++-----------------
makedumpfile.c | 33 ++++++++++++++++-----------------
makedumpfile.h | 7 +++----
3 files changed, 53 insertions(+), 38 deletions(-)
--
2.5.5
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/3] makedumpfile: Get info->kernel_version from SYMBOL(init_uts_ns) earlier
2016-10-06 9:50 [PATCH v2 0/3] makedumpfile: Add support of mm randomization Baoquan He
@ 2016-10-06 9:50 ` Baoquan He
2016-10-06 9:50 ` [PATCH v2 2/3] makedumpfile: Move get_versiondep_info calling earlier Baoquan He
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Baoquan He @ 2016-10-06 9:50 UTC (permalink / raw)
To: kumagai-atsushi; +Cc: dyoung, kexec, thgarnie, Baoquan He, tonli
The current code assign value to info->kernel_version in check_release,
this is too late and buggy. Because in check_release(), it needs calling
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 exported "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.
Signed-off-by: Baoquan He <bhe@redhat.com>
---
makedumpfile.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/makedumpfile.c b/makedumpfile.c
index d168dfd..89e1089 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -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;
--
2.5.5
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 2/3] makedumpfile: Move get_versiondep_info calling earlier
2016-10-06 9:50 [PATCH v2 0/3] makedumpfile: Add support of mm randomization Baoquan He
2016-10-06 9:50 ` [PATCH v2 1/3] makedumpfile: Get info->kernel_version from SYMBOL(init_uts_ns) earlier Baoquan He
@ 2016-10-06 9:50 ` Baoquan He
2016-10-06 9:50 ` [PATCH v2 3/3] makedumpfile: Add support for MM randomization Baoquan He
2016-10-06 10:23 ` [PATCH v2 0/3] makedumpfile: Add support of mm randomization Baoquan He
3 siblings, 0 replies; 5+ messages in thread
From: Baoquan He @ 2016-10-06 9:50 UTC (permalink / raw)
To: kumagai-atsushi; +Cc: dyoung, kexec, thgarnie, Baoquan He, tonli
Because is_vmalloc_addr_x86_64 need be called very early, e.g in
readmem(). So we have to move get_versiondep_info calling earlier
to let PAGE_OFFSET/VMALLOC_START/VMEMMAP_START get value before
use them.
Signed-off-by: Baoquan He <bhe@redhat.com>
---
makedumpfile.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/makedumpfile.c b/makedumpfile.c
index 89e1089..e132550 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -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
--
2.5.5
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v2 3/3] makedumpfile: Add support for MM randomization
2016-10-06 9:50 [PATCH v2 0/3] makedumpfile: Add support of mm randomization Baoquan He
2016-10-06 9:50 ` [PATCH v2 1/3] makedumpfile: Get info->kernel_version from SYMBOL(init_uts_ns) earlier Baoquan He
2016-10-06 9:50 ` [PATCH v2 2/3] makedumpfile: Move get_versiondep_info calling earlier Baoquan He
@ 2016-10-06 9:50 ` Baoquan He
2016-10-06 10:23 ` [PATCH v2 0/3] makedumpfile: Add support of mm randomization Baoquan He
3 siblings, 0 replies; 5+ messages in thread
From: Baoquan He @ 2016-10-06 9:50 UTC (permalink / raw)
To: kumagai-atsushi; +Cc: dyoung, kexec, thgarnie, Baoquan He, tonli
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.
Signed-off-by: Baoquan He <bhe@redhat.com>
---
arch/x86_64.c | 51 ++++++++++++++++++++++++++++++++++-----------------
makedumpfile.c | 15 +++++++--------
makedumpfile.h | 7 +++----
3 files changed, 44 insertions(+), 29 deletions(-)
diff --git a/arch/x86_64.c b/arch/x86_64.c
index ddf7be6..1fd193f 100644
--- a/arch/x86_64.c
+++ b/arch/x86_64.c
@@ -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,38 @@ 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;
-
- 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;
+ if (NUMBER(KERNEL_IMAGE_SIZE) == NOT_FOUND_NUMBER) {
+ if (info->kernel_version < KERNEL_VERSION(2, 6, 26))
+ NUMBER(KERNEL_IMAGE_SIZE) = KERNEL_IMAGE_SIZE_ORIG;
+ 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;
+ }
+
+ info->page_offset = NUMBER(page_offset);
+
+ 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;
}
diff --git a/makedumpfile.c b/makedumpfile.c
index e132550..bf990f1 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -1985,14 +1985,7 @@ get_value_for_old_linux(void)
NUMBER(PAGE_BUDDY_MAPCOUNT_VALUE) =
PAGE_BUDDY_MAPCOUNT_VALUE_v2_6_39_to_latest_version;
}
-#ifdef __x86_64__
- if (NUMBER(KERNEL_IMAGE_SIZE) == NOT_FOUND_NUMBER) {
- if (info->kernel_version < KERNEL_VERSION(2, 6, 26))
- NUMBER(KERNEL_IMAGE_SIZE) = KERNEL_IMAGE_SIZE_ORIG;
- else
- NUMBER(KERNEL_IMAGE_SIZE) = KERNEL_IMAGE_SIZE_2_6_26;
- }
-#endif
+
if (SIZE(pageflags) == NOT_FOUND_STRUCTURE) {
if (info->kernel_version >= KERNEL_VERSION(2, 6, 27))
SIZE(pageflags) =
@@ -2249,6 +2242,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 +2591,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);
diff --git a/makedumpfile.h b/makedumpfile.h
index 1814139..17f71a3 100644
--- a/makedumpfile.h
+++ b/makedumpfile.h
@@ -564,13 +564,9 @@ int get_va_bits_arm64(void);
#define VMALLOC_START_ORIG (0xffffc20000000000) /* 2.6.30, or former */
#define VMALLOC_START_2_6_31 (0xffffc90000000000) /* 2.6.31, or later */
-#define VMALLOC_END_ORIG (0xffffe1ffffffffff) /* 2.6.30, or former */
-#define VMALLOC_END_2_6_31 (0xffffe8ffffffffff) /* 2.6.31, or later */
#define VMEMMAP_START_ORIG (0xffffe20000000000) /* 2.6.30, or former */
#define VMEMMAP_START_2_6_31 (0xffffea0000000000) /* 2.6.31, or later */
-#define VMEMMAP_END_ORIG (0xffffe2ffffffffff) /* 2.6.30, or former */
-#define VMEMMAP_END_2_6_31 (0xffffeaffffffffff) /* 2.6.31, or later */
#define __START_KERNEL_map (0xffffffff80000000)
#define KERNEL_IMAGE_SIZE_ORIG (0x0000000008000000) /* 2.6.25, or former */
@@ -1685,6 +1681,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
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2 0/3] makedumpfile: Add support of mm randomization
2016-10-06 9:50 [PATCH v2 0/3] makedumpfile: Add support of mm randomization Baoquan He
` (2 preceding siblings ...)
2016-10-06 9:50 ` [PATCH v2 3/3] makedumpfile: Add support for MM randomization Baoquan He
@ 2016-10-06 10:23 ` Baoquan He
3 siblings, 0 replies; 5+ messages in thread
From: Baoquan He @ 2016-10-06 10:23 UTC (permalink / raw)
To: ats-kumagai; +Cc: dyoung, kexec, thgarnie, tonli
Oops, I just sent to Atsushi's old mail. Sorry about this!
On 10/06/16 at 05:50pm, Baoquan He wrote:
> This is v2 post.
>
> Because of Thomas's kernel patchset, direct mapping, vmalloc and vmemmap
> could have random starting address. They need be exported to VMCOREINFO
> and let makedumpfile know this so that makedumpfile can identify these
> memory areas correctly.
>
> Below is the kernel patchset from Thomas:
> x86/mm: memory area address KASLR
> https://lwn.net/Articles/692289/
>
> I have posted a new kernel patchset to export the base of direct mapping,
> vmalloc and vmemmap. The subject is:
> kexec: Export memory sections virtual addresses to vmcoreinfo
>
> v1->v2:
> According to Atsushi's comment, mainly change patch 3/3.
> - Remove VMALLOC_END_ORIG, VMEMMAP_END_ORIG , VMALLOC_END_2_6_31
> and VMEMMAP_END_2_6_31 since they are not needed anymore.
> - Put those number table member value assignment into
> get_versiondep_info_x86_64.
>
> 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 | 51 ++++++++++++++++++++++++++++++++++-----------------
> makedumpfile.c | 33 ++++++++++++++++-----------------
> makedumpfile.h | 7 +++----
> 3 files changed, 53 insertions(+), 38 deletions(-)
>
> --
> 2.5.5
>
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-10-06 10:24 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-06 9:50 [PATCH v2 0/3] makedumpfile: Add support of mm randomization Baoquan He
2016-10-06 9:50 ` [PATCH v2 1/3] makedumpfile: Get info->kernel_version from SYMBOL(init_uts_ns) earlier Baoquan He
2016-10-06 9:50 ` [PATCH v2 2/3] makedumpfile: Move get_versiondep_info calling earlier Baoquan He
2016-10-06 9:50 ` [PATCH v2 3/3] makedumpfile: Add support for MM randomization Baoquan He
2016-10-06 10:23 ` [PATCH v2 0/3] makedumpfile: Add support of mm randomization Baoquan He
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.