From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796465080; b=w6qQVFQiZ8aDqE7wcqunyZwd4S8xXn7u7zDCHCZpQMH0/Puy7/4RBejew6Sfm/+VcY3j Hfe190qppU5gWMywolF43w/tAjcyrm/3CuJp9nAmAZxvreCppWqvkpCNeNbwdid0QeR0x +PUdaXkgM7DhFj61QvEjldZTZLM+tq69d6y2LEGgvB0CW7E+DjSlKb2SwDTZuhOBqxMZB 2ZzSYT5wYC2S5xRmkJqIGA/SNH6YYBuapasJIXeS5v4GmgQ5Wlcu7QhKguBHJkq7/K9T5 X5KqpdZoVUcIjCswj3QJn0eNyAtkD+VJR2kdIG+YXbhS0ckGd0xcW/lXz/2BNv0lLrg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796465080; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=hYW6jWXKexxQWATAY92JKCIVWH3c5BUigBd2WnFm8EE=; b=HI1EdXDhFEt+RblkNEinI7rbQsz7oZNNsEj1l3v9rThCsJY0YdFQ25hbG5cb3/izw+PD nM3kGVDbs5ie9InUxnwwrRneUPkwaevPbRyqGckQFn2amd2gC5HnQZlv601oYU5e8uvbL DE6lGtOYothoma1pYy/XXL7aWHse2ZqjjayhFBLXiyJ/2eg6JfVXTSJL1DUMV6WJsSOq9 XHQQLFbKG9v5wnf1nEewgn0QwvIjZw8hHSp5c3FeBsc7AXl1X7SieShsBroL6/CrN24bx vGdLn973zfqNgDpbEwP40AgM+S6riPGU4MIIKnD3kPJ6g/OZkx5gq3Ps9cq1FiAFC/A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SROodKoZ; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F06A3606A336; Sat, 5 Dec 2026 10:04:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=SROodKoZ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 911291F00936; Sat, 5 Dec 2026 10:04:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796465079; bh=hYW6jWXKexxQWATAY92JKCIVWH3c5BUigBd2WnFm8EE=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=SROodKoZSK1Fzhh1NgmCZydSV5YRzG5bHf282yE+mBhjhq8SK6yGPz2hN9LlX+WOb VOM80LmEQrHiOhFwRwJ6cG+MZJaI65aezBnoW8ONgN2uJl8eQ+ZJNTuh1PZtT7GT/5 wH1R/ksmAAkz16pzbQs+GZimyDTHlSUoMlnsJqQH6uQDDsodlxMbLmw9xmKnb01/Su MnJVHuFbqitl/EndvjaWu0aWNZu5DKuZubnbL1VQ8fRfVFS72PG6OcaMcfBZ+n3t0w D8RjElJGzcyDq9mo1U6cMi8hOCSRErq3BIZrTP5fI+8ST5XOs4mic/IiUNs2+SMWAY Spm1lfF7AVQjQ== Subject: Re: [PATCH net-next v2 2/2] cxgb4: use scnprintf() for fw_version From: netdev-bot+sashiko@kernel.org To: chenaibing@cmss.chinamobile.com Cc: willemdebruijn.kernel@gmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kuba@kernel.org Date: Sat, 05 Dec 2026 10:04:39 +0000 Message-ID: <179646507917.3146.6681406898437849168@kernel.org> In-Reply-To: <20261204094816.116-2-chenaibing@cmss.chinamobile.com> References: <20261204094816.116-2-chenaibing@cmss.chinamobile.com> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 1 · Low: 2 (1) If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [Medium] The patch leaves the same construct unfixed in the sibling cxgb4vf driver. - [Low] The commit message misdescribes what the change does. - [Low] The continuation lines of the call are left inconsistently aligned. Pre-existing issues: - [Low] This problem wasn't introduced by this patch, but get_drvinfo() in drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c can still format… -- cxgb4: use scnprintf() for fw_version This commit changes get_drvinfo() in cxgb4 to format info->fw_version with scnprintf() instead of snprintf(). The goal is to silence a -Wformat-truncation error that the kernel test robot reported for W=1 builds with CONFIG_WERROR. Link: https://lore.kernel.org/oe-kbuild-all/202604141419.a4vuNBN7-lkp@intel.com/ > Use scnprintf(), which returns the number of bytes written, so the string > is bounded by the field and the intent is visible at the call site. [Severity: Low] Is this description accurate? snprintf() already limited the string to size - 1 bytes plus a NUL. scnprintf() writes exactly the same bytes and differs only in its return value, which get_drvinfo() discards. The warning seems to go away only because GCC's format-truncation analysis covers the snprintf()/vsnprintf() built-ins. scnprintf() is a plain kernel function declared with __printf(3, 4) in include/linux/sprintf.h, so GCC doesn't check it. The diagnostic was a true positive, since 35 characters can exceed the 31 usable bytes. Could the changelog say that the warning is being suppressed, and that the ", TP ..." suffix can still be truncated? > diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c > index c72c0bcd45c80..7c88bc8102d7d 100644 > --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c > +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c > @@ -205,8 +205,8 @@ static void get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) > info->regdump_len = get_regs_len(dev); > > if (adapter->params.fw_vers) > - snprintf(info->fw_version, sizeof(info->fw_version), > - "%u.%u.%u.%u, TP %u.%u.%u.%u", > + scnprintf(info->fw_version, sizeof(info->fw_version), > + "%u.%u.%u.%u, TP %u.%u.%u.%u", [Severity: Medium] Does the same build failure still happen in the sibling cxgb4vf driver? cxgb4vf_get_drvinfo() in drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c still has the same construct: snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), "%u.%u.%u.%u, TP %u.%u.%u.%u", FW_HDR_FW_VER_MAJOR_G(adapter->params.dev.fwrev), FW_HDR_FW_VER_MINOR_G(adapter->params.dev.fwrev), FW_HDR_FW_VER_MICRO_G(adapter->params.dev.fwrev), ... It uses the same FW_HDR_FW_VER_*_G() accessors from cxgb4/t4fw_api.h, whose masks are all 0xff. It also writes into the same 32-byte fw_version field, so GCC should compute the same 35-character worst case. scripts/Makefile.warn adds -Wno-format-truncation only outside of W=1. A W=1 build with CONFIG_WERROR (or W=e) and CONFIG_CHELSIO_T4VF enabled, such as allmodconfig, would therefore still fail. The commit message describes this build failure as resolved. Should cxgb4vf be handled in the same patch? [Severity: Low] This isn't a bug introduced by this patch, but get_drvinfo() can still format more characters than info->fw_version can hold. The field is ETHTOOL_FWVERS_LEN (32) bytes. With eight 0xff-masked fields, the worst case is 24 digits + 6 dots + ", TP " = 35 characters. In that case, the TP revision reported by ethtool -i is silently cut, for example "200.100.200.100, TP 200.100.20". The switch to scnprintf() doesn't change where the truncation happens. It only removes the warning that pointed to it. > FW_HDR_FW_VER_MAJOR_G(adapter->params.fw_vers), > FW_HDR_FW_VER_MINOR_G(adapter->params.fw_vers), > FW_HDR_FW_VER_MICRO_G(adapter->params.fw_vers), [Severity: Low] This isn't a bug, but only the format string line was re-indented to match the new scnprintf( parenthesis. The eight FW_HDR_FW_VER_*_G() argument lines keep the old alignment that matched snprintf(, so one call now has mixed continuation indentation. Could these lines be re-aligned too? -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204094816.116-1-chenaibing%40cmss.chinamobile.com