Re: [PATCH net-next] cxgb4: avoid truncating the MSI-X interrupt names
From: Willem de Bruijn
Date: Thu Dec 03 2026 - 21:25:44 EST
On Thu, Nov 26, 2026 at 1:19 AM Aibing Chen
<chenaibing@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> The MSI-X interrupt names are assembled with snprintf() into
> adap->msix_info[].desc[IFNAMSIZ + 10], from adap->port[0]->name (up to
> IFNAMSIZ - 1 characters) plus a suffix and a queue index:
>
> "%s-Rx%d" needs up to 30 bytes
> "%s-mirrorrxq%d" needs up to 37 bytes
> "%s-%s%d" needs up to 43 bytes
In cxgb4_port_mirror_alloc_queues(), i is u16 (range 0..65534, up to 5
digits, as noted in the GCC message below), so "%s-mirrorrxq%d" needs up
to 31 bytes (15 + 10 + 5 + 1), not 37; similarly "%s-%s%d" has i in
[0, nrxq + nciq - 1] (<= 131069, 38 bytes under GCC VRP, or 43 bytes if
allowing full 32-bit int).
> The last one also formats the ULD queue name, which is copied from the
> ULD with memcpy(rxq_info->name, uld_info->name, IFNAMSIZ) into a
> char[IFNAMSIZ] field, so it can be up to IFNAMSIZ - 1 characters as well.
>
> Because -Wformat-truncation is enabled for W=1 builds and COMPILE_TEST
> configurations turn it into an error through CONFIG_WERROR, the driver
> does not build today:
>
> cxgb4_main.c:1074:48: error: '%d' directive output may be truncated
> writing between 1 and 11 bytes into a region of size between 8 and
> 23 [-Werror=format-truncation=]
> cxgb4_main.c:1356:47: error: '%d' directive output may be truncated
> writing between 1 and 5 bytes into a region of size between 1 and 16
> cxgb4_uld.c:141:38: error: '%s' directive output may be truncated
> writing up to 15 bytes into a region of size between 10 and 25
>
> Size desc[] for the worst case, 42 characters plus the terminator, which
> is IFNAMSIZ + 27 bytes.
>
> Compile tested only, with W=1 before and after the change; no Chelsio
> hardware was available to exercise the driver.
>
> Reported-by: kernel test robot <lkp@xxxxxxxxx>
> Closes: https://lore.kernel.org/oe-kbuild-all/202604141419.a4vuNBN7-lkp@xxxxxxxxx/
This lkp report is for an unrelated thermal link error
(devm_thermal_of_cooling_device_register) that only happened to capture
cxgb4 W=1 warnings incidentally (and cxgb4_ethtool.c:209 remains open);
Link: would be more accurate than Closes:.
> Signed-off-by: Aibing Chen <chenaibing@xxxxxxxxxxxxxxxxxxxx>
> ---
> drivers/net/ethernet/chelsio/cxgb4/cxgb4.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
> index f20f4bc58..dda787b8d 100644
> --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
> +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
> @@ -1049,7 +1049,7 @@ struct msix_bmap {
>
> struct msix_info {
> unsigned short vec;
> - char desc[IFNAMSIZ + 10];
> + char desc[IFNAMSIZ + 27];
The + 27 silently hardcodes a second IFNAMSIZ - 1 (for rxq_info->name)
plus '-' and 11 bytes for %d. Writing 2 * IFNAMSIZ + 11 (same 43 bytes)
makes the bound self-documenting and tracks IFNAMSIZ automatically.
> unsigned int idx;
> cpumask_var_t aff_mask;
> };
>
>
>