From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62A62C3A5A9 for ; Mon, 4 May 2020 18:12:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 43D2020663 for ; Mon, 4 May 2020 18:12:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="aH742N84" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731582AbgEDSMq (ORCPT ); Mon, 4 May 2020 14:12:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1732292AbgEDSMp (ORCPT ); Mon, 4 May 2020 14:12:45 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BED5C061A0E for ; Mon, 4 May 2020 11:12:45 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id z1so5939663pfn.3 for ; Mon, 04 May 2020 11:12:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=2t85iJlph6Ef8JKJOUjpWg5TqaXW+ZWxyKsRV3ThBgw=; b=aH742N842oe7OA3iNJcOds5bSKnEuHAMCXh+aDAwkdSSQRtoymdunTd5VQAjlYHQOM OjULy3JBZp5yb7vg5p5qDxupV9iTMJr5cLcgxy/lXqRpmEnMPzqfvH6f95xCs9eY01RT 47Si/yLCW7fX1qR5gKrcSyaoD4LfqSwa/YQyA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=2t85iJlph6Ef8JKJOUjpWg5TqaXW+ZWxyKsRV3ThBgw=; b=ShG/qK0WdRogHmNE3mv608C7hzfQwu3ngQVW7BRonCVVdw90GskiPKGvg5S0Y5VxrB TNzfSdS1hkAd71IFe8C9K4Q9fQ95abfRI1uzfTdEbSsf5QU+yCr8LqyZKooFwBBsNUyq a9/FHDavbHcA9cV5ggOFYUysnvNe8wpGVu5M0uo4ggIzXwQRoPH/i9/xPDnmKHN3o/Fi 7+S39TbbUk4fVl2fjKHN2VcuKclEs1q/QmO9ogBGmjxJlx3B7IMeq9L8IylOFDU6yfqv k2xe095ef+v16FyqT8v367CF6gXTcDKqrRtcKisPePiAqIBdTwMiEl6zG1cmCQalRY5d f1Zw== X-Gm-Message-State: AGi0PuaM57fqlq7BT58pQfrjPg+r3jZYbKbX6QnPS7obibjpuU3wUiFX 9TYKBg9wt+u+ofVC+PKCy5HT/w== X-Google-Smtp-Source: APiQypJwXwd6yTrLo+nsjAM60TJxP6uE+6NhJJmcwz/VBqP3Hf1U27dr+P3P+V/0llWuVJfNyCsDzQ== X-Received: by 2002:a63:951b:: with SMTP id p27mr194840pgd.49.1588615963952; Mon, 04 May 2020 11:12:43 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id l5sm1558594pgt.92.2020.05.04.11.12.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 May 2020 11:12:43 -0700 (PDT) Date: Mon, 4 May 2020 11:12:42 -0700 From: Kees Cook To: Steven Rostedt Cc: Pavel Tatashin , jmorris@namei.org, sashal@kernel.org, linux-kernel@vger.kernel.org, pmladek@suse.com, sergey.senozhatsky@gmail.com, anton@enomsg.org, ccross@android.com, tony.luck@intel.com, robh+dt@kernel.org, devicetree@vger.kernel.org Subject: Re: [PATCH v1 1/3] printk: honor the max_reason field in kmsg_dumper Message-ID: <202005041111.D803E731@keescook> References: <20200502143555.543636-1-pasha.tatashin@soleen.com> <20200502143555.543636-2-pasha.tatashin@soleen.com> <20200504131500.5f6c8860@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200504131500.5f6c8860@gandalf.local.home> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org On Mon, May 04, 2020 at 01:15:00PM -0400, Steven Rostedt wrote: > On Sat, 2 May 2020 10:35:53 -0400 > Pavel Tatashin 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 > > --- > > 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