[Crash-utility] Crash-utility Digest, Vol 179, Issue 4

lijiang lijiang at redhat.com
Thu Aug 13 13:41:54 UTC 2020


在 2020年08月13日 15:31, HAGIO KAZUHITO(萩尾 一仁) 写道:
> Hi Lianbo,
> 
>> -----Original Message-----
>> 在 2020年08月07日 00:00, crash-utility-request at redhat.com 写道:
>>> Message: 5
>>> Date: Thu,  6 Aug 2020 09:30:22 -0400
>>> From: Dave Wysochanski <dwysocha at redhat.com>
>>> To: crash-utility at redhat.com
>>> Subject: [Crash-utility] [PATCH v3] Fix "log" command when crash is
>>> 	started	with "--minimal" option
>>> Message-ID: <20200806133022.2127538-1-dwysocha at 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 at redhat.com>
>>> Reviewed-by: Wang Long <w at laoqinren.net>
>>> Tested-by: Mathias Krause <minipli at 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;

Here, it will give a warning and then return if it is in minimal mode.

>> +               }
>> +
>> +               if (kt->boot_date.tv_sec == 0) {
>> ...
>> +               }
>>         }
>>
>> In addition, might it be more reasonable to issue a warning instead of a fatal error?
> 
> hmm, why do you think so?  I think FATAL is fine because we cannot proceed
> anymore and there is no memory to be released.
> 
When users are trying to use the some commands in crash, crash should give a warning to users if
it doesn't support the command yet, but users can still use other commands, the fatal error means
that it can not continue to do anythings.

Anyway, I have no preference about this. The more important thing is that I didn't reproduce the
problem that David mentioned(after applied the above patch). Maybe David could help me give more
details.

Thanks.
Lianbo 

> Thanks,
> Kazu
> 
>>
>> Thanks.
>> Lianbo
>>
>>>  		ulonglong uptime_jiffies;
>>>  		ulong  uptime_sec;
>>>  		get_uptime(NULL, &uptime_jiffies);
>>> -- 2.27.0
>>
>> --
>> Crash-utility mailing list
>> Crash-utility at redhat.com
>> https://www.redhat.com/mailman/listinfo/crash-utility




More information about the Crash-utility mailing list