* drivers/xen/manage.c:337:60: warning: '%s' directive output may be truncated writing up to 95 bytes into a region of size 12
@ 2023-11-18 20:08 kernel test robot
0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2023-11-18 20:08 UTC (permalink / raw)
To: Juergen Gross; +Cc: oe-kbuild-all, linux-kernel, David Vrabel, Paul Durrant
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 05aa69b096a089dc85391e36ccdce76961694e22
commit: 44b3c7af02ca2701b6b90ee30c9d1d9c3ae07653 xenbus: advertise control feature flags
date: 7 years ago
config: x86_64-randconfig-r031-20230816 (https://download.01.org/0day-ci/archive/20231119/202311190459.zOWcFodz-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/202311190459.zOWcFodz-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/202311190459.zOWcFodz-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from include/linux/kobject.h:21,
from include/linux/device.h:17,
from include/linux/node.h:17,
from include/linux/cpu.h:16,
from include/linux/stop_machine.h:4,
from drivers/xen/manage.c:12:
include/linux/sysfs.h: In function 'sysfs_get_dirent':
include/linux/sysfs.h:517:44: warning: pointer targets in passing argument 2 of 'kernfs_find_and_get' differ in signedness [-Wpointer-sign]
517 | return kernfs_find_and_get(parent, name);
| ^~~~
| |
| const unsigned char *
In file included from include/linux/sysfs.h:15:
include/linux/kernfs.h:440:57: note: expected 'const char *' but argument is of type 'const unsigned char *'
440 | kernfs_find_and_get(struct kernfs_node *kn, const char *name)
| ~~~~~~~~~~~~^~~~
drivers/xen/manage.c: In function 'shutdown_event':
>> drivers/xen/manage.c:337:60: warning: '%s' directive output may be truncated writing up to 95 bytes into a region of size 12 [-Wformat-truncation=]
337 | snprintf(node, FEATURE_PATH_SIZE, "feature-%s",
| ^~
In function 'setup_shutdown_watcher',
inlined from 'shutdown_event' at drivers/xen/manage.c:349:2:
drivers/xen/manage.c:337:17: note: 'snprintf' output between 9 and 104 bytes into a destination of size 20
337 | snprintf(node, FEATURE_PATH_SIZE, "feature-%s",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
338 | shutdown_handlers[idx].command);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vim +337 drivers/xen/manage.c
333
334 for (idx = 0; idx < ARRAY_SIZE(shutdown_handlers); idx++) {
335 if (!shutdown_handlers[idx].flag)
336 continue;
> 337 snprintf(node, FEATURE_PATH_SIZE, "feature-%s",
338 shutdown_handlers[idx].command);
339 xenbus_printf(XBT_NIL, "control", node, "%u", 1);
340 }
341
342 return 0;
343 }
344
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
* drivers/xen/manage.c:337:60: warning: '%s' directive output may be truncated writing up to 95 bytes into a region of size 12
@ 2023-12-03 19:55 kernel test robot
2023-12-04 7:35 ` Juergen Gross
0 siblings, 1 reply; 3+ messages in thread
From: kernel test robot @ 2023-12-03 19:55 UTC (permalink / raw)
To: Juergen Gross; +Cc: oe-kbuild-all, linux-kernel, David Vrabel, Paul Durrant
Hi Juergen,
FYI, the error/warning still remains.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 33cc938e65a98f1d29d0a18403dbbee050dcad9a
commit: 44b3c7af02ca2701b6b90ee30c9d1d9c3ae07653 xenbus: advertise control feature flags
date: 7 years ago
config: x86_64-randconfig-015-20231009 (https://download.01.org/0day-ci/archive/20231204/202312040309.sACmAKoo-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/20231204/202312040309.sACmAKoo-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/202312040309.sACmAKoo-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from include/linux/kobject.h:21,
from include/linux/device.h:17,
from include/linux/node.h:17,
from include/linux/cpu.h:16,
from include/linux/stop_machine.h:4,
from drivers/xen/manage.c:12:
include/linux/sysfs.h: In function 'sysfs_get_dirent':
include/linux/sysfs.h:517:44: warning: pointer targets in passing argument 2 of 'kernfs_find_and_get' differ in signedness [-Wpointer-sign]
517 | return kernfs_find_and_get(parent, name);
| ^~~~
| |
| const unsigned char *
In file included from include/linux/sysfs.h:15:
include/linux/kernfs.h:440:57: note: expected 'const char *' but argument is of type 'const unsigned char *'
440 | kernfs_find_and_get(struct kernfs_node *kn, const char *name)
| ~~~~~~~~~~~~^~~~
drivers/xen/manage.c: In function 'shutdown_event':
>> drivers/xen/manage.c:337:60: warning: '%s' directive output may be truncated writing up to 95 bytes into a region of size 12 [-Wformat-truncation=]
337 | snprintf(node, FEATURE_PATH_SIZE, "feature-%s",
| ^~
In function 'setup_shutdown_watcher',
inlined from 'shutdown_event' at drivers/xen/manage.c:349:2:
drivers/xen/manage.c:337:17: note: 'snprintf' output between 9 and 104 bytes into a destination of size 20
337 | snprintf(node, FEATURE_PATH_SIZE, "feature-%s",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
338 | shutdown_handlers[idx].command);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vim +337 drivers/xen/manage.c
333
334 for (idx = 0; idx < ARRAY_SIZE(shutdown_handlers); idx++) {
335 if (!shutdown_handlers[idx].flag)
336 continue;
> 337 snprintf(node, FEATURE_PATH_SIZE, "feature-%s",
338 shutdown_handlers[idx].command);
339 xenbus_printf(XBT_NIL, "control", node, "%u", 1);
340 }
341
342 return 0;
343 }
344
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: drivers/xen/manage.c:337:60: warning: '%s' directive output may be truncated writing up to 95 bytes into a region of size 12
2023-12-03 19:55 drivers/xen/manage.c:337:60: warning: '%s' directive output may be truncated writing up to 95 bytes into a region of size 12 kernel test robot
@ 2023-12-04 7:35 ` Juergen Gross
0 siblings, 0 replies; 3+ messages in thread
From: Juergen Gross @ 2023-12-04 7:35 UTC (permalink / raw)
To: kernel test robot; +Cc: oe-kbuild-all, linux-kernel, Paul Durrant
[-- Attachment #1.1.1: Type: text/plain, Size: 4247 bytes --]
On 03.12.23 20:55, kernel test robot wrote:
> Hi Juergen,
>
> FYI, the error/warning still remains.
>
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: 33cc938e65a98f1d29d0a18403dbbee050dcad9a
> commit: 44b3c7af02ca2701b6b90ee30c9d1d9c3ae07653 xenbus: advertise control feature flags
> date: 7 years ago
> config: x86_64-randconfig-015-20231009 (https://download.01.org/0day-ci/archive/20231204/202312040309.sACmAKoo-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/20231204/202312040309.sACmAKoo-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/202312040309.sACmAKoo-lkp@intel.com/
>
> All warnings (new ones prefixed by >>):
>
> In file included from include/linux/kobject.h:21,
> from include/linux/device.h:17,
> from include/linux/node.h:17,
> from include/linux/cpu.h:16,
> from include/linux/stop_machine.h:4,
> from drivers/xen/manage.c:12:
> include/linux/sysfs.h: In function 'sysfs_get_dirent':
> include/linux/sysfs.h:517:44: warning: pointer targets in passing argument 2 of 'kernfs_find_and_get' differ in signedness [-Wpointer-sign]
> 517 | return kernfs_find_and_get(parent, name);
> | ^~~~
> | |
> | const unsigned char *
> In file included from include/linux/sysfs.h:15:
> include/linux/kernfs.h:440:57: note: expected 'const char *' but argument is of type 'const unsigned char *'
> 440 | kernfs_find_and_get(struct kernfs_node *kn, const char *name)
> | ~~~~~~~~~~~~^~~~
> drivers/xen/manage.c: In function 'shutdown_event':
>>> drivers/xen/manage.c:337:60: warning: '%s' directive output may be truncated writing up to 95 bytes into a region of size 12 [-Wformat-truncation=]
> 337 | snprintf(node, FEATURE_PATH_SIZE, "feature-%s",
> | ^~
> In function 'setup_shutdown_watcher',
> inlined from 'shutdown_event' at drivers/xen/manage.c:349:2:
> drivers/xen/manage.c:337:17: note: 'snprintf' output between 9 and 104 bytes into a destination of size 20
> 337 | snprintf(node, FEATURE_PATH_SIZE, "feature-%s",
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 338 | shutdown_handlers[idx].command);
> | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
IMHO this is a false analysis.
shutdown_handlers[] is:
struct shutdown_handler {
#define SHUTDOWN_CMD_SIZE 11
const char command[SHUTDOWN_CMD_SIZE];
bool flag;
void (*cb)(void);
};
static struct shutdown_handler shutdown_handlers[] = {
{ "poweroff", true, do_poweroff },
{ "halt", false, do_poweroff },
{ "reboot", true, do_reboot },
#ifdef CONFIG_HIBERNATE_CALLBACKS
{ "suspend", true, do_suspend },
#endif
};
And it is never changed.
We have:
#define FEATURE_PATH_SIZE (SHUTDOWN_CMD_SIZE + sizeof("feature-"))
char node[FEATURE_PATH_SIZE];
So how on earth could the snprintf() destination not be large enough?
> vim +337 drivers/xen/manage.c
>
> 333
> 334 for (idx = 0; idx < ARRAY_SIZE(shutdown_handlers); idx++) {
> 335 if (!shutdown_handlers[idx].flag)
> 336 continue;
> > 337 snprintf(node, FEATURE_PATH_SIZE, "feature-%s",
> 338 shutdown_handlers[idx].command);
> 339 xenbus_printf(XBT_NIL, "control", node, "%u", 1);
> 340 }
> 341
> 342 return 0;
> 343 }
> 344
>
Juergen
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 3743 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 495 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-12-04 7:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-03 19:55 drivers/xen/manage.c:337:60: warning: '%s' directive output may be truncated writing up to 95 bytes into a region of size 12 kernel test robot
2023-12-04 7:35 ` Juergen Gross
-- strict thread matches above, loose matches on Subject: below --
2023-11-18 20:08 kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox