lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Sun, 19 Nov 2023 10:51:31 +0800
From:   kernel test robot <lkp@...el.com>
To:     Shaohua Li <shli@...com>
Cc:     oe-kbuild-all@...ts.linux.dev, linux-kernel@...r.kernel.org,
        Jens Axboe <axboe@...nel.dk>
Subject: block/blk-throttle.c:1488:74: warning: 'snprintf' output may be
 truncated before the last format character

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   b8f1fa2419c19c81bc386a6b350879ba54a573e1
commit: ada75b6e5b2a939401d4919dfaf2f2fc9484f68a blk-throttle: add interface to configure idle time threshold
date:   7 years ago
config: x86_64-randconfig-r031-20230816 (https://download.01.org/0day-ci/archive/20231119/202311191030.CRFJc6T4-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231119/202311191030.CRFJc6T4-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@...el.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202311191030.CRFJc6T4-lkp@intel.com/

All warnings (new ones prefixed by >>):

   block/blk-throttle.c:1675:13: warning: 'throtl_tg_is_idle' defined but not used [-Wunused-function]
    1675 | static bool throtl_tg_is_idle(struct throtl_grp *tg)
         |             ^~~~~~~~~~~~~~~~~
   block/blk-throttle.c: In function 'tg_prfill_limit':
>> block/blk-throttle.c:1488:74: warning: 'snprintf' output may be truncated before the last format character [-Wformat-truncation=]
    1488 |                         snprintf(idle_time, sizeof(idle_time), " idle=%lu",
         |                                                                          ^
   block/blk-throttle.c:1488:25: note: 'snprintf' output between 8 and 27 bytes into a destination of size 26
    1488 |                         snprintf(idle_time, sizeof(idle_time), " idle=%lu",
         |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1489 |                                 tg->idletime_threshold);
         |                                 ~~~~~~~~~~~~~~~~~~~~~~~


vim +/snprintf +1488 block/blk-throttle.c

  1442	
  1443	static u64 tg_prfill_limit(struct seq_file *sf, struct blkg_policy_data *pd,
  1444				 int off)
  1445	{
  1446		struct throtl_grp *tg = pd_to_tg(pd);
  1447		const char *dname = blkg_dev_name(pd->blkg);
  1448		char bufs[4][21] = { "max", "max", "max", "max" };
  1449		u64 bps_dft;
  1450		unsigned int iops_dft;
  1451		char idle_time[26] = "";
  1452	
  1453		if (!dname)
  1454			return 0;
  1455	
  1456		if (off == LIMIT_LOW) {
  1457			bps_dft = 0;
  1458			iops_dft = 0;
  1459		} else {
  1460			bps_dft = U64_MAX;
  1461			iops_dft = UINT_MAX;
  1462		}
  1463	
  1464		if (tg->bps_conf[READ][off] == bps_dft &&
  1465		    tg->bps_conf[WRITE][off] == bps_dft &&
  1466		    tg->iops_conf[READ][off] == iops_dft &&
  1467		    tg->iops_conf[WRITE][off] == iops_dft &&
  1468		    (off != LIMIT_LOW || tg->idletime_threshold ==
  1469					  tg->td->dft_idletime_threshold))
  1470			return 0;
  1471	
  1472		if (tg->bps_conf[READ][off] != bps_dft)
  1473			snprintf(bufs[0], sizeof(bufs[0]), "%llu",
  1474				tg->bps_conf[READ][off]);
  1475		if (tg->bps_conf[WRITE][off] != bps_dft)
  1476			snprintf(bufs[1], sizeof(bufs[1]), "%llu",
  1477				tg->bps_conf[WRITE][off]);
  1478		if (tg->iops_conf[READ][off] != iops_dft)
  1479			snprintf(bufs[2], sizeof(bufs[2]), "%u",
  1480				tg->iops_conf[READ][off]);
  1481		if (tg->iops_conf[WRITE][off] != iops_dft)
  1482			snprintf(bufs[3], sizeof(bufs[3]), "%u",
  1483				tg->iops_conf[WRITE][off]);
  1484		if (off == LIMIT_LOW) {
  1485			if (tg->idletime_threshold == ULONG_MAX)
  1486				strcpy(idle_time, " idle=max");
  1487			else
> 1488				snprintf(idle_time, sizeof(idle_time), " idle=%lu",
  1489					tg->idletime_threshold);
  1490		}
  1491	
  1492		seq_printf(sf, "%s rbps=%s wbps=%s riops=%s wiops=%s%s\n",
  1493			   dname, bufs[0], bufs[1], bufs[2], bufs[3], idle_time);
  1494		return 0;
  1495	}
  1496	

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

Powered by blists - more mailing lists