[Crash-utility] [PATCH v4] Fix "log" command when crash is started with "--minimal" option

lijiang lijiang at redhat.com
Tue Aug 18 11:28:37 UTC 2020


在 2020年08月18日 00:00, crash-utility-request at redhat.com 写道:
>> -----Original Message-----
>> From: crash-utility-bounces at redhat.com <crash-utility-bounces at redhat.com> On Behalf Of Dave Wysochanski
>> Sent: Monday, August 17, 2020 4:20 AM
>> To: crash-utility at redhat.com
>> Subject: [Crash-utility] [PATCH v4] Fix "log" command when crash is started with "--minimal" option
>>
>> 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 at redhat.com>
>> Reviewed-by: Wang Long <w at laoqinren.net>
>> Tested-by: Mathias Krause <minipli at grsecurity.net>
>> Reviewed-by: Lianbo Jiang <lijiang at 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");
>                                        ^^^^^
> This extra "log: " is not needed:
> 
> crash> log -T
> log: WARNING: log: option 'T' not available in minimal mode
> 
> Lianbo, would you remove it when applying?  Otherwise,
> 
Sure, applied. Thanks for the fix, Dave Wysochanski.

Lianbo

> Acked-by: Kazuhito Hagio <k-hagio-ab at nec.com>
> 
> Thanks,
> Kazu
> 
> 




More information about the Crash-utility mailing list