[PATCH v4] Fix "log" command when crash is started with "--minimal" option
by Dave Wysochanski
Commit c86250bce29f introduced the useful '-T' option to print the
log timestamp in human-readable form. However, this option does
not work when crash is invoked with '--minimal' mode, and if tried,
crash will spin at 100% and continuously crash at a divide by 0
because machdep->hz == 0.
Fix this by disallowing this option in minimal mode. In addition,
only calculate the logic to calculate kt->boot_date.tv_sec
when this option is enabled.
Fixes: c86250bce29f ("Introduction of the "log -T" option...")
Signed-off-by: Dave Wysochanski <dwysocha(a)redhat.com>
Reviewed-by: Wang Long <w(a)laoqinren.net>
Tested-by: Mathias Krause <minipli(a)grsecurity.net>
Reviewed-by: Lianbo Jiang <lijiang(a)redhat.com>
---
kernel.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/kernel.c b/kernel.c
index 5ed6021..9aa1d4d 100644
--- a/kernel.c
+++ b/kernel.c
@@ -4939,13 +4939,20 @@ cmd_log(void)
if (argerrs)
cmd_usage(pc->curcmd, SYNOPSIS);
- if (kt->boot_date.tv_sec == 0) {
- ulonglong uptime_jiffies;
- ulong uptime_sec;
- get_uptime(NULL, &uptime_jiffies);
- uptime_sec = (uptime_jiffies)/(ulonglong)machdep->hz;
- kt->boot_date.tv_sec = kt->date.tv_sec - uptime_sec;
- kt->boot_date.tv_nsec = 0;
+ if (msg_flags & SHOW_LOG_CTIME) {
+ if (pc->flags & MINIMAL_MODE) {
+ error(WARNING, "log: option 'T' not available in minimal mode\n");
+ return;
+ }
+
+ if (kt->boot_date.tv_sec == 0) {
+ ulonglong uptime_jiffies;
+ ulong uptime_sec;
+ get_uptime(NULL, &uptime_jiffies);
+ uptime_sec = (uptime_jiffies)/(ulonglong)machdep->hz;
+ kt->boot_date.tv_sec = kt->date.tv_sec - uptime_sec;
+ kt->boot_date.tv_nsec = 0;
+ }
}
if (msg_flags & SHOW_LOG_AUDIT) {
--
2.27.0
4 years, 1 month
Re: [Crash-utility] [PATCH v3] Fix "log" command when crash is, started with "--minimal" option
by lijiang
在 2020年08月16日 00:00, crash-utility-request(a)redhat.com 写道:
> Send Crash-utility mailing list submissions to
> crash-utility(a)redhat.com
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://www.redhat.com/mailman/listinfo/crash-utility
> or, via email, send a message with subject or body 'help' to
> crash-utility-request(a)redhat.com
>
> You can reach the person managing the list at
> crash-utility-owner(a)redhat.com
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Crash-utility digest..."
>
>
> Today's Topics:
>
> 1. Re: Crash-utility Digest, Vol 179, Issue 4 (David Wysochanski)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sat, 15 Aug 2020 04:45:49 -0400
> From: David Wysochanski <dwysocha(a)redhat.com>
> To: HAGIO KAZUHITO(?? ??) <k-hagio-ab(a)nec.com>
> Cc: lijiang <lijiang(a)redhat.com>, "Discussion list for crash utility
> usage, maintenance and development" <crash-utility(a)redhat.com>
> Subject: Re: [Crash-utility] Crash-utility Digest, Vol 179, Issue 4
> Message-ID:
> <CALF+zOkMQoyDn8cP5fBpMrrusvcqytMUW+tzs=npKUWwG=nH1g(a)mail.gmail.com>
> Content-Type: text/plain; charset="UTF-8"
>
> On Thu, Aug 13, 2020 at 8:47 PM HAGIO KAZUHITO(?????)
> <k-hagio-ab(a)nec.com> wrote:
>>
>> -----Original Message-----
>>> From: crash-utility-bounces(a)redhat.com <crash-utility-bounces(a)redhat.com> On Behalf Of lijiang
>>> Sent: Friday, August 14, 2020 8:31 AM
>>> To: David Wysochanski <dwysocha(a)redhat.com>
>>> Cc: Discussion list for crash utility usage, maintenance and development <crash-utility(a)redhat.com>
>>> Subject: Re: [Crash-utility] Crash-utility Digest, Vol 179, Issue 4
>>>
>>> ? 2020?08?13? 22:58, David Wysochanski ??:
>>>> On Thu, Aug 13, 2020 at 9:08 AM lijiang <lijiang(a)redhat.com> wrote:
>>>>>
>>>>> ? 2020?08?13? 16:33, David Wysochanski ??:
>>>>>> Hi Lianbo
>>>>>>
>>>>>> On Sat, Aug 8, 2020 at 10:46 PM lijiang <lijiang(a)redhat.com> wrote:
>>>>>>>
>>>>>>> ? 2020?08?07? 00:00, crash-utility-request(a)redhat.com ??:
>>>>>>>> Message: 5
>>>>>>>> Date: Thu, 6 Aug 2020 09:30:22 -0400
>>>>>>>> From: Dave Wysochanski <dwysocha(a)redhat.com>
>>>>>>>> To: crash-utility(a)redhat.com
>>>>>>>> Subject: [Crash-utility] [PATCH v3] Fix "log" command when crash is
>>>>>>>> started with "--minimal" option
>>>>>>>> Message-ID: <20200806133022.2127538-1-dwysocha(a)redhat.com>
>>>>>>>>
>>>>>>>> Commit c86250bce29f introduced the useful '-T' option to print the
>>>>>>>> log timestamp in human-readable form. However, this option does
>>>>>>>> not work when crash is invoked with '--minimal' mode, and if tried,
>>>>>>>> crash will spin at 100% and continuously crash at a divide by 0
>>>>>>>> because machdep->hz == 0.
>>>>>>>>
>>>>>>>> Fix this by disallowing this option in minimal mode. In addition,
>>>>>>>> only calculate the logic to calculate kt->boot_date.tv_sec
>>>>>>>> when this option is enabled.
>>>>>>>>
>>>>>>> Hi, Dave Wysochanski
>>>>>>>
>>>>>>> Thank you for the patch.
>>>>>>>
>>>>>>>> Fixes: c86250bce29f ("Introduction of the "log -T" option...")
>>>>>>>> Signed-off-by: Dave Wysochanski <dwysocha(a)redhat.com>
>>>>>>>> Reviewed-by: Wang Long <w(a)laoqinren.net>
>>>>>>>> Tested-by: Mathias Krause <minipli(a)grsecurity.net>
>>>>>>>> ---
>>>>>>>> kernel.c | 5 ++++-
>>>>>>>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>>>>>>>
>>>>>>>> diff --git a/kernel.c b/kernel.c
>>>>>>>> index 5ed6021..95119f3 100644
>>>>>>>> --- a/kernel.c
>>>>>>>> +++ b/kernel.c
>>>>>>>> @@ -4939,7 +4939,10 @@ cmd_log(void)
>>>>>>>> if (argerrs)
>>>>>>>> cmd_usage(pc->curcmd, SYNOPSIS);
>>>>>>>>
>>>>>>>> - if (kt->boot_date.tv_sec == 0) {
>>>>>>>> + if (msg_flags & SHOW_LOG_CTIME && pc->flags & MINIMAL_MODE)
>>>>>>>> + error(FATAL, "log: option 'T' not available in minimal mode\n");
>>>>>>>> +
>>>>>>>> + if (msg_flags & SHOW_LOG_CTIME && kt->boot_date.tv_sec == 0) {
>>>>>>>
>>>>>>> The above two 'if' statements have the same checking condition, would you mind putting them together
>>>>>>> as a statement block? E.g:
>>>>>>>
>>>>>> Sure I can resubmit a fixup of v4 patch once there are no more changes needed.
>>>>>>
>>>>>>> + if (msg_flags & SHOW_LOG_CTIME) {
>>>>>>> + if (pc->flags & MINIMAL_MODE) {
>>>>>>> + error(WARNING, "the option '-T' not available in minimal mode\n");
>>>>>>> + return;
>>>>>>> + }
>>>>>>> +
>>>>>>> + if (kt->boot_date.tv_sec == 0) {
>>>>>>> ...
>>>>>>> + }
>>>>>>> }
>>>>>>>
>>>>>>> In addition, might it be more reasonable to issue a warning instead of a fatal error?
>>>>>>>
>>>>>>
>>>>>> If you use WARNING it will not fix the infinite loop / CPU spin at
>>>>>> 100%. You have to CTRL-C the crash program to get the prompt back.
>>>>>> So I do not think this is a good idea.
>>>>>>
>>>>> How did you reproduce it? Can you help to confirm if you have applied the correct patch
>>>>> as below?
>>>>>
>>>>> [root@intel-sharkbay-mb-03 crash]# git diff kernel.c
>>>>> diff --git a/kernel.c b/kernel.c
>>>>> index 5ed6021..6375b24 100644
>>>>> --- a/kernel.c
>>>>> +++ b/kernel.c
>>>>> @@ -4939,13 +4939,20 @@ cmd_log(void)
>>>>> if (argerrs)
>>>>> cmd_usage(pc->curcmd, SYNOPSIS);
>>>>>
>>>>> - if (kt->boot_date.tv_sec == 0) {
>>>>> - ulonglong uptime_jiffies;
>>>>> - ulong uptime_sec;
>>>>> - get_uptime(NULL, &uptime_jiffies);
>>>>> - uptime_sec = (uptime_jiffies)/(ulonglong)machdep->hz;
>>>>> - kt->boot_date.tv_sec = kt->date.tv_sec - uptime_sec;
>>>>> - kt->boot_date.tv_nsec = 0;
>>>>> + if (msg_flags & SHOW_LOG_CTIME) {
>>>>> + if (pc->flags & MINIMAL_MODE) {
>>>>> + error(WARNING, "the option '-T' not available in minimal mode\n");
>>>>> + return;
>>>>> + }
>>>>> +
>>>>> + if (kt->boot_date.tv_sec == 0) {
>>>>> + ulonglong uptime_jiffies;
>>>>> + ulong uptime_sec;
>>>>> + get_uptime(NULL, &uptime_jiffies);
>>>>> + uptime_sec = (uptime_jiffies)/(ulonglong)machdep->hz;
>>>>> + kt->boot_date.tv_sec = kt->date.tv_sec - uptime_sec;
>>>>> + kt->boot_date.tv_nsec = 0;
>>>>> + }
>>>>> }
>>>>>
>>>>> if (msg_flags & SHOW_LOG_AUDIT) {
>>>>>
>>>>>
>>>>> I didn't see any problems, it's strange, this is my test steps.
>>>>>
>>>>
>>>> You are right - I missed the 'return;' in your patch. The WARNING is fine.
>>>>
>>> Thanks for your confirmation.
>>>
>>>> How do you want to handle this? Do you want to take the original header
>>>> and add your signed-off-by line and commit your patch? Or do you want
>>>> me to resubmit with review-by or signed-off-by lines?
>>>>
>>> No, please do not add my signed-off-by and review-by line.
>>>
>>> If you and Kazu have no objection, you could post it again with the above changes.
>>
>> No objection. I can ack a new one with the above change.
>>
>
> I would suggest taking the v3 patch as is because Lianbo has said not
> to add his signed-off-by line because I did not write that portion. I'm not
> going to modify something written by someone else and omit where it
> came from.
>
Hi, David
Sorry for the misunderstanding, I don't oppose to adding my signature, but, I just think
that, maybe it doesn't make sense to add my signature.
If you like the improvement suggestions, can you please post it again with or without
my signature?
Crash utility really needs the fix ASAP. :-)
Thanks.
Lianbo
> Thanks!
>
>
>> Thanks,
>> Kazu
>>
>>> Otherwise Kazu can help to merge your last patch, because it can also work.
>>>
>>> Thanks.
>>> Lianbo
>>>
>>> --
>>> Crash-utility mailing list
>>> Crash-utility(a)redhat.com
>>> https://www.redhat.com/mailman/listinfo/crash-utility
>
>
>
>
> ------------------------------
>
> --
> Crash-utility mailing list
> Crash-utility(a)redhat.com
> https://www.redhat.com/mailman/listinfo/crash-utility
>
> End of Crash-utility Digest, Vol 179, Issue 19
> **********************************************
>
4 years, 1 month
Re: [Crash-utility] Crash-utility Digest, Vol 179, Issue 4
by lijiang
在 2020年08月07日 00:00, crash-utility-request(a)redhat.com 写道:
> Message: 5
> Date: Thu, 6 Aug 2020 09:30:22 -0400
> From: Dave Wysochanski <dwysocha(a)redhat.com>
> To: crash-utility(a)redhat.com
> Subject: [Crash-utility] [PATCH v3] Fix "log" command when crash is
> started with "--minimal" option
> Message-ID: <20200806133022.2127538-1-dwysocha(a)redhat.com>
>
> Commit c86250bce29f introduced the useful '-T' option to print the
> log timestamp in human-readable form. However, this option does
> not work when crash is invoked with '--minimal' mode, and if tried,
> crash will spin at 100% and continuously crash at a divide by 0
> because machdep->hz == 0.
>
> Fix this by disallowing this option in minimal mode. In addition,
> only calculate the logic to calculate kt->boot_date.tv_sec
> when this option is enabled.
>
Hi, Dave Wysochanski
Thank you for the patch.
> Fixes: c86250bce29f ("Introduction of the "log -T" option...")
> Signed-off-by: Dave Wysochanski <dwysocha(a)redhat.com>
> Reviewed-by: Wang Long <w(a)laoqinren.net>
> Tested-by: Mathias Krause <minipli(a)grsecurity.net>
> ---
> kernel.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/kernel.c b/kernel.c
> index 5ed6021..95119f3 100644
> --- a/kernel.c
> +++ b/kernel.c
> @@ -4939,7 +4939,10 @@ cmd_log(void)
> if (argerrs)
> cmd_usage(pc->curcmd, SYNOPSIS);
>
> - if (kt->boot_date.tv_sec == 0) {
> + if (msg_flags & SHOW_LOG_CTIME && pc->flags & MINIMAL_MODE)
> + error(FATAL, "log: option 'T' not available in minimal mode\n");
> +
> + if (msg_flags & SHOW_LOG_CTIME && kt->boot_date.tv_sec == 0) {
The above two 'if' statements have the same checking condition, would you mind putting them together
as a statement block? E.g:
+ if (msg_flags & SHOW_LOG_CTIME) {
+ if (pc->flags & MINIMAL_MODE) {
+ error(WARNING, "the option '-T' not available in minimal mode\n");
+ return;
+ }
+
+ if (kt->boot_date.tv_sec == 0) {
...
+ }
}
In addition, might it be more reasonable to issue a warning instead of a fatal error?
Thanks.
Lianbo
> ulonglong uptime_jiffies;
> ulong uptime_sec;
> get_uptime(NULL, &uptime_jiffies);
> -- 2.27.0
4 years, 1 month
[PATCH 1/2] s390dbf: remove raw-view from s390dbf
by Mikhail Zaslonko
With kernel commit ecb1ff6833 "s390/debug: remove raw view" the raw-view
is no longer supported by s390 debug feature.
Since there has never been a single user of the raw-view, remove it from
crash as well.
Signed-off-by: Mikhail Zaslonko <zaslonko(a)linux.ibm.com>
---
s390dbf.c | 42 ------------------------------------------
1 file changed, 42 deletions(-)
diff --git a/s390dbf.c b/s390dbf.c
index f21cd3a..232ceb8 100644
--- a/s390dbf.c
+++ b/s390dbf.c
@@ -378,40 +378,6 @@ dflt_header_fn(debug_info_t * id, debug_view_t *view,
return rc;
}
-/*
- * prints debug header in raw format
- */
-static int
-raw_header_fn(debug_info_t * id, debug_view_t *view,
- int area, debug_entry_t * entry, char *out_buf)
-{
- int rc;
-
- rc = sizeof(debug_entry_t);
- if (out_buf == NULL)
- goto out;
- memcpy(out_buf,entry,sizeof(debug_entry_t));
- out:
- return rc;
-}
-
-/*
- * prints debug data in raw format
- */
-static int
-raw_format_fn(debug_info_t * id, debug_view_t *view,
- char *out_buf, const char *in_buf)
-{
- int rc;
-
- rc = id->buf_size;
- if (out_buf == NULL || in_buf == NULL)
- goto out;
- memcpy(out_buf, in_buf, id->buf_size);
- out:
- return rc;
-}
-
/*
* prints debug data in hex/ascii format
*/
@@ -682,13 +648,6 @@ debug_view_t pages_view = {
NULL,
};
-debug_view_t raw_view = {
- "raw",
- NULL,
- &raw_header_fn,
- &raw_format_fn,
-};
-
debug_view_t hex_ascii_view = {
"hex_ascii",
&prolog_fn,
@@ -899,7 +858,6 @@ dbf_init(void)
add_lcrash_debug_view(&hex_view);
add_lcrash_debug_view(&hex_ascii_view);
add_lcrash_debug_view(&sprintf_view);
- add_lcrash_debug_view(&raw_view);
ebcdic_ascii_conv = iconv_open("ISO-8859-1", "EBCDIC-US");
initialized = 1;
}
--
2.17.1
4 years, 1 month
Re: [Crash-utility] - [PATCH v2 2/3] vmware: vmss beautify and extend debug log
by HAGIO KAZUHITO(萩尾 一仁)
Hi Mathias,
-----Original Message-----
> The parser's debug log is missing a few line breaks as well as some
> crucial information, like control register dumps.
>
> Add them for read- and debugability.
>
> Signed-off-by: Mathias Krause <minipli(a)grsecurity.net>
> ---
> vmware_vmss.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/vmware_vmss.c b/vmware_vmss.c
> index 11b7b72bf503..2eee36c3daec 100644
> --- a/vmware_vmss.c
> +++ b/vmware_vmss.c
> @@ -175,8 +175,10 @@ vmware_vmss_init(char *filename, FILE *ofp)
> }
> DEBUG_PARSE_PRINT((ofp, "[%d]", idx[j]));
> }
> - if (nextgroup)
> + if (nextgroup) {
> + DEBUG_PARSE_PRINT((ofp, "\n"));
> break;
> + }
>
> if (IS_BLOCK_TAG(tag)) {
> uint64_t nbytes;
> @@ -232,16 +234,21 @@ vmware_vmss_init(char *filename, FILE *ofp)
> filename, errno, strerror(errno));
> break;
> }
> + DEBUG_PARSE_PRINT((ofp, "\n"));
> vmss.vcpu_regs[cpu] |= REGS_PRESENT_GPREGS;
> } else if (strcmp(name, "CR64") == 0 &&
> nbytes == VMW_CR64_SIZE &&
> idx[0] < vmss.num_vcpus) {
> int cpu = idx[0];
> + DEBUG_PARSE_PRINT((ofp, "\t=> "));
> if (fread(&vmss.regs64[cpu]->cr[0], VMW_CR64_SIZE, 1, fp) != 1) {
> error(INFO, LOGPRX"Failed to read '%s': [Error %d] %s\n",
> filename, errno, strerror(errno));
> break;
> }
> + for (j = 0; j < VMW_CR64_SIZE / 8; j++)
> + DEBUG_PARSE_PRINT((ofp, "%s%016llX", j ? " " : "",
> vmss.regs64[cpu]->cr[j]));
This warning is emitted.
$ make warn
...
cc -c -g -DX86_64 -DSNAPPY -DLZO -DGDB_7_6 vmware_vmss.c -Wall -O2 -Wstrict-prototypes -Wmissing-prototypes -fstack-protector -Wformat-security
vmware_vmss.c: In function ‘vmware_vmss_init’:
vmware_vmss.c:250:7: warning: format ‘%llX’ expects argument of type ‘long long unsigned int’, but argument 4 has type ‘uint64_t’ [-Wformat=]
DEBUG_PARSE_PRINT((ofp, "%s%016llX", j ? " " : "", vmss.regs64[cpu]->cr[j]));
^
I'll fix when merging.
- DEBUG_PARSE_PRINT((ofp, "%s%016llX", j ? " " : "", vmss.regs64[cpu]->cr[j]));
+ DEBUG_PARSE_PRINT((ofp, "%s%016llX", j ? " " : "",
+ (ulonglong)vmss.regs64[cpu]->cr[j]));
Thanks,
Kazu
> + DEBUG_PARSE_PRINT((ofp, "\n"));
> vmss.vcpu_regs[cpu] |= REGS_PRESENT_CRS;
> } else if (strcmp(name, "IDTR") == 0 &&
> nbytes == VMW_IDTR_SIZE &&
> @@ -258,6 +265,7 @@ vmware_vmss_init(char *filename, FILE *ofp)
> filename, errno, strerror(errno));
> break;
> }
> + DEBUG_PARSE_PRINT((ofp, "\n"));
> vmss.regs64[cpu]->idtr = idtr;
> vmss.vcpu_regs[cpu] |= REGS_PRESENT_IDTR;
> } else {
> @@ -266,6 +274,7 @@ vmware_vmss_init(char *filename, FILE *ofp)
> (ulonglong)(blockpos + nbytes));
> break;
> }
> + DEBUG_PARSE_PRINT((ofp, "\n"));
> }
> } else {
> union {
> --
> 2.20.1
>
>
> --
> Crash-utility mailing list
> Crash-utility(a)redhat.com
> https://www.redhat.com/mailman/listinfo/crash-utility
4 years, 1 month
Re: [Crash-utility] Crash-utility Digest, Vol 179, Issue 9
by lijiang
在 2020年08月11日 16:55, crash-utility-request(a)redhat.com 写道:
> Send Crash-utility mailing list submissions to
> crash-utility(a)redhat.com
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://www.redhat.com/mailman/listinfo/crash-utility
> or, via email, send a message with subject or body 'help' to
> crash-utility-request(a)redhat.com
>
> You can reach the person managing the list at
> crash-utility-owner(a)redhat.com
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Crash-utility digest..."
>
>
> Today's Topics:
>
> 1. Re: Crash-utility Digest, Vol 178, Issue 21 (lijiang)
> 2. Re: Crash-utility Digest, Vol 178, Issue 21 (Mathias Krause)
> 3. Re: Crash-utility Digest, Vol 178, Issue 21 (lijiang)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 11 Aug 2020 10:08:22 +0800
> From: lijiang <lijiang(a)redhat.com>
> To: crash-utility(a)redhat.com
> Subject: Re: [Crash-utility] Crash-utility Digest, Vol 178, Issue 21
> Message-ID: <c712820b-2b84-bfbe-935a-6f5ab4e10c79(a)redhat.com>
> Content-Type: text/plain; charset=utf-8
>
> ? 2020?07?31? 00:00, crash-utility-request(a)redhat.com ??:
>> Message: 1
>> Date: Thu, 30 Jul 2020 15:34:59 +0200
>> From: Mathias Krause <minipli(a)grsecurity.net>
>> To: crash-utility(a)redhat.com
>> Subject: [Crash-utility] [PATCH RESEND] Basic support for PaX's split
>> module layout
>> Message-ID: <20200730133459.7868-1-minipli(a)grsecurity.net>
>> Content-Type: text/plain; charset=US-ASCII
>>
>> PaX and grsecurity kernels split module memory into dedicated r/x and
>> r/w mappings using '*_rw' and '*_rx' named member variables in 'struct
>> module'. To add basic support for such kernels detect the split layout
>> by testing for the corresponding structure members and use these
>> instead.
>>
>> So far we limit ourself to only track module code mappings for such
>> kernels as adding support for separate data mappings violates lots of
>> invariants in the rest of our code base, thereby would require a major
>> rework. However, with that patch applied, module code references can be
>> resolved in backtraces, memory and code dumps, which makes it already
>> very useful for analyzing such kernels.
>>
>> Signed-off-by: Mathias Krause <minipli(a)grsecurity.net>
>> ---
>> Resend as the original posting got stuck in the mail queue.
>>
>> defs.h | 13 +++++++++++
>> kernel.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++----
>> symbols.c | 20 ++++++++--------
>> 3 files changed, 86 insertions(+), 15 deletions(-)
>>
>> diff --git a/defs.h b/defs.h
>> index d7adb23b86d5..160974ed554a 100644
>> --- a/defs.h
>> +++ b/defs.h
>> @@ -654,12 +654,15 @@ struct new_utsname {
>> #define TIMER_BASES (0x20ULL)
>> #define IRQ_DESC_TREE_RADIX (0x40ULL)
>> #define IRQ_DESC_TREE_XARRAY (0x80ULL)
>> +#define KMOD_PAX (0x100ULL)
>>
>> #define XEN() (kt->flags & ARCH_XEN)
>> #define OPENVZ() (kt->flags & ARCH_OPENVZ)
>> #define PVOPS() (kt->flags & ARCH_PVOPS)
>> #define PVOPS_XEN() (kt->flags & ARCH_PVOPS_XEN)
>>
>> +#define PAX_MODULE_SPLIT() (kt->flags2 & KMOD_PAX)
>> +
>> #define XEN_MACHINE_TO_MFN(m) ((ulonglong)(m) >> PAGESHIFT())
>> #define XEN_PFN_TO_PSEUDO(p) ((ulonglong)(p) << PAGESHIFT())
>>
>> @@ -1346,7 +1349,11 @@ struct offset_table { /* stash of commonly-used offsets */
>> long module_gpl_syms;
>> long module_num_gpl_syms;
>> long module_module_core;
>> + long module_module_core_rw;
>> + long module_module_core_rx;
>> long module_core_size;
>> + long module_core_size_rw;
>> + long module_core_size_rx;
>> long module_core_text_size;
>> long module_num_symtab;
>> long module_symtab;
>> @@ -1776,6 +1783,8 @@ struct offset_table { /* stash of commonly-used offsets */
>> long mm_struct_rss_stat;
>> long mm_rss_stat_count;
>> long module_module_init;
>> + long module_module_init_rw;
>> + long module_module_init_rx;
>> long module_init_text_size;
>> long cpu_context_save_fp;
>> long cpu_context_save_sp;
>> @@ -1793,6 +1802,8 @@ struct offset_table { /* stash of commonly-used offsets */
>> long unwind_idx_insn;
>> long signal_struct_nr_threads;
>> long module_init_size;
>> + long module_init_size_rw;
>> + long module_init_size_rx;
>> long module_percpu;
>> long radix_tree_node_slots;
>> long s390_stack_frame_back_chain;
>> @@ -2313,6 +2324,8 @@ struct array_table {
>> * in the offset table, size table or array_table.
>> */
Hi, Mathias
I just know the details of the offset_table from Dave Anderson. The above changes will
break the extension modules that have been previously compiled, because the OFFSET()
values will be different.
Would you mind correcting it and putting the new entries at end of the offset_table?
In addition, can you help to add the new entries to the dump_offset_table()?
Sorry for this.
Thanks.
Lianbo
>> #define OFFSET(X) (OFFSET_verify(offset_table.X, (char *)__FUNCTION__, __FILE__, __LINE__, #X))
>> +#define MODULE_OFFSET(X,Y) (PAX_MODULE_SPLIT() ? OFFSET(Y) : OFFSET(X))
>> +#define MODULE_OFFSET2(X,T) MODULE_OFFSET(X, X##_##T)
> The above definition has a code style issue(space required after that ','), but we could correct
> it when this patch is applied.
>
> Otherwise, it looks good to me.
> Acked-by: Lianbo Jiang <lijiang(a)redhat.com>
>
> Thanks.
> Lianbo
>
>> #define SIZE(X) (SIZE_verify(size_table.X, (char *)__FUNCTION__, __FILE__, __LINE__, #X))
>> #define INVALID_OFFSET (-1)
>> #define INVALID_MEMBER(X) (offset_table.X == INVALID_OFFSET)
>> diff --git a/kernel.c b/kernel.c
>> index 5ed602108b87..c2b8e0a04a26 100644
>> --- a/kernel.c
>> +++ b/kernel.c
>> @@ -3540,6 +3540,62 @@ module_init(void)
>> "module_core");
>> MEMBER_OFFSET_INIT(module_module_init, "module",
>> "module_init");
>> + } else if (MEMBER_EXISTS("module", "module_core_rx")) {
>> + if (CRASHDEBUG(1))
>> + error(INFO, "PaX module layout detected.\n");
>> + kt->flags2 |= KMOD_PAX;
>> +
>> + MEMBER_OFFSET_INIT(module_core_size_rw, "module",
>> + "core_size_rw");
>> + MEMBER_OFFSET_INIT(module_core_size_rx, "module",
>> + "core_size_rx");
>> +
>> + MEMBER_OFFSET_INIT(module_init_size_rw, "module",
>> + "init_size_rw");
>> + MEMBER_OFFSET_INIT(module_init_size_rx, "module",
>> + "init_size_rx");
>> +
>> + MEMBER_OFFSET_INIT(module_module_core_rw, "module",
>> + "module_core_rw");
>> + MEMBER_OFFSET_INIT(module_module_core_rx, "module",
>> + "module_core_rx");
>> +
>> + MEMBER_OFFSET_INIT(module_module_init_rw, "module",
>> + "module_init_rw");
>> + MEMBER_OFFSET_INIT(module_module_init_rx, "module",
>> + "module_init_rx");
>> + } else if (MEMBER_EXISTS("module_layout", "base_rx")) {
>> + if (CRASHDEBUG(1))
>> + error(INFO, "PaX module layout detected.\n");
>> + kt->flags2 |= KMOD_PAX;
>> +
>> + ASSIGN_OFFSET(module_core_size_rw) =
>> + MEMBER_OFFSET("module", "core_layout") +
>> + MEMBER_OFFSET("module_layout", "size_rw");
>> + ASSIGN_OFFSET(module_core_size_rx) =
>> + MEMBER_OFFSET("module", "core_layout") +
>> + MEMBER_OFFSET("module_layout", "size_rx");
>> +
>> + ASSIGN_OFFSET(module_init_size_rw) =
>> + MEMBER_OFFSET("module", "init_layout") +
>> + MEMBER_OFFSET("module_layout", "size_rw");
>> + ASSIGN_OFFSET(module_init_size_rx) =
>> + MEMBER_OFFSET("module", "init_layout") +
>> + MEMBER_OFFSET("module_layout", "size_rx");
>> +
>> + ASSIGN_OFFSET(module_module_core_rw) =
>> + MEMBER_OFFSET("module", "core_layout") +
>> + MEMBER_OFFSET("module_layout", "base_rw");
>> + ASSIGN_OFFSET(module_module_core_rx) =
>> + MEMBER_OFFSET("module", "core_layout") +
>> + MEMBER_OFFSET("module_layout", "base_rx");
>> +
>> + ASSIGN_OFFSET(module_module_init_rw) =
>> + MEMBER_OFFSET("module", "init_layout") +
>> + MEMBER_OFFSET("module_layout", "base_rw");
>> + ASSIGN_OFFSET(module_module_init_rx) =
>> + MEMBER_OFFSET("module", "init_layout") +
>> + MEMBER_OFFSET("module_layout", "base_rx");
>> } else {
>> ASSIGN_OFFSET(module_core_size) =
>> MEMBER_OFFSET("module", "core_layout") +
>> @@ -3682,10 +3738,10 @@ module_init(void)
>> case KALLSYMS_V2:
>> if (THIS_KERNEL_VERSION >= LINUX(2,6,27)) {
>> numksyms = UINT(modbuf + OFFSET(module_num_symtab));
>> - size = UINT(modbuf + OFFSET(module_core_size));
>> + size = UINT(modbuf + MODULE_OFFSET2(module_core_size, rx));
>> } else {
>> numksyms = ULONG(modbuf + OFFSET(module_num_symtab));
>> - size = ULONG(modbuf + OFFSET(module_core_size));
>> + size = ULONG(modbuf + MODULE_OFFSET2(module_core_size, rx));
>> }
>>
>> if (!size) {
>> @@ -3792,7 +3848,7 @@ verify_modules(void)
>> break;
>> case KMOD_V2:
>> mod_base = ULONG(modbuf +
>> - OFFSET(module_module_core));
>> + MODULE_OFFSET2(module_module_core, rx));
>> break;
>> }
>>
>> @@ -3816,10 +3872,10 @@ verify_modules(void)
>> OFFSET(module_name);
>> if (THIS_KERNEL_VERSION >= LINUX(2,6,27))
>> mod_size = UINT(modbuf +
>> - OFFSET(module_core_size));
>> + MODULE_OFFSET2(module_core_size, rx));
>> else
>> mod_size = ULONG(modbuf +
>> - OFFSET(module_core_size));
>> + MODULE_OFFSET2(module_core_size, rx));
>> if (strlen(module_name) < MAX_MOD_NAME)
>> strcpy(buf, module_name);
>> else
>> @@ -5989,6 +6045,8 @@ dump_kernel_table(int verbose)
>> fprintf(fp, "%sIRQ_DESC_TREE_RADIX", others++ ? "|" : "");
>> if (kt->flags2 & IRQ_DESC_TREE_XARRAY)
>> fprintf(fp, "%sIRQ_DESC_TREE_XARRAY", others++ ? "|" : "");
>> + if (kt->flags2 & KMOD_PAX)
>> + fprintf(fp, "%sKMOD_PAX", others++ ? "|" : "");
>> fprintf(fp, ")\n");
>>
>> fprintf(fp, " stext: %lx\n", kt->stext);
>> diff --git a/symbols.c b/symbols.c
>> index 3b1f08af43ff..be672fcaefd9 100644
>> --- a/symbols.c
>> +++ b/symbols.c
>> @@ -1766,17 +1766,17 @@ store_module_symbols_v2(ulong total, int mods_installed)
>>
>> if (THIS_KERNEL_VERSION >= LINUX(2,6,27)) {
>> nksyms = UINT(modbuf + OFFSET(module_num_symtab));
>> - size = UINT(modbuf + OFFSET(module_core_size));
>> + size = UINT(modbuf + MODULE_OFFSET2(module_core_size, rx));
>> } else {
>> nksyms = ULONG(modbuf + OFFSET(module_num_symtab));
>> - size = ULONG(modbuf + OFFSET(module_core_size));
>> + size = ULONG(modbuf + MODULE_OFFSET2(module_core_size, rx));
>> }
>>
>> mod_name = modbuf + OFFSET(module_name);
>>
>> lm = &st->load_modules[m++];
>> BZERO(lm, sizeof(struct load_module));
>> - lm->mod_base = ULONG(modbuf + OFFSET(module_module_core));
>> + lm->mod_base = ULONG(modbuf + MODULE_OFFSET2(module_module_core, rx));
>> lm->module_struct = mod;
>> lm->mod_size = size;
>> if (strlen(mod_name) < MAX_MOD_NAME)
>> @@ -1795,23 +1795,23 @@ store_module_symbols_v2(ulong total, int mods_installed)
>> lm->mod_flags = MOD_EXT_SYMS;
>> lm->mod_ext_symcnt = mcnt;
>> lm->mod_init_module_ptr = ULONG(modbuf +
>> - OFFSET(module_module_init));
>> + MODULE_OFFSET2(module_module_init, rx));
>> if (VALID_MEMBER(module_percpu))
>> lm->mod_percpu = ULONG(modbuf + OFFSET(module_percpu));
>> if (THIS_KERNEL_VERSION >= LINUX(2,6,27)) {
>> lm->mod_etext_guess = lm->mod_base +
>> - UINT(modbuf + OFFSET(module_core_text_size));
>> + UINT(modbuf + MODULE_OFFSET(module_core_text_size, module_core_size_rx));
>> lm->mod_init_size =
>> - UINT(modbuf + OFFSET(module_init_size));
>> + UINT(modbuf + MODULE_OFFSET2(module_init_size, rx));
>> lm->mod_init_text_size =
>> - UINT(modbuf + OFFSET(module_init_text_size));
>> + UINT(modbuf + MODULE_OFFSET(module_init_text_size, module_init_size_rx));
>> } else {
>> lm->mod_etext_guess = lm->mod_base +
>> - ULONG(modbuf + OFFSET(module_core_text_size));
>> + ULONG(modbuf + MODULE_OFFSET(module_core_text_size, module_core_size_rx));
>> lm->mod_init_size =
>> - ULONG(modbuf + OFFSET(module_init_size));
>> + ULONG(modbuf + MODULE_OFFSET2(module_init_size, rx));
>> lm->mod_init_text_size =
>> - ULONG(modbuf + OFFSET(module_init_text_size));
>> + ULONG(modbuf + MODULE_OFFSET(module_init_text_size, module_init_size_rx));
>> }
>> lm->mod_text_start = lm->mod_base;
>>
>> -- 2.20.1
>
>
>
> ------------------------------
>
> Message: 2
> Date: Tue, 11 Aug 2020 10:23:14 +0200
> From: Mathias Krause <minipli(a)grsecurity.net>
> To: lijiang <lijiang(a)redhat.com>
> Cc: crash-utility(a)redhat.com
> Subject: Re: [Crash-utility] Crash-utility Digest, Vol 178, Issue 21
> Message-ID: <d0c9b41e-379b-58cc-c457-e06b59eae9af(a)grsecurity.net>
> Content-Type: text/plain; charset=utf-8
>
> Hi Lianbo,
>
> Am 11.08.20 um 04:08 schrieb lijiang:
>> ? 2020?07?31? 00:00, crash-utility-request(a)redhat.com ??:
>>> Message: 1
>>> Date: Thu, 30 Jul 2020 15:34:59 +0200
>>> From: Mathias Krause <minipli(a)grsecurity.net>
>>> To: crash-utility(a)redhat.com
>>> Subject: [Crash-utility] [PATCH RESEND] Basic support for PaX's split
>>> module layout
>>> Message-ID: <20200730133459.7868-1-minipli(a)grsecurity.net>
>>> Content-Type: text/plain; charset=US-ASCII
>>>
>>> PaX and grsecurity kernels split module memory into dedicated r/x and
>>> r/w mappings using '*_rw' and '*_rx' named member variables in 'struct
>>> module'. To add basic support for such kernels detect the split layout
>>> by testing for the corresponding structure members and use these
>>> instead.
>>>
>>> So far we limit ourself to only track module code mappings for such
>>> kernels as adding support for separate data mappings violates lots of
>>> invariants in the rest of our code base, thereby would require a major
>>> rework. However, with that patch applied, module code references can be
>>> resolved in backtraces, memory and code dumps, which makes it already
>>> very useful for analyzing such kernels.
>>>
>>> Signed-off-by: Mathias Krause <minipli(a)grsecurity.net>
>>> ---
>>> Resend as the original posting got stuck in the mail queue.
>>>
>>> defs.h | 13 +++++++++++
>>> kernel.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++----
>>> symbols.c | 20 ++++++++--------
>>> 3 files changed, 86 insertions(+), 15 deletions(-)
>>>
>>> diff --git a/defs.h b/defs.h
>>> index d7adb23b86d5..160974ed554a 100644
>>> --- a/defs.h
>>> +++ b/defs.h
>>> @@ -654,12 +654,15 @@ struct new_utsname {
>>> #define TIMER_BASES (0x20ULL)
>>> #define IRQ_DESC_TREE_RADIX (0x40ULL)
>>> #define IRQ_DESC_TREE_XARRAY (0x80ULL)
>>> +#define KMOD_PAX (0x100ULL)
>>>
>>> #define XEN() (kt->flags & ARCH_XEN)
>>> #define OPENVZ() (kt->flags & ARCH_OPENVZ)
>>> #define PVOPS() (kt->flags & ARCH_PVOPS)
>>> #define PVOPS_XEN() (kt->flags & ARCH_PVOPS_XEN)
>>>
>>> +#define PAX_MODULE_SPLIT() (kt->flags2 & KMOD_PAX)
>>> +
>>> #define XEN_MACHINE_TO_MFN(m) ((ulonglong)(m) >> PAGESHIFT())
>>> #define XEN_PFN_TO_PSEUDO(p) ((ulonglong)(p) << PAGESHIFT())
>>>
>>> @@ -1346,7 +1349,11 @@ struct offset_table { /* stash of commonly-used offsets */
>>> long module_gpl_syms;
>>> long module_num_gpl_syms;
>>> long module_module_core;
>>> + long module_module_core_rw;
>>> + long module_module_core_rx;
>>> long module_core_size;
>>> + long module_core_size_rw;
>>> + long module_core_size_rx;
>>> long module_core_text_size;
>>> long module_num_symtab;
>>> long module_symtab;
>>> @@ -1776,6 +1783,8 @@ struct offset_table { /* stash of commonly-used offsets */
>>> long mm_struct_rss_stat;
>>> long mm_rss_stat_count;
>>> long module_module_init;
>>> + long module_module_init_rw;
>>> + long module_module_init_rx;
>>> long module_init_text_size;
>>> long cpu_context_save_fp;
>>> long cpu_context_save_sp;
>>> @@ -1793,6 +1802,8 @@ struct offset_table { /* stash of commonly-used offsets */
>>> long unwind_idx_insn;
>>> long signal_struct_nr_threads;
>>> long module_init_size;
>>> + long module_init_size_rw;
>>> + long module_init_size_rx;
>>> long module_percpu;
>>> long radix_tree_node_slots;
>>> long s390_stack_frame_back_chain;
>>> @@ -2313,6 +2324,8 @@ struct array_table {
>>> * in the offset table, size table or array_table.
>>> */
>>> #define OFFSET(X) (OFFSET_verify(offset_table.X, (char *)__FUNCTION__, __FILE__, __LINE__, #X))
>>> +#define MODULE_OFFSET(X,Y) (PAX_MODULE_SPLIT() ? OFFSET(Y) : OFFSET(X))
>>> +#define MODULE_OFFSET2(X,T) MODULE_OFFSET(X, X##_##T)
>> The above definition has a code style issue(space required after that ','), but we could correct
>> it when this patch is applied.
>
> I just wanted to stick with the coding style nearby, like with
> MEMBER_OFFSET(), MEMBER_EXISTS(), MEMBER_SIZE(), etc. all have no space
> between the arguments. But I've no strong opinion about it. Feel free to
> adapt.
>
>>
>> Otherwise, it looks good to me.
>> Acked-by: Lianbo Jiang <lijiang(a)redhat.com>
>
> Thanks for the review!
>
> Mathias
>
>>
>> Thanks.
>> Lianbo
>>
>>> [...]
>
>
>
>
> ------------------------------
>
> Message: 3
> Date: Tue, 11 Aug 2020 16:55:42 +0800
> From: lijiang <lijiang(a)redhat.com>
> To: Mathias Krause <minipli(a)grsecurity.net>
> Cc: crash-utility(a)redhat.com
> Subject: Re: [Crash-utility] Crash-utility Digest, Vol 178, Issue 21
> Message-ID: <87316ee3-adf9-7126-1ce6-5276a363bc4a(a)redhat.com>
> Content-Type: text/plain; charset=utf-8
>
> ? 2020?08?11? 16:23, Mathias Krause ??:
>> Hi Lianbo,
>>
>> Am 11.08.20 um 04:08 schrieb lijiang:
>>> ? 2020?07?31? 00:00, crash-utility-request(a)redhat.com ??:
>>>> Message: 1
>>>> Date: Thu, 30 Jul 2020 15:34:59 +0200
>>>> From: Mathias Krause <minipli(a)grsecurity.net>
>>>> To: crash-utility(a)redhat.com
>>>> Subject: [Crash-utility] [PATCH RESEND] Basic support for PaX's split
>>>> module layout
>>>> Message-ID: <20200730133459.7868-1-minipli(a)grsecurity.net>
>>>> Content-Type: text/plain; charset=US-ASCII
>>>>
>>>> PaX and grsecurity kernels split module memory into dedicated r/x and
>>>> r/w mappings using '*_rw' and '*_rx' named member variables in 'struct
>>>> module'. To add basic support for such kernels detect the split layout
>>>> by testing for the corresponding structure members and use these
>>>> instead.
>>>>
>>>> So far we limit ourself to only track module code mappings for such
>>>> kernels as adding support for separate data mappings violates lots of
>>>> invariants in the rest of our code base, thereby would require a major
>>>> rework. However, with that patch applied, module code references can be
>>>> resolved in backtraces, memory and code dumps, which makes it already
>>>> very useful for analyzing such kernels.
>>>>
>>>> Signed-off-by: Mathias Krause <minipli(a)grsecurity.net>
>>>> ---
>>>> Resend as the original posting got stuck in the mail queue.
>>>>
>>>> defs.h | 13 +++++++++++
>>>> kernel.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++----
>>>> symbols.c | 20 ++++++++--------
>>>> 3 files changed, 86 insertions(+), 15 deletions(-)
>>>>
>>>> diff --git a/defs.h b/defs.h
>>>> index d7adb23b86d5..160974ed554a 100644
>>>> --- a/defs.h
>>>> +++ b/defs.h
>>>> @@ -654,12 +654,15 @@ struct new_utsname {
>>>> #define TIMER_BASES (0x20ULL)
>>>> #define IRQ_DESC_TREE_RADIX (0x40ULL)
>>>> #define IRQ_DESC_TREE_XARRAY (0x80ULL)
>>>> +#define KMOD_PAX (0x100ULL)
>>>>
>>>> #define XEN() (kt->flags & ARCH_XEN)
>>>> #define OPENVZ() (kt->flags & ARCH_OPENVZ)
>>>> #define PVOPS() (kt->flags & ARCH_PVOPS)
>>>> #define PVOPS_XEN() (kt->flags & ARCH_PVOPS_XEN)
>>>>
>>>> +#define PAX_MODULE_SPLIT() (kt->flags2 & KMOD_PAX)
>>>> +
>>>> #define XEN_MACHINE_TO_MFN(m) ((ulonglong)(m) >> PAGESHIFT())
>>>> #define XEN_PFN_TO_PSEUDO(p) ((ulonglong)(p) << PAGESHIFT())
>>>>
>>>> @@ -1346,7 +1349,11 @@ struct offset_table { /* stash of commonly-used offsets */
>>>> long module_gpl_syms;
>>>> long module_num_gpl_syms;
>>>> long module_module_core;
>>>> + long module_module_core_rw;
>>>> + long module_module_core_rx;
>>>> long module_core_size;
>>>> + long module_core_size_rw;
>>>> + long module_core_size_rx;
>>>> long module_core_text_size;
>>>> long module_num_symtab;
>>>> long module_symtab;
>>>> @@ -1776,6 +1783,8 @@ struct offset_table { /* stash of commonly-used offsets */
>>>> long mm_struct_rss_stat;
>>>> long mm_rss_stat_count;
>>>> long module_module_init;
>>>> + long module_module_init_rw;
>>>> + long module_module_init_rx;
>>>> long module_init_text_size;
>>>> long cpu_context_save_fp;
>>>> long cpu_context_save_sp;
>>>> @@ -1793,6 +1802,8 @@ struct offset_table { /* stash of commonly-used offsets */
>>>> long unwind_idx_insn;
>>>> long signal_struct_nr_threads;
>>>> long module_init_size;
>>>> + long module_init_size_rw;
>>>> + long module_init_size_rx;
>>>> long module_percpu;
>>>> long radix_tree_node_slots;
>>>> long s390_stack_frame_back_chain;
>>>> @@ -2313,6 +2324,8 @@ struct array_table {
>>>> * in the offset table, size table or array_table.
>>>> */
>>>> #define OFFSET(X) (OFFSET_verify(offset_table.X, (char *)__FUNCTION__, __FILE__, __LINE__, #X))
>>>> +#define MODULE_OFFSET(X,Y) (PAX_MODULE_SPLIT() ? OFFSET(Y) : OFFSET(X))
>>>> +#define MODULE_OFFSET2(X,T) MODULE_OFFSET(X, X##_##T)
>>> The above definition has a code style issue(space required after that ','), but we could correct
>>> it when this patch is applied.
>>
>> I just wanted to stick with the coding style nearby, like with
>> MEMBER_OFFSET(), MEMBER_EXISTS(), MEMBER_SIZE(), etc. all have no space
>
> That's true.
>
>> between the arguments. But I've no strong opinion about it. Feel free to
>> adapt.
>>
> No worry. :-)
>
> Thanks.
> Lianbo
>
>>>
>>> Otherwise, it looks good to me.
>>> Acked-by: Lianbo Jiang <lijiang(a)redhat.com>
>>
>> Thanks for the review!
>>
>> Mathias
>>
>>>
>>> Thanks.
>>> Lianbo
>>>
>>>> [...]
>>
>
>
>
> ------------------------------
>
> --
> Crash-utility mailing list
> Crash-utility(a)redhat.com
> https://www.redhat.com/mailman/listinfo/crash-utility
>
> End of Crash-utility Digest, Vol 179, Issue 9
> *********************************************
>
4 years, 1 month
[PATCH v2 0/3] vmss/core related fixes and enhancements
by Mathias Krause
This small patch series enhances support for VMware vmss dump and core
files by fixing some bugs I ran into.
Version 2 of the series integrates Lianbo's feedback, as in:
- added separate define and comment for 128 byte "padding"
- changed commit message of patch 3 accordingly
- added missing '\n' to warning messages
- fixed whitespace issues
I meanwhile realized that the register dump of patch 2 can also be seen
via 'help -r' but its formating fixes are useful nonetheless.
Please apply!
Thanks,
Mathias
Mathias Krause (3):
vmware: vmss - support huge holes in vmem
vmware: vmss - beautify and extend debug log
Support core files with "unusual" layout
netdump.c | 90 ++++++++++++++++++++++++++++++++++-----------------
netdump.h | 8 +++++
vmware_vmss.c | 17 ++++++++--
3 files changed, 83 insertions(+), 32 deletions(-)
--
2.20.1
4 years, 1 month
Re: [Crash-utility] Crash-utility Digest, Vol 178, Issue 21
by lijiang
在 2020年07月31日 00:00, crash-utility-request(a)redhat.com 写道:
> Message: 1
> Date: Thu, 30 Jul 2020 15:34:59 +0200
> From: Mathias Krause <minipli(a)grsecurity.net>
> To: crash-utility(a)redhat.com
> Subject: [Crash-utility] [PATCH RESEND] Basic support for PaX's split
> module layout
> Message-ID: <20200730133459.7868-1-minipli(a)grsecurity.net>
> Content-Type: text/plain; charset=US-ASCII
>
> PaX and grsecurity kernels split module memory into dedicated r/x and
> r/w mappings using '*_rw' and '*_rx' named member variables in 'struct
> module'. To add basic support for such kernels detect the split layout
> by testing for the corresponding structure members and use these
> instead.
>
> So far we limit ourself to only track module code mappings for such
> kernels as adding support for separate data mappings violates lots of
> invariants in the rest of our code base, thereby would require a major
> rework. However, with that patch applied, module code references can be
> resolved in backtraces, memory and code dumps, which makes it already
> very useful for analyzing such kernels.
>
> Signed-off-by: Mathias Krause <minipli(a)grsecurity.net>
> ---
> Resend as the original posting got stuck in the mail queue.
>
> defs.h | 13 +++++++++++
> kernel.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++----
> symbols.c | 20 ++++++++--------
> 3 files changed, 86 insertions(+), 15 deletions(-)
>
> diff --git a/defs.h b/defs.h
> index d7adb23b86d5..160974ed554a 100644
> --- a/defs.h
> +++ b/defs.h
> @@ -654,12 +654,15 @@ struct new_utsname {
> #define TIMER_BASES (0x20ULL)
> #define IRQ_DESC_TREE_RADIX (0x40ULL)
> #define IRQ_DESC_TREE_XARRAY (0x80ULL)
> +#define KMOD_PAX (0x100ULL)
>
> #define XEN() (kt->flags & ARCH_XEN)
> #define OPENVZ() (kt->flags & ARCH_OPENVZ)
> #define PVOPS() (kt->flags & ARCH_PVOPS)
> #define PVOPS_XEN() (kt->flags & ARCH_PVOPS_XEN)
>
> +#define PAX_MODULE_SPLIT() (kt->flags2 & KMOD_PAX)
> +
> #define XEN_MACHINE_TO_MFN(m) ((ulonglong)(m) >> PAGESHIFT())
> #define XEN_PFN_TO_PSEUDO(p) ((ulonglong)(p) << PAGESHIFT())
>
> @@ -1346,7 +1349,11 @@ struct offset_table { /* stash of commonly-used offsets */
> long module_gpl_syms;
> long module_num_gpl_syms;
> long module_module_core;
> + long module_module_core_rw;
> + long module_module_core_rx;
> long module_core_size;
> + long module_core_size_rw;
> + long module_core_size_rx;
> long module_core_text_size;
> long module_num_symtab;
> long module_symtab;
> @@ -1776,6 +1783,8 @@ struct offset_table { /* stash of commonly-used offsets */
> long mm_struct_rss_stat;
> long mm_rss_stat_count;
> long module_module_init;
> + long module_module_init_rw;
> + long module_module_init_rx;
> long module_init_text_size;
> long cpu_context_save_fp;
> long cpu_context_save_sp;
> @@ -1793,6 +1802,8 @@ struct offset_table { /* stash of commonly-used offsets */
> long unwind_idx_insn;
> long signal_struct_nr_threads;
> long module_init_size;
> + long module_init_size_rw;
> + long module_init_size_rx;
> long module_percpu;
> long radix_tree_node_slots;
> long s390_stack_frame_back_chain;
> @@ -2313,6 +2324,8 @@ struct array_table {
> * in the offset table, size table or array_table.
> */
> #define OFFSET(X) (OFFSET_verify(offset_table.X, (char *)__FUNCTION__, __FILE__, __LINE__, #X))
> +#define MODULE_OFFSET(X,Y) (PAX_MODULE_SPLIT() ? OFFSET(Y) : OFFSET(X))
> +#define MODULE_OFFSET2(X,T) MODULE_OFFSET(X, X##_##T)
The above definition has a code style issue(space required after that ','), but we could correct
it when this patch is applied.
Otherwise, it looks good to me.
Acked-by: Lianbo Jiang <lijiang(a)redhat.com>
Thanks.
Lianbo
> #define SIZE(X) (SIZE_verify(size_table.X, (char *)__FUNCTION__, __FILE__, __LINE__, #X))
> #define INVALID_OFFSET (-1)
> #define INVALID_MEMBER(X) (offset_table.X == INVALID_OFFSET)
> diff --git a/kernel.c b/kernel.c
> index 5ed602108b87..c2b8e0a04a26 100644
> --- a/kernel.c
> +++ b/kernel.c
> @@ -3540,6 +3540,62 @@ module_init(void)
> "module_core");
> MEMBER_OFFSET_INIT(module_module_init, "module",
> "module_init");
> + } else if (MEMBER_EXISTS("module", "module_core_rx")) {
> + if (CRASHDEBUG(1))
> + error(INFO, "PaX module layout detected.\n");
> + kt->flags2 |= KMOD_PAX;
> +
> + MEMBER_OFFSET_INIT(module_core_size_rw, "module",
> + "core_size_rw");
> + MEMBER_OFFSET_INIT(module_core_size_rx, "module",
> + "core_size_rx");
> +
> + MEMBER_OFFSET_INIT(module_init_size_rw, "module",
> + "init_size_rw");
> + MEMBER_OFFSET_INIT(module_init_size_rx, "module",
> + "init_size_rx");
> +
> + MEMBER_OFFSET_INIT(module_module_core_rw, "module",
> + "module_core_rw");
> + MEMBER_OFFSET_INIT(module_module_core_rx, "module",
> + "module_core_rx");
> +
> + MEMBER_OFFSET_INIT(module_module_init_rw, "module",
> + "module_init_rw");
> + MEMBER_OFFSET_INIT(module_module_init_rx, "module",
> + "module_init_rx");
> + } else if (MEMBER_EXISTS("module_layout", "base_rx")) {
> + if (CRASHDEBUG(1))
> + error(INFO, "PaX module layout detected.\n");
> + kt->flags2 |= KMOD_PAX;
> +
> + ASSIGN_OFFSET(module_core_size_rw) =
> + MEMBER_OFFSET("module", "core_layout") +
> + MEMBER_OFFSET("module_layout", "size_rw");
> + ASSIGN_OFFSET(module_core_size_rx) =
> + MEMBER_OFFSET("module", "core_layout") +
> + MEMBER_OFFSET("module_layout", "size_rx");
> +
> + ASSIGN_OFFSET(module_init_size_rw) =
> + MEMBER_OFFSET("module", "init_layout") +
> + MEMBER_OFFSET("module_layout", "size_rw");
> + ASSIGN_OFFSET(module_init_size_rx) =
> + MEMBER_OFFSET("module", "init_layout") +
> + MEMBER_OFFSET("module_layout", "size_rx");
> +
> + ASSIGN_OFFSET(module_module_core_rw) =
> + MEMBER_OFFSET("module", "core_layout") +
> + MEMBER_OFFSET("module_layout", "base_rw");
> + ASSIGN_OFFSET(module_module_core_rx) =
> + MEMBER_OFFSET("module", "core_layout") +
> + MEMBER_OFFSET("module_layout", "base_rx");
> +
> + ASSIGN_OFFSET(module_module_init_rw) =
> + MEMBER_OFFSET("module", "init_layout") +
> + MEMBER_OFFSET("module_layout", "base_rw");
> + ASSIGN_OFFSET(module_module_init_rx) =
> + MEMBER_OFFSET("module", "init_layout") +
> + MEMBER_OFFSET("module_layout", "base_rx");
> } else {
> ASSIGN_OFFSET(module_core_size) =
> MEMBER_OFFSET("module", "core_layout") +
> @@ -3682,10 +3738,10 @@ module_init(void)
> case KALLSYMS_V2:
> if (THIS_KERNEL_VERSION >= LINUX(2,6,27)) {
> numksyms = UINT(modbuf + OFFSET(module_num_symtab));
> - size = UINT(modbuf + OFFSET(module_core_size));
> + size = UINT(modbuf + MODULE_OFFSET2(module_core_size, rx));
> } else {
> numksyms = ULONG(modbuf + OFFSET(module_num_symtab));
> - size = ULONG(modbuf + OFFSET(module_core_size));
> + size = ULONG(modbuf + MODULE_OFFSET2(module_core_size, rx));
> }
>
> if (!size) {
> @@ -3792,7 +3848,7 @@ verify_modules(void)
> break;
> case KMOD_V2:
> mod_base = ULONG(modbuf +
> - OFFSET(module_module_core));
> + MODULE_OFFSET2(module_module_core, rx));
> break;
> }
>
> @@ -3816,10 +3872,10 @@ verify_modules(void)
> OFFSET(module_name);
> if (THIS_KERNEL_VERSION >= LINUX(2,6,27))
> mod_size = UINT(modbuf +
> - OFFSET(module_core_size));
> + MODULE_OFFSET2(module_core_size, rx));
> else
> mod_size = ULONG(modbuf +
> - OFFSET(module_core_size));
> + MODULE_OFFSET2(module_core_size, rx));
> if (strlen(module_name) < MAX_MOD_NAME)
> strcpy(buf, module_name);
> else
> @@ -5989,6 +6045,8 @@ dump_kernel_table(int verbose)
> fprintf(fp, "%sIRQ_DESC_TREE_RADIX", others++ ? "|" : "");
> if (kt->flags2 & IRQ_DESC_TREE_XARRAY)
> fprintf(fp, "%sIRQ_DESC_TREE_XARRAY", others++ ? "|" : "");
> + if (kt->flags2 & KMOD_PAX)
> + fprintf(fp, "%sKMOD_PAX", others++ ? "|" : "");
> fprintf(fp, ")\n");
>
> fprintf(fp, " stext: %lx\n", kt->stext);
> diff --git a/symbols.c b/symbols.c
> index 3b1f08af43ff..be672fcaefd9 100644
> --- a/symbols.c
> +++ b/symbols.c
> @@ -1766,17 +1766,17 @@ store_module_symbols_v2(ulong total, int mods_installed)
>
> if (THIS_KERNEL_VERSION >= LINUX(2,6,27)) {
> nksyms = UINT(modbuf + OFFSET(module_num_symtab));
> - size = UINT(modbuf + OFFSET(module_core_size));
> + size = UINT(modbuf + MODULE_OFFSET2(module_core_size, rx));
> } else {
> nksyms = ULONG(modbuf + OFFSET(module_num_symtab));
> - size = ULONG(modbuf + OFFSET(module_core_size));
> + size = ULONG(modbuf + MODULE_OFFSET2(module_core_size, rx));
> }
>
> mod_name = modbuf + OFFSET(module_name);
>
> lm = &st->load_modules[m++];
> BZERO(lm, sizeof(struct load_module));
> - lm->mod_base = ULONG(modbuf + OFFSET(module_module_core));
> + lm->mod_base = ULONG(modbuf + MODULE_OFFSET2(module_module_core, rx));
> lm->module_struct = mod;
> lm->mod_size = size;
> if (strlen(mod_name) < MAX_MOD_NAME)
> @@ -1795,23 +1795,23 @@ store_module_symbols_v2(ulong total, int mods_installed)
> lm->mod_flags = MOD_EXT_SYMS;
> lm->mod_ext_symcnt = mcnt;
> lm->mod_init_module_ptr = ULONG(modbuf +
> - OFFSET(module_module_init));
> + MODULE_OFFSET2(module_module_init, rx));
> if (VALID_MEMBER(module_percpu))
> lm->mod_percpu = ULONG(modbuf + OFFSET(module_percpu));
> if (THIS_KERNEL_VERSION >= LINUX(2,6,27)) {
> lm->mod_etext_guess = lm->mod_base +
> - UINT(modbuf + OFFSET(module_core_text_size));
> + UINT(modbuf + MODULE_OFFSET(module_core_text_size, module_core_size_rx));
> lm->mod_init_size =
> - UINT(modbuf + OFFSET(module_init_size));
> + UINT(modbuf + MODULE_OFFSET2(module_init_size, rx));
> lm->mod_init_text_size =
> - UINT(modbuf + OFFSET(module_init_text_size));
> + UINT(modbuf + MODULE_OFFSET(module_init_text_size, module_init_size_rx));
> } else {
> lm->mod_etext_guess = lm->mod_base +
> - ULONG(modbuf + OFFSET(module_core_text_size));
> + ULONG(modbuf + MODULE_OFFSET(module_core_text_size, module_core_size_rx));
> lm->mod_init_size =
> - ULONG(modbuf + OFFSET(module_init_size));
> + ULONG(modbuf + MODULE_OFFSET2(module_init_size, rx));
> lm->mod_init_text_size =
> - ULONG(modbuf + OFFSET(module_init_text_size));
> + ULONG(modbuf + MODULE_OFFSET(module_init_text_size, module_init_size_rx));
> }
> lm->mod_text_start = lm->mod_base;
>
> -- 2.20.1
4 years, 1 month
Re: [Crash-utility] Crash-utility Digest, Vol 178, Issue 21
by lijiang
在 2020年07月30日 21:34, crash-utility-request(a)redhat.com 写道:
> Message: 4
> Date: Thu, 30 Jul 2020 15:34:30 +0200
> From: Mathias Krause <minipli(a)grsecurity.net>
> To: crash-utility(a)redhat.com
> Subject: [Crash-utility] [PATCH 3/3] Support core files with "unusual"
> layout
> Message-ID: <20200730133430.7773-4-minipli(a)grsecurity.net>
> Content-Type: text/plain; charset=US-ASCII
>
> The netdump code not only gets used for netdump/diskdump files, but also
> for kdump core files. These can also be generated with the 'vmss2core'
> tool that'll produce a slightly different format that isn't as densely
> packed as we expect it to be. In fact, the implicit assumption that the
> ELF program headers directly follow the ELF header isn't always true for
Hi, Mathias
Thanks for your patch. I agree with you, the actual files may differ.
> these files, as they may contain a small padding area after the ELF
> header -- which is totally conforming in regards to the ELF spec. This
> padding in combination with the implicit assumption of densely packed
> headers make us interpret the padding bytes as program headers which is
> obviously wrong.
>
> Support these kind of core files too by not blindly assuming the program
> headers follow the ELF header but by looking at the program header
> offset in the ELF header and use that instead. Add some guarding sanity
> checks to decline operating on obviously malicious or broken core files.
>
> To not needlessly make things too complicated, allow a "padding space" of
> up to 128 bytes only.
>
> Signed-off-by: Mathias Krause <minipli(a)grsecurity.net>
> ---
> netdump.c | 86 ++++++++++++++++++++++++++++++++++++++-----------------
> netdump.h | 2 ++
> 2 files changed, 61 insertions(+), 27 deletions(-)
>
> diff --git a/netdump.c b/netdump.c
> index 406416af36bf..0490bb52a8ed 100644
> --- a/netdump.c
> +++ b/netdump.c
> @@ -132,7 +132,7 @@ is_netdump(char *file, ulong source_query)
> }
> }
>
> - size = MIN_NETDUMP_ELF_HEADER_SIZE;
> + size = SAFE_NETDUMP_ELF_HEADER_SIZE;
> if ((eheader = (char *)malloc(size)) == NULL) {
> fprintf(stderr, "cannot malloc minimum ELF header buffer\n");
> clean_exit(1);
> @@ -219,8 +219,22 @@ is_netdump(char *file, ulong source_query)
> source_query))
> goto bailout;
>
> - load32 = (Elf32_Phdr *)
> - &eheader[sizeof(Elf32_Ehdr)+sizeof(Elf32_Phdr)];
For the Program Header table, could it be optional? If present, the value of
e_phoff should be non-zero, otherwise its value is zero. Would it be better
to check if the value of e_phoff is valid?
> + if (elf32->e_phoff != sizeof(Elf32_Ehdr)) {
> + if (CRASHDEBUG(1))
> + error(WARNING, "%s: first PHdr not following "
> + "EHdr (PHdr offset = %u)", file,
> + elf32->e_phoff);
> + /* it's okay as long as we've read enough data */
> + if (elf32->e_phoff > size - 2 * sizeof(Elf32_Phdr)) {
> + error(WARNING, "%s: PHdr to far into file!\n",
> + file);
> + goto bailout;
> + }
> + }
> +
> + /* skip the NOTE program header */
> + load32 = (Elf32_Phdr *)
> + &eheader[elf32->e_phoff+sizeof(Elf32_Phdr)];
>
> if ((load32->p_offset & (MIN_PAGE_SIZE-1)) ||
> (load32->p_align == 0))
> @@ -291,8 +305,22 @@ is_netdump(char *file, ulong source_query)
> source_query))
> goto bailout;
>
> - load64 = (Elf64_Phdr *)
> - &eheader[sizeof(Elf64_Ehdr)+sizeof(Elf64_Phdr)];
> + if (elf64->e_phoff != sizeof(Elf64_Ehdr)) {
> + if (CRASHDEBUG(1))
> + error(WARNING, "%s: first PHdr not following "
> + "EHdr (PHdr offset = %u)", file,
> + elf64->e_phoff);
> + /* it's okay as long as we've read enough data */
> + if (elf64->e_phoff > size - 2 * sizeof(Elf64_Phdr)) {
> + error(WARNING, "%s: PHdr to far into file!\n",
> + file);
> + goto bailout;
> + }
> + }
> +
> + /* skip the NOTE program header */
> + load64 = (Elf64_Phdr *)
> + &eheader[elf64->e_phoff+sizeof(Elf64_Phdr)];
>
> if ((load64->p_offset & (MIN_PAGE_SIZE-1)) ||
> (load64->p_align == 0))
> @@ -353,9 +381,8 @@ is_netdump(char *file, ulong source_query)
> clean_exit(1);
> }
> nd->notes32 = (Elf32_Phdr *)
> - &nd->elf_header[sizeof(Elf32_Ehdr)];
> - nd->load32 = (Elf32_Phdr *)
> - &nd->elf_header[sizeof(Elf32_Ehdr)+sizeof(Elf32_Phdr)];
> + &nd->elf_header[nd->elf32->e_phoff];
> + nd->load32 = nd->notes32 + 1;
> if (format == NETDUMP_ELF32)
> nd->page_size = (uint)nd->load32->p_align;
> dump_Elf32_Ehdr(nd->elf32);
> @@ -392,9 +419,8 @@ is_netdump(char *file, ulong source_query)
> clean_exit(1);
> }
> nd->notes64 = (Elf64_Phdr *)
> - &nd->elf_header[sizeof(Elf64_Ehdr)];
> - nd->load64 = (Elf64_Phdr *)
> - &nd->elf_header[sizeof(Elf64_Ehdr)+sizeof(Elf64_Phdr)];
> + &nd->elf_header[nd->elf64->e_phoff];
> + nd->load64 = nd->notes64 + 1;
> if (format == NETDUMP_ELF64)
> nd->page_size = (uint)nd->load64->p_align;
> dump_Elf64_Ehdr(nd->elf64);
> @@ -469,8 +495,8 @@ resize_elf_header(int fd, char *file, char **eheader_ptr, char **sect0_ptr,
> case NETDUMP_ELF32:
> case KDUMP_ELF32:
> num_pt_load_segments = elf32->e_phnum - 1;
> - header_size = sizeof(Elf32_Ehdr) + sizeof(Elf32_Phdr) +
> - (sizeof(Elf32_Phdr) * num_pt_load_segments);
> + header_size = MAX(sizeof(Elf32_Ehdr), elf32->e_phoff) +
> + (sizeof(Elf32_Phdr) * (num_pt_load_segments + 1));
> break;
>
> case NETDUMP_ELF64:
> @@ -513,8 +539,8 @@ resize_elf_header(int fd, char *file, char **eheader_ptr, char **sect0_ptr,
> } else
> num_pt_load_segments = elf64->e_phnum - 1;
>
> - header_size = sizeof(Elf64_Ehdr) + sizeof(Elf64_Phdr) +
> - (sizeof(Elf64_Phdr) * num_pt_load_segments);
> + header_size = MAX(sizeof(Elf64_Ehdr), elf64->e_phoff) +
> + (sizeof(Elf64_Phdr) * (num_pt_load_segments + 1));
> break;
> }
>
> @@ -544,7 +570,7 @@ resize_elf_header(int fd, char *file, char **eheader_ptr, char **sect0_ptr,
> {
> case NETDUMP_ELF32:
> case KDUMP_ELF32:
> - load32 = (Elf32_Phdr *)&eheader[sizeof(Elf32_Ehdr)+sizeof(Elf32_Phdr)];
> + load32 = (Elf32_Phdr *)&eheader[elf32->e_phoff+sizeof(Elf32_Phdr)];
> p_offset32 = load32->p_offset;
> for (i = 0; i < num_pt_load_segments; i++, load32 += 1) {
> if (load32->p_offset &&
> @@ -556,7 +582,7 @@ resize_elf_header(int fd, char *file, char **eheader_ptr, char **sect0_ptr,
>
> case NETDUMP_ELF64:
> case KDUMP_ELF64:
> - load64 = (Elf64_Phdr *)&eheader[sizeof(Elf64_Ehdr)+sizeof(Elf64_Phdr)];
> + load64 = (Elf64_Phdr *)&eheader[elf64->e_phoff+sizeof(Elf64_Phdr)];
> p_offset64 = load64->p_offset;
> for (i = 0; i < num_pt_load_segments; i++, load64 += 1) {
> if (load64->p_offset &&
> @@ -4459,8 +4485,12 @@ proc_kcore_init_32(FILE *fp, int kcore_fd)
> close(fd);
>
> elf32 = (Elf32_Ehdr *)&eheader[0];
> - notes32 = (Elf32_Phdr *)&eheader[sizeof(Elf32_Ehdr)];
> - load32 = (Elf32_Phdr *)&eheader[sizeof(Elf32_Ehdr)+sizeof(Elf32_Phdr)];
> + if (elf32->e_phoff > sizeof(eheader) - 2 * sizeof(Elf32_Phdr)) {
> + error(INFO, "/proc/kcore: ELF program header offset too big!\n");
> + return FALSE;
> + }
> + notes32 = (Elf32_Phdr *)&eheader[elf32->e_phoff];
> + load32 = notes32 + 1;
>
> pkd->segments = elf32->e_phnum - 1;
>
> @@ -4479,9 +4509,8 @@ proc_kcore_init_32(FILE *fp, int kcore_fd)
> }
>
> BCOPY(&eheader[0], &pkd->elf_header[0], pkd->header_size);
> - pkd->notes32 = (Elf32_Phdr *)&pkd->elf_header[sizeof(Elf32_Ehdr)];
> - pkd->load32 = (Elf32_Phdr *)
> - &pkd->elf_header[sizeof(Elf32_Ehdr)+sizeof(Elf32_Phdr)];
> + pkd->notes32 = (Elf32_Phdr *)&pkd->elf_header[elf32->e_phoff];
> + pkd->load32 = pkd->notes32 + 1;
> pkd->flags |= KCORE_ELF32;
>
> kcore_memory_dump(CRASHDEBUG(1) ? fp : pc->nullfp);
> @@ -4529,8 +4558,12 @@ proc_kcore_init_64(FILE *fp, int kcore_fd)
> close(fd);
>
> elf64 = (Elf64_Ehdr *)&eheader[0];
> - notes64 = (Elf64_Phdr *)&eheader[sizeof(Elf64_Ehdr)];
> - load64 = (Elf64_Phdr *)&eheader[sizeof(Elf64_Ehdr)+sizeof(Elf64_Phdr)];
> + if (elf64->e_phoff > sizeof(eheader) - 2 * sizeof(Elf64_Phdr)) {
> + error(INFO, "/proc/kcore: ELF program header offset too big!\n");
> + return FALSE;
> + }
> + notes64 = (Elf64_Phdr *)&eheader[elf64->e_phoff];
> + load64 = notes64 + 1;
>
> pkd->segments = elf64->e_phnum - 1;
>
> @@ -4550,9 +4583,8 @@ proc_kcore_init_64(FILE *fp, int kcore_fd)
> }
>
> BCOPY(&eheader[0], &pkd->elf_header[0], pkd->header_size);
> - pkd->notes64 = (Elf64_Phdr *)&pkd->elf_header[sizeof(Elf64_Ehdr)];
> - pkd->load64 = (Elf64_Phdr *)
> - &pkd->elf_header[sizeof(Elf64_Ehdr)+sizeof(Elf64_Phdr)];
> + pkd->notes64 = (Elf64_Phdr *)&pkd->elf_header[elf64->e_phoff];
> + pkd->load64 = pkd->notes64 + 1;
> pkd->flags |= KCORE_ELF64;
>
> kcore_memory_dump(CRASHDEBUG(1) ? fp : pc->nullfp);
> diff --git a/netdump.h b/netdump.h
> index 7fa04f7c3a0f..844279bc4a00 100644
> --- a/netdump.h
> +++ b/netdump.h
> @@ -25,6 +25,8 @@
> sizeof(Elf64_Ehdr)+sizeof(Elf64_Phdr)+sizeof(Elf64_Phdr)
> #define MIN_NETDUMP_ELF_HEADER_SIZE \
> MAX(MIN_NETDUMP_ELF32_HEADER_SIZE, MIN_NETDUMP_ELF64_HEADER_SIZE)
> +#define SAFE_NETDUMP_ELF_HEADER_SIZE \
> + (MIN_NETDUMP_ELF_HEADER_SIZE+128)
>
Can you please describe more details why the size of padding area is 128 bytes?
Are there any particular reasons?
Thanks.
Lianbo
> #define NT_TASKSTRUCT 4
> #define NT_DISKDUMP 0x70000001
> -- 2.20.1
4 years, 2 months