lkml.org 
[lkml]   [2022]   [Jun]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] rpmsg: strcpy is not safe, use strncpy
Hi Saud,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on v5.19-rc1]
[also build test WARNING on next-20220609]
[cannot apply to remoteproc/rpmsg-next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/intel-lab-lkp/linux/commits/Saud-Farooqui/rpmsg-strcpy-is-not-safe-use-strncpy/20220609-024555
base: f2906aa863381afb0015a9eb7fefad885d4e5a56
config: sparc64-randconfig-r026-20220609 (https://download.01.org/0day-ci/archive/20220610/202206100428.A3CCM24E-lkp@intel.com/config)
compiler: sparc64-linux-gcc (GCC) 11.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/b6e6a64ab89042911604aa4741584a422cdfe8a5
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Saud-Farooqui/rpmsg-strcpy-is-not-safe-use-strncpy/20220609-024555
git checkout b6e6a64ab89042911604aa4741584a422cdfe8a5
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross W=1 O=build_dir ARCH=sparc64 SHELL=/bin/bash drivers/rpmsg/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

drivers/rpmsg/rpmsg_core.c: In function 'rpmsg_register_device_override':
>> drivers/rpmsg/rpmsg_core.c:607:17: warning: 'strncpy' specified bound 32 equals destination size [-Wstringop-truncation]
607 | strncpy(rpdev->id.name, driver_override, sizeof(rpdev->id.name));
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +/strncpy +607 drivers/rpmsg/rpmsg_core.c

595
596 /*
597 * A helper for registering rpmsg device with driver override and name.
598 * Drivers should not be using it, but instead rpmsg_register_device().
599 */
600 int rpmsg_register_device_override(struct rpmsg_device *rpdev,
601 const char *driver_override)
602 {
603 struct device *dev = &rpdev->dev;
604 int ret;
605
606 if (driver_override)
> 607 strncpy(rpdev->id.name, driver_override, sizeof(rpdev->id.name));
608
609 dev_set_name(dev, "%s.%s.%d.%d", dev_name(dev->parent),
610 rpdev->id.name, rpdev->src, rpdev->dst);
611
612 dev->bus = &rpmsg_bus;
613
614 device_initialize(dev);
615 if (driver_override) {
616 ret = driver_set_override(dev, &rpdev->driver_override,
617 driver_override,
618 strlen(driver_override));
619 if (ret) {
620 dev_err(dev, "device_set_override failed: %d\n", ret);
621 return ret;
622 }
623 }
624
625 ret = device_add(dev);
626 if (ret) {
627 dev_err(dev, "device_add failed: %d\n", ret);
628 kfree(rpdev->driver_override);
629 rpdev->driver_override = NULL;
630 put_device(dev);
631 }
632
633 return ret;
634 }
635 EXPORT_SYMBOL(rpmsg_register_device_override);
636

--
0-DAY CI Kernel Test Service
https://01.org/lkp

\
 
 \ /
  Last update: 2022-06-09 23:11    [W:0.144 / U:1.404 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site