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

Mathias Krause minipli at grsecurity.net
Thu Aug 6 11:26:13 UTC 2020


Am 04.08.20 um 16:10 schrieb 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.
> Further, only calculate the logic to calculate 	kt->boot_date.tv_sec

I guess the tab is not intended? -----------------^

> when this option is enabled.
> 
> Fixes: c86250bce29f ("Introduction of the "log -T" option...")
> Signed-off-by: Dave Wysochanski <dwysocha at redhat.com>
> ---
>  kernel.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel.c b/kernel.c
> index 5ed6021..500532a 100644
> --- a/kernel.c
> +++ b/kernel.c
> @@ -4939,7 +4939,11 @@ 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");

Minor nit: no need to wrap the line, it fits the 80 columns limit just fine.

> +
> +	if (msg_flags & SHOW_LOG_CTIME && kt->boot_date.tv_sec == 0) {
>  		ulonglong uptime_jiffies;
>  		ulong  uptime_sec;
>  		get_uptime(NULL, &uptime_jiffies);
> 

Beside that: Tested-by: Mathias Krause <minipli at grsecurity.net>

Thanks,
Mathias





More information about the Crash-utility mailing list