All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: kaixuxia@tencent.com, frankjpliu@tencent.com, kasong@tencent.com,
	sagazchen@tencent.com, kernelxing@tencent.com,
	aurelianliu@tencent.com, deshengwu@tencent.com,
	flyingpeng@tencent.com, jingqunli@tencent.com,
	jason.zeng@intel.com, wu.zheng@intel.com, yingbao.jia@intel.com,
	pei.p.jia@intel.com
Cc: oe-kbuild-all@lists.linux.dev
Subject: [opencloudos:next 11987/13046] net/core/netclassid_cgroup.c:331:17: warning: 'strncpy' specified bound depends on the length of the source argument
Date: Thu, 24 Oct 2024 00:26:36 +0800	[thread overview]
Message-ID: <202410240035.lSlCcYd8-lkp@intel.com> (raw)

Hi Honglin,

FYI, the error/warning still remains.

tree:   https://gitee.com/OpenCloudOS/OpenCloudOS-Kernel.git next
head:   ce9f9d823a41831d622fa11e29c3d620c044f51b
commit: 669bbf19cd74db8ba957c288e9482d9dc10d68e1 [11987/13046] rue/net: init netcls traffic controller
config: x86_64-defconfig (https://download.01.org/0day-ci/archive/20241024/202410240035.lSlCcYd8-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241024/202410240035.lSlCcYd8-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202410240035.lSlCcYd8-lkp@intel.com/

All warnings (new ones prefixed by >>):

   net/core/netclassid_cgroup.c:100:5: warning: no previous prototype for 'cls_cgroup_stats_init' [-Wmissing-prototypes]
     100 | int cls_cgroup_stats_init(struct cls_cgroup_stats *stats)
         |     ^~~~~~~~~~~~~~~~~~~~~
   net/core/netclassid_cgroup.c:129:6: warning: no previous prototype for 'cls_cgroup_stats_destroy' [-Wmissing-prototypes]
     129 | void cls_cgroup_stats_destroy(struct cls_cgroup_stats *stats)
         |      ^~~~~~~~~~~~~~~~~~~~~~~~
   net/core/netclassid_cgroup.c:257:5: warning: no previous prototype for 'net_cgroup_notify_prio_change' [-Wmissing-prototypes]
     257 | int net_cgroup_notify_prio_change(struct cgroup_subsys_state *css,
         |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/core/netclassid_cgroup.c:409:5: warning: no previous prototype for 'read_class_stat' [-Wmissing-prototypes]
     409 | int read_class_stat(struct seq_file *sf, void *v)
         |     ^~~~~~~~~~~~~~~
   net/core/netclassid_cgroup.c:421:5: warning: no previous prototype for 'rx_dump' [-Wmissing-prototypes]
     421 | int rx_dump(struct seq_file *sf, void *v)
         |     ^~~~~~~
   net/core/netclassid_cgroup.c:428:5: warning: no previous prototype for 'tx_dump' [-Wmissing-prototypes]
     428 | int tx_dump(struct seq_file *sf, void *v)
         |     ^~~~~~~
   net/core/netclassid_cgroup.c: In function 'write_dev_bps_config':
>> net/core/netclassid_cgroup.c:331:17: warning: 'strncpy' specified bound depends on the length of the source argument [-Wstringop-truncation]
     331 |                 strncpy(bw_config[dev->ifindex].name, dev->name,
         |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     332 |                         strlen(dev->name));
         |                         ~~~~~~~~~~~~~~~~~~


vim +/strncpy +331 net/core/netclassid_cgroup.c

   264	
   265	static ssize_t write_dev_bps_config(struct kernfs_open_file *of,
   266					    char *buf, size_t nbytes, loff_t off)
   267	{
   268		struct net_device *dev;
   269		struct net *net = current->nsproxy->net_ns;
   270		char tok[27] = {0};
   271		unsigned long v[4] = {0};
   272		int len;
   273		int ret = -EINVAL;
   274	
   275		if (sscanf(buf, "%16s%n", tok, &len) != 1)
   276			return ret;
   277		buf += len;
   278	
   279		dev = dev_get_by_name(net, tok);
   280		if (!dev) {
   281			pr_err("Netdev name %s not found!\n", tok);
   282			return -ENODEV;
   283		}
   284	
   285		if (dev->ifindex >= MAX_NIC_SUPPORT) {
   286			pr_err("Netdev %s index(%d) too large!\n", tok, dev->ifindex);
   287			goto out_finish;
   288		}
   289	
   290		while (true) {
   291			char *p;
   292			unsigned long val = 0;
   293	
   294			if (sscanf(buf, "%26s%n", tok, &len) != 1)
   295				break;
   296			if (tok[0] == '\0')
   297				break;
   298			buf += len;
   299	
   300			p = tok;
   301			strsep(&p, "=");
   302			if (!p || kstrtoul(p, 10, &val) || !val)
   303				goto out_finish;
   304	
   305			if (!strcmp(tok, "disable") && val == 1) {
   306				kfree(bw_config[dev->ifindex].name);
   307				bw_config[dev->ifindex].name = NULL;
   308				ret = nbytes;
   309				goto out_finish;
   310			} else if (!strcmp(tok, "rx_bps_min")) {
   311				v[0] = val;
   312			} else if (!strcmp(tok, "rx_bps_max")) {
   313				v[1] = val;
   314			} else if (!strcmp(tok, "tx_bps_min")) {
   315				v[2] = val;
   316			} else if (!strcmp(tok, "tx_bps_max")) {
   317				v[3] = val;
   318			} else {
   319				goto out_finish;
   320			}
   321		}
   322	
   323		if (v[0] && v[1] && v[2] && v[3]) {
   324			if (v[0] < 0 || v[0] > v[1] || v[2] < 0 || v[2] > v[3])
   325				goto out_finish;
   326			/* release old config info */
   327			kfree(bw_config[dev->ifindex].name);
   328	
   329			len = strlen(dev->name) + 1;
   330			bw_config[dev->ifindex].name = kzalloc(len, GFP_KERNEL);
 > 331			strncpy(bw_config[dev->ifindex].name, dev->name,
   332				strlen(dev->name));
   333	
   334			bw_config[dev->ifindex].rx_bps_min = v[0];
   335			bw_config[dev->ifindex].rx_bps_max = v[1];
   336			bw_config[dev->ifindex].tx_bps_min = v[2];
   337			bw_config[dev->ifindex].tx_bps_max = v[3];
   338	
   339			if (READ_ONCE(netcls_modfunc.write_rx_bps_minmax) &&
   340			    READ_ONCE(netcls_modfunc.write_tx_bps_minmax)) {
   341				netcls_modfunc.write_rx_bps_minmax(dev->ifindex,
   342							v[0], v[1]);
   343				netcls_modfunc.write_tx_bps_minmax(dev->ifindex,
   344							v[2], v[3]);
   345			}
   346			ret = nbytes;
   347		}
   348	
   349	out_finish:
   350		dev_put(dev);
   351		return ret;
   352	}
   353	
   354	static int read_dev_bps_config(struct seq_file *sf, void *v)
   355	{
   356		int i;
   357	
   358		for (i = 0; i < MAX_NIC_SUPPORT; i++)
   359			if (bw_config[i].name)
   360				seq_printf(sf,
   361					   "%s rx_bps_min=%lu rx_bps_max=%lu tx_bps_min=%lu tx_bps_max=%lu\n",
   362					   bw_config[i].name,
   363					   bw_config[i].rx_bps_min,
   364					   bw_config[i].rx_bps_max,
   365					   bw_config[i].tx_bps_min,
   366					   bw_config[i].tx_bps_max);
   367		return 0;
   368	}
   369	
   370	int netqos_notifier(struct notifier_block *this,
   371			    unsigned long event, void *ptr)
   372	{
   373		struct net_device *dev = netdev_notifier_info_to_dev(ptr);
   374		struct net *net = dev_net(dev);
   375	
   376		if (!net_eq(net, &init_net))
   377			return NOTIFY_DONE;
   378	
   379		switch (event) {
   380		case NETDEV_UNREGISTER:
   381			if (dev->ifindex < MAX_NIC_SUPPORT &&
   382			    bw_config[dev->ifindex].name) {
   383				kfree(bw_config[dev->ifindex].name);
   384				bw_config[dev->ifindex].name = NULL;
   385			}
   386			break;
   387		}
   388	
   389		return NOTIFY_DONE;
   390	}
   391	EXPORT_SYMBOL_GPL(netqos_notifier);
   392	
   393	static int write_rx_min_rwnd_segs(struct cgroup_subsys_state *css,
   394					  struct cftype *cft, u64 value)
   395	{
   396		if (READ_ONCE(netcls_modfunc.write_rx_min_rwnd_segs))
   397			return netcls_modfunc.write_rx_min_rwnd_segs(css, cft, value);
   398		return 0;
   399	}
   400	
   401	static u64 read_rx_min_rwnd_segs(struct cgroup_subsys_state *css,
   402					 struct cftype *cft)
   403	{
   404		if (READ_ONCE(netcls_modfunc.read_rx_min_rwnd_segs))
   405			return netcls_modfunc.read_rx_min_rwnd_segs(css, cft);
   406		return 0;
   407	}
   408	
   409	int read_class_stat(struct seq_file *sf, void *v)
   410	{
   411		struct cgroup_subsys_state *css = seq_css(sf);
   412	
   413		if (READ_ONCE(netcls_modfunc.read_rx_stat) &&
   414		    READ_ONCE(netcls_modfunc.read_tx_stat)) {
   415			netcls_modfunc.read_rx_stat(css, sf);
   416			netcls_modfunc.read_tx_stat(css, sf);
   417		}
   418		return 0;
   419	}
   420	
 > 421	int rx_dump(struct seq_file *sf, void *v)
   422	{
   423		if (READ_ONCE(netcls_modfunc.dump_rx_tb))
   424			netcls_modfunc.dump_rx_tb(sf);
   425		return 0;
   426	}
   427	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

                 reply	other threads:[~2024-10-23 16:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=202410240035.lSlCcYd8-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=aurelianliu@tencent.com \
    --cc=deshengwu@tencent.com \
    --cc=flyingpeng@tencent.com \
    --cc=frankjpliu@tencent.com \
    --cc=jason.zeng@intel.com \
    --cc=jingqunli@tencent.com \
    --cc=kaixuxia@tencent.com \
    --cc=kasong@tencent.com \
    --cc=kernelxing@tencent.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=pei.p.jia@intel.com \
    --cc=sagazchen@tencent.com \
    --cc=wu.zheng@intel.com \
    --cc=yingbao.jia@intel.com \
    /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.