Re: [PATCH v2] RAS: Fix the trace_show() function to output trace_count

From: Tony Luck
Date: Tue Oct 18 2022 - 10:37:00 EST


On Mon, Oct 17, 2022 at 09:40:09PM +0200, Borislav Petkov wrote:
> Question is, what is your goal with this?

I ran into it while fixing:

https://lore.kernel.org/all/20221006163258.318916-1-tony.luck@xxxxxxxxx/

when I just used "cat daemon_active" to check status and was confused
by the lack of any output. Looked at the code and saw the silly

return atomic_read(&trace_count);

which does nothing useful.

Maybe if there isn't a reasonable thing to output, that could be
changed to:

static int trace_show(struct seq_file *m, void *v)
{
/*
* User should use "lsof daemon_active" if they want to
* know if there is a process consuming trace error records
*/
return 0;
}

Sadly, we need to have a trace_show() function. If trace_open() just
does:

return single_open(file, NULL, NULL);

then we get a deref NULL OOPs if somebody does "cat daemon_active" :-(

-Tony