All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: jiang.peng9@zte.com.cn
Cc: pabeni@redhat.com, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, jiri@resnulli.us, linux@treblig.org,
	oscmaes92@gmail.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, xu.xin16@zte.com.cn,
	yang.yang29@zte.com.cn
Subject: Re: [PATCH net] net: vlan: fix format-truncation warnings in? register_vlan_device
Date: Thu, 19 Jun 2025 13:35:23 +0100	[thread overview]
Message-ID: <20250619123523.GK1699@horms.kernel.org> (raw)
In-Reply-To: <20250619144934348-KObAuS33g0yI9ulIjMjE@zte.com.cn>

On Thu, Jun 19, 2025 at 02:49:34PM +0800, jiang.peng9@zte.com.cn wrote:
> From: Peng Jiang <jiang.peng9@zte.com.cn>
> 
> Building with W=1 triggers format-truncation warnings in the
> register_vlan_device function when compiled with GCC 12.3.0.
> These warnings occur due to the use of %i and %.4i format
> specifiers with a buffer size that might be insufficient
> for the formatted string, potentially causing truncation.
> 
> The original warning trace:
> net/8021q/vlan.c:247:17: note: 'snprintf' output between 3 and 22 bytes into a destination of size 16
> 247 | snprintf(name, IFNAMSIZ, "%s.%i", real_dev->name, vlan_id);
> 
> Signed-off-by: Peng Jiang <jiang.peng9@zte.com.cn>

Hi Peng Jiang,

name is passed to alloc_netdev(). Which is a wrapper around alloc_netdev_mqs()
which includes the following check:

	BUG_ON(strlen(name) >= sizeof(dev->name)); 

And the size of dev->name is IFNAMSIZ.

So while I am very pleased to see efforts to address format-truncation
warning - indeed I have made efforts elsewhere to this end myself - I don't
think we can solve this problem the way you propose.


Also, I suspect any work in this area will not be a bug fix, and
thus more appropriate to target at net-next rather than net.

	Subject; [PATCH net-next]

And please make sure patches for net or next-next apply against
their target tree: this patch applies to cleanly to neither.

For more information on process for networking patches please see
https://docs.kernel.org/process/maintainer-netdev.html

-- 
pw-bot: changes-requested


...


  reply	other threads:[~2025-06-19 12:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-19  6:49 [PATCH net] net: vlan: fix format-truncation warnings in register_vlan_device jiang.peng9
2025-06-19 12:35 ` Simon Horman [this message]
2025-06-20  1:33   ` [PATCH net] net: vlan: fix format-truncation warnings in? register_vlan_device jiang.peng9

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250619123523.GK1699@horms.kernel.org \
    --to=horms@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jiang.peng9@zte.com.cn \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@treblig.org \
    --cc=netdev@vger.kernel.org \
    --cc=oscmaes92@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=xu.xin16@zte.com.cn \
    --cc=yang.yang29@zte.com.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.