2023-11-03 17:37:05

by kernel test robot

[permalink] [raw]
Subject: drivers/vdpa/pds/debugfs.c:269:49: warning: '%02d' directive output may be truncated writing between 2 and 11 bytes into a region of size 6

tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 8f6f76a6a29f36d2f3e4510d0bde5046672f6924
commit: 9a8864d2a8dc5c49acd66284fd382871d99b5db8 pds_vdpa: pds_vdps.rst and Kconfig
date: 4 months ago
config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20231104/[email protected]/config)
compiler: alpha-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231104/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

drivers/vdpa/pds/debugfs.c: In function 'pds_vdpa_debugfs_add_vdpadev':
>> drivers/vdpa/pds/debugfs.c:269:49: warning: '%02d' directive output may be truncated writing between 2 and 11 bytes into a region of size 6 [-Wformat-truncation=]
269 | snprintf(name, sizeof(name), "vq%02d", i);
| ^~~~
drivers/vdpa/pds/debugfs.c:269:46: note: directive argument in the range [-2147483641, 254]
269 | snprintf(name, sizeof(name), "vq%02d", i);
| ^~~~~~~~
drivers/vdpa/pds/debugfs.c:269:17: note: 'snprintf' output between 5 and 14 bytes into a destination of size 8
269 | snprintf(name, sizeof(name), "vq%02d", i);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +269 drivers/vdpa/pds/debugfs.c

151cc834f3ddafe Shannon Nelson 2023-05-19 259
151cc834f3ddafe Shannon Nelson 2023-05-19 260 void pds_vdpa_debugfs_add_vdpadev(struct pds_vdpa_aux *vdpa_aux)
151cc834f3ddafe Shannon Nelson 2023-05-19 261 {
151cc834f3ddafe Shannon Nelson 2023-05-19 262 int i;
151cc834f3ddafe Shannon Nelson 2023-05-19 263
151cc834f3ddafe Shannon Nelson 2023-05-19 264 debugfs_create_file("config", 0400, vdpa_aux->dentry, vdpa_aux->pdsv, &config_fops);
151cc834f3ddafe Shannon Nelson 2023-05-19 265
151cc834f3ddafe Shannon Nelson 2023-05-19 266 for (i = 0; i < vdpa_aux->pdsv->num_vqs; i++) {
151cc834f3ddafe Shannon Nelson 2023-05-19 267 char name[8];
151cc834f3ddafe Shannon Nelson 2023-05-19 268
151cc834f3ddafe Shannon Nelson 2023-05-19 @269 snprintf(name, sizeof(name), "vq%02d", i);
151cc834f3ddafe Shannon Nelson 2023-05-19 270 debugfs_create_file(name, 0400, vdpa_aux->dentry,
151cc834f3ddafe Shannon Nelson 2023-05-19 271 &vdpa_aux->pdsv->vqs[i], &vq_fops);
151cc834f3ddafe Shannon Nelson 2023-05-19 272 }
151cc834f3ddafe Shannon Nelson 2023-05-19 273 }
151cc834f3ddafe Shannon Nelson 2023-05-19 274

:::::: The code at line 269 was first introduced by commit
:::::: 151cc834f3ddafec869269fe48036460d920d08a pds_vdpa: add support for vdpa and vdpamgmt interfaces

:::::: TO: Shannon Nelson <[email protected]>
:::::: CC: Michael S. Tsirkin <[email protected]>

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


2023-11-05 12:58:59

by Michael S. Tsirkin

[permalink] [raw]
Subject: Re: drivers/vdpa/pds/debugfs.c:269:49: warning: '%02d' directive output may be truncated writing between 2 and 11 bytes into a region of size 6

On Sat, Nov 04, 2023 at 01:36:05AM +0800, kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: 8f6f76a6a29f36d2f3e4510d0bde5046672f6924
> commit: 9a8864d2a8dc5c49acd66284fd382871d99b5db8 pds_vdpa: pds_vdps.rst and Kconfig
> date: 4 months ago
> config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20231104/[email protected]/config)
> compiler: alpha-linux-gcc (GCC) 13.2.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231104/[email protected]/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 <[email protected]>
> | Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
>
> All warnings (new ones prefixed by >>):
>
> drivers/vdpa/pds/debugfs.c: In function 'pds_vdpa_debugfs_add_vdpadev':
> >> drivers/vdpa/pds/debugfs.c:269:49: warning: '%02d' directive output may be truncated writing between 2 and 11 bytes into a region of size 6 [-Wformat-truncation=]
> 269 | snprintf(name, sizeof(name), "vq%02d", i);
> | ^~~~
> drivers/vdpa/pds/debugfs.c:269:46: note: directive argument in the range [-2147483641, 254]
> 269 | snprintf(name, sizeof(name), "vq%02d", i);
> | ^~~~~~~~
> drivers/vdpa/pds/debugfs.c:269:17: note: 'snprintf' output between 5 and 14 bytes into a destination of size 8
> 269 | snprintf(name, sizeof(name), "vq%02d", i);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
> vim +269 drivers/vdpa/pds/debugfs.c

> 151cc834f3ddafe Shannon Nelson 2023-05-19 259
> 151cc834f3ddafe Shannon Nelson 2023-05-19 260 void pds_vdpa_debugfs_add_vdpadev(struct pds_vdpa_aux *vdpa_aux)
> 151cc834f3ddafe Shannon Nelson 2023-05-19 261 {
> 151cc834f3ddafe Shannon Nelson 2023-05-19 262 int i;
> 151cc834f3ddafe Shannon Nelson 2023-05-19 263
> 151cc834f3ddafe Shannon Nelson 2023-05-19 264 debugfs_create_file("config", 0400, vdpa_aux->dentry, vdpa_aux->pdsv, &config_fops);
> 151cc834f3ddafe Shannon Nelson 2023-05-19 265
> 151cc834f3ddafe Shannon Nelson 2023-05-19 266 for (i = 0; i < vdpa_aux->pdsv->num_vqs; i++) {
> 151cc834f3ddafe Shannon Nelson 2023-05-19 267 char name[8];
> 151cc834f3ddafe Shannon Nelson 2023-05-19 268
> 151cc834f3ddafe Shannon Nelson 2023-05-19 @269 snprintf(name, sizeof(name), "vq%02d", i);
> 151cc834f3ddafe Shannon Nelson 2023-05-19 270 debugfs_create_file(name, 0400, vdpa_aux->dentry,
> 151cc834f3ddafe Shannon Nelson 2023-05-19 271 &vdpa_aux->pdsv->vqs[i], &vq_fops);
> 151cc834f3ddafe Shannon Nelson 2023-05-19 272 }
> 151cc834f3ddafe Shannon Nelson 2023-05-19 273 }
> 151cc834f3ddafe Shannon Nelson 2023-05-19 274


So gcc can't figure out that i is positive in this loop :(

Let's make it unsigned I guess? Should calm it down.

Shannon could you send a patch please?

>
> :::::: The code at line 269 was first introduced by commit
> :::::: 151cc834f3ddafec869269fe48036460d920d08a pds_vdpa: add support for vdpa and vdpamgmt interfaces
>
> :::::: TO: Shannon Nelson <[email protected]>
> :::::: CC: Michael S. Tsirkin <[email protected]>
>
> --
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki

2023-11-06 05:20:51

by Nelson, Shannon

[permalink] [raw]
Subject: Re: drivers/vdpa/pds/debugfs.c:269:49: warning: '%02d' directive output may be truncated writing between 2 and 11 bytes into a region of size 6

On 11/5/2023 4:57 AM, Michael S. Tsirkin wrote:
> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
>
>
> On Sat, Nov 04, 2023 at 01:36:05AM +0800, kernel test robot wrote:
>> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
>> head: 8f6f76a6a29f36d2f3e4510d0bde5046672f6924
>> commit: 9a8864d2a8dc5c49acd66284fd382871d99b5db8 pds_vdpa: pds_vdps.rst and Kconfig
>> date: 4 months ago
>> config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20231104/[email protected]/config)
>> compiler: alpha-linux-gcc (GCC) 13.2.0
>> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231104/[email protected]/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 <[email protected]>
>> | Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
>>
>> All warnings (new ones prefixed by >>):
>>
>> drivers/vdpa/pds/debugfs.c: In function 'pds_vdpa_debugfs_add_vdpadev':
>>>> drivers/vdpa/pds/debugfs.c:269:49: warning: '%02d' directive output may be truncated writing between 2 and 11 bytes into a region of size 6 [-Wformat-truncation=]
>> 269 | snprintf(name, sizeof(name), "vq%02d", i);
>> | ^~~~
>> drivers/vdpa/pds/debugfs.c:269:46: note: directive argument in the range [-2147483641, 254]
>> 269 | snprintf(name, sizeof(name), "vq%02d", i);
>> | ^~~~~~~~
>> drivers/vdpa/pds/debugfs.c:269:17: note: 'snprintf' output between 5 and 14 bytes into a destination of size 8
>> 269 | snprintf(name, sizeof(name), "vq%02d", i);
>> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>>
>> vim +269 drivers/vdpa/pds/debugfs.c
>
>> 151cc834f3ddafe Shannon Nelson 2023-05-19 259
>> 151cc834f3ddafe Shannon Nelson 2023-05-19 260 void pds_vdpa_debugfs_add_vdpadev(struct pds_vdpa_aux *vdpa_aux)
>> 151cc834f3ddafe Shannon Nelson 2023-05-19 261 {
>> 151cc834f3ddafe Shannon Nelson 2023-05-19 262 int i;
>> 151cc834f3ddafe Shannon Nelson 2023-05-19 263
>> 151cc834f3ddafe Shannon Nelson 2023-05-19 264 debugfs_create_file("config", 0400, vdpa_aux->dentry, vdpa_aux->pdsv, &config_fops);
>> 151cc834f3ddafe Shannon Nelson 2023-05-19 265
>> 151cc834f3ddafe Shannon Nelson 2023-05-19 266 for (i = 0; i < vdpa_aux->pdsv->num_vqs; i++) {
>> 151cc834f3ddafe Shannon Nelson 2023-05-19 267 char name[8];
>> 151cc834f3ddafe Shannon Nelson 2023-05-19 268
>> 151cc834f3ddafe Shannon Nelson 2023-05-19 @269 snprintf(name, sizeof(name), "vq%02d", i);
>> 151cc834f3ddafe Shannon Nelson 2023-05-19 270 debugfs_create_file(name, 0400, vdpa_aux->dentry,
>> 151cc834f3ddafe Shannon Nelson 2023-05-19 271 &vdpa_aux->pdsv->vqs[i], &vq_fops);
>> 151cc834f3ddafe Shannon Nelson 2023-05-19 272 }
>> 151cc834f3ddafe Shannon Nelson 2023-05-19 273 }
>> 151cc834f3ddafe Shannon Nelson 2023-05-19 274
>
>
> So gcc can't figure out that i is positive in this loop :(
>
> Let's make it unsigned I guess? Should calm it down.
>
> Shannon could you send a patch please?

Yes, I've been a little snowed under the last couple of weeks, but will
try to get to this and a couple other similar complaints in the next
week or so.

sln


>
>>
>> :::::: The code at line 269 was first introduced by commit
>> :::::: 151cc834f3ddafec869269fe48036460d920d08a pds_vdpa: add support for vdpa and vdpamgmt interfaces
>>
>> :::::: TO: Shannon Nelson <[email protected]>
>> :::::: CC: Michael S. Tsirkin <[email protected]>
>>
>> --
>> 0-DAY CI Kernel Test Service
>> https://github.com/intel/lkp-tests/wiki
>