Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp906496rwl; Thu, 5 Jan 2023 06:16:44 -0800 (PST) X-Google-Smtp-Source: AMrXdXvsE67evWMJ9cP8kGAvyizmKeudfE1MY49cemMxc1/ZxgiTZoFGps9/iBQTkZ5zVfD4ZmTG X-Received: by 2002:a17:902:d4d1:b0:189:c322:df3a with SMTP id o17-20020a170902d4d100b00189c322df3amr73617273plg.43.1672928204269; Thu, 05 Jan 2023 06:16:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672928204; cv=none; d=google.com; s=arc-20160816; b=uCQ0wUkxSs3S4dHmwf+q+16ErqM9t24zAxpnsM/R4cohFWMmwEmv/WsoxyYW0TbTrE z25fbtk2bWP6+rlAT4lAw/pfDEdhSnPK8t9q7MgL6Pj2ylJ6N6NSBsaiX2iiBVDNs5k+ ovKR40NhfUOsBCT2dX7fTfjM08mdJW2YDQtXBS6F8UtgIoR3/rrC9qCNNZk6Ya0Vm+EF ZRv4CPmA62D/sYzumljKgpDwfwq62gYwdWTHUR1pRw9ws+jf/JhzXfzkE6PWBDg7oa5T t6gDZrHV2Q3NvI4/VLTu0RYRIgscrKWwC0MjD+bxd/w7ezAw6cpEyH77vl7PzP2GYAtZ 97DQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=/sIatotjJUdFh+rLaqBhsOp82C9DkXXeUSI88pC2wMQ=; b=d92hbT37WXikgyj4aBKRGh0rBkSVYYoJTsiSUTw/FGOYyq82oAm5o2V+yITiuZX36r SBBqZhJKjvqLixgePg5sD+Ozk/2PVvhRqjE9SYQkg5Hyg6ZGfd6AwZa+ERZqO/eU3wIV jmaaQbpAfIK2o6Y/Qg9FQTps0tFbdnVJHfv26KXBMJzhWtBXDAYh6qk8A5K3RnpfDxXX Vs8TGb9ozoVLYPWDChCVT+55DT21arZmSFeoxAgbq3ekjbP3R24smK949Jk5OyEj38Dz T+9d4NIkCsJV7urpIL5Trv0HnWuUStI665RpialWyAdIKOSTU3Ea4WMOTyqA0m9Z62CA VKxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=tKbhHoYA; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=jGuJbd3Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t15-20020a170902e84f00b001898558457dsi39609110plg.123.2023.01.05.06.16.36; Thu, 05 Jan 2023 06:16:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=tKbhHoYA; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=jGuJbd3Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234429AbjAEN5z (ORCPT + 58 others); Thu, 5 Jan 2023 08:57:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234239AbjAEN5D (ORCPT ); Thu, 5 Jan 2023 08:57:03 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACB1150F5E for ; Thu, 5 Jan 2023 05:56:10 -0800 (PST) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1672926968; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=/sIatotjJUdFh+rLaqBhsOp82C9DkXXeUSI88pC2wMQ=; b=tKbhHoYA15Dd2DKj+LbkG8ogGrd5rC1zAHRutJjK5T+Y8veV1e7EqYQkfASMFnvijMcfbN ejzluB3l0b+IhOIC1O+bDJeRQp6laLp2s1L/KuOd7GgNPyRrU9u3mk8nU2i9KNa7xXwTwH DpqxDWTFUBK/djmdfiF0r6xtRMI/jkM8viPufUqYuK/+HLNe+H1nNIQcsu+7iFpNecq08t KMb0uyKlw+5XkAQfZc1l/K9s4Wal4N3oEzCC9ejBaxsou+gXGAxWGrwJoX6hEgKvHBojIn hovEocqZ3mTly0K/g5WhqLgUVwxYnhN77UyXBizrOL9WsGU+VrrJUba55iiSbQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1672926968; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=/sIatotjJUdFh+rLaqBhsOp82C9DkXXeUSI88pC2wMQ=; b=jGuJbd3Q9omAGinUHrftA9GNZEoPsIzbq8o5o9m5WJje6IMnjqr3kOaMjaViRI+11YEQ8s bhl6ki37r1CEKSDg== To: kernel test robot , Petr Mladek Cc: oe-kbuild-all@lists.linux.dev, Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org Subject: Re: [PATCH printk v3 6/6] printk: introduce console_prepend_dropped() for dropped messages In-Reply-To: <202301052114.vvN3wQoH-lkp@intel.com> References: <20221221202704.857925-7-john.ogness@linutronix.de> <202301052114.vvN3wQoH-lkp@intel.com> Date: Thu, 05 Jan 2023 15:01:28 +0106 Message-ID: <877cy1cchb.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,INVALID_DATE_TZ_ABSURD, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023-01-05, kernel test robot wrote: > smatch warnings: > kernel/printk/printk.c:2735 console_prepend_dropped() warn: always true condition '(cmsg->outbuf_len + len >= outbuf_sz) => (0-u64max >= 0)' Thank you kernel test robot, but actually this code will never be hit when outbuf_sz is 0. Explanation below. > vim +2735 kernel/printk/printk.c > > 2701 > 2702 /* > 2703 * Prepend the message in @cmsg->cbufs->outbuf with a "dropped message". This > 2704 * is achieved by shifting the existing message over and inserting the dropped > 2705 * message. > 2706 * > 2707 * @cmsg is the console message to prepend. > 2708 * > 2709 * @dropped is the dropped count to report in the dropped message. > 2710 * > 2711 * If the message text in @cmsg->cbufs->outbuf does not have enough space for > 2712 * the dropped message, the message text will be sufficiently truncated. > 2713 * > 2714 * If @cmsg->cbufs->outbuf is modified, @cmsg->outbuf_len is updated. > 2715 */ > 2716 static void console_prepend_dropped(struct console_message *cmsg, unsigned long dropped) > 2717 { > 2718 struct console_buffers *cbufs = cmsg->cbufs; > 2719 const size_t scratchbuf_sz = sizeof(cbufs->scratchbuf); > 2720 const size_t outbuf_sz = sizeof(cbufs->outbuf); > 2721 char *scratchbuf = &cbufs->scratchbuf[0]; > 2722 char *outbuf = &cbufs->outbuf[0]; > 2723 size_t len; > 2724 > 2725 len = snprintf(scratchbuf, scratchbuf_sz, > 2726 "** %lu printk messages dropped **\n", dropped); > 2727 > 2728 /* > 2729 * Make sure outbuf is sufficiently large before prepending. Space > 2730 * for a terminator is also counted in case truncation occurs. > 2731 */ > 2732 if (WARN_ON_ONCE(len + 1 >= outbuf_sz)) > 2733 return; If outbuf_sz is 0, the above check will return. It is interesting that smatch did not complain about this line instead. I suppose the WARN_ON_ONCE confused it. Note that if outbuf_sz is 0, then CONFIG_PRINTK is undefined. In that case this function should not be called anyway. So the check and warning are appropriate here. > 2734 >> 2735 if (cmsg->outbuf_len + len >= outbuf_sz) { John Ogness