Re: [PATCH v1 1/3] printk: honor the max_reason field in kmsg_dumper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, May 04, 2020 at 01:15:00PM -0400, Steven Rostedt wrote:
> On Sat,  2 May 2020 10:35:53 -0400
> Pavel Tatashin <pasha.tatashin@xxxxxxxxxx> wrote:
> 
> > kmsg_dump() allows to dump kmesg buffer for various system events: oops,
> > panic, reboot, etc. It provides an interface to register a callback call
> > for clients, and in that callback interface there is a field "max_reason"
> > which gets ignored unless always_kmsg_dump is passed as kernel parameter.
> > 
> > Allow clients to decide max_reason, and keep the current behavior when
> > max_reason is not set.
> > 
> > Signed-off-by: Pavel Tatashin <pasha.tatashin@xxxxxxxxxx>
> > ---
> >  include/linux/kmsg_dump.h |  1 +
> >  kernel/printk/printk.c    | 16 +++++++++-------
> >  2 files changed, 10 insertions(+), 7 deletions(-)
> > 
> > diff --git a/include/linux/kmsg_dump.h b/include/linux/kmsg_dump.h
> > index 2e7a1e032c71..c0d703b7ce38 100644
> > --- a/include/linux/kmsg_dump.h
> > +++ b/include/linux/kmsg_dump.h
> > @@ -28,6 +28,7 @@ enum kmsg_dump_reason {
> >  	KMSG_DUMP_RESTART,
> >  	KMSG_DUMP_HALT,
> >  	KMSG_DUMP_POWEROFF,
> > +	KMSG_DUMP_MAX = KMSG_DUMP_POWEROFF
> 
> Hmm, I didn't realize that enums were allowed to have duplicates. That can
> usually screw up logic. I would recommend making that a define afterward.
> 
> #define KMSG_DUMP_MAX KMSG_DUMP_POWEROFF
> 
> As is done in other locations of the kernel.

I've seen it also be the last item in an enum, then comparisons can just
do "< KMSG_DUMP_MAX" instead of "<= KMSG_DUMP_MAX".

-- 
Kees Cook



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux