include/linux/netlink.h:116:6: warning: ' TXQs for network stack (total ' directive output truncated writing 31 bytes into a region of size between 0 and 14

From: kernel test robot
Date: Mon Nov 06 2023 - 00:28:50 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: d2f51b3516dade79269ff45eae2a7668ae711b25
commit: 800db2d125c2bc22c448e2386c3518e663d6db71 net: enetc: ensure we always have a minimum number of TXQs for stack
date: 9 months ago
config: x86_64-buildonly-randconfig-006-20231106 (https://download.01.org/0day-ci/archive/20231106/202311061336.4dsWMT1h-lkp@xxxxxxxxx/config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231106/202311061336.4dsWMT1h-lkp@xxxxxxxxx/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@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202311061336.4dsWMT1h-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

In file included from include/uapi/linux/neighbour.h:6:0,
from include/linux/netdevice.h:46,
from drivers/net/ethernet/freescale/enetc/enetc.h:6,
from drivers/net/ethernet/freescale/enetc/enetc.c:4:
drivers/net/ethernet/freescale/enetc/enetc.c: In function 'enetc_setup_bpf':
>> include/linux/netlink.h:116:6: warning: ' TXQs for network stack (total ' directive output truncated writing 31 bytes into a region of size between 0 and 14 [-Wformat-truncation=]
if (snprintf(__extack->_msg_buf, NETLINK_MAX_FMTMSG_LEN, \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"%s" fmt "%s", "", ##args, "") >= \
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/netlink.h:131:2: note: in expansion of macro 'NL_SET_ERR_MSG_FMT'
NL_SET_ERR_MSG_FMT((extack), KBUILD_MODNAME ": " fmt, ##args)
^~~~~~~~~~~~~~~~~~
drivers/net/ethernet/freescale/enetc/enetc.c:2713:3: note: in expansion of macro 'NL_SET_ERR_MSG_FMT_MOD'
NL_SET_ERR_MSG_FMT_MOD(extack,
^~~~~~~~~~~~~~~~~~~~~~
include/linux/netlink.h:116:6: note: directive argument in the range [0, 65535]
if (snprintf(__extack->_msg_buf, NETLINK_MAX_FMTMSG_LEN, \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"%s" fmt "%s", "", ##args, "") >= \
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/netlink.h:131:2: note: in expansion of macro 'NL_SET_ERR_MSG_FMT'
NL_SET_ERR_MSG_FMT((extack), KBUILD_MODNAME ": " fmt, ##args)
^~~~~~~~~~~~~~~~~~
drivers/net/ethernet/freescale/enetc/enetc.c:2713:3: note: in expansion of macro 'NL_SET_ERR_MSG_FMT_MOD'
NL_SET_ERR_MSG_FMT_MOD(extack,
^~~~~~~~~~~~~~~~~~~~~~
include/linux/netlink.h:116:6: note: 'snprintf' output between 110 and 134 bytes into a destination of size 80
if (snprintf(__extack->_msg_buf, NETLINK_MAX_FMTMSG_LEN, \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"%s" fmt "%s", "", ##args, "") >= \
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/netlink.h:131:2: note: in expansion of macro 'NL_SET_ERR_MSG_FMT'
NL_SET_ERR_MSG_FMT((extack), KBUILD_MODNAME ": " fmt, ##args)
^~~~~~~~~~~~~~~~~~
drivers/net/ethernet/freescale/enetc/enetc.c:2713:3: note: in expansion of macro 'NL_SET_ERR_MSG_FMT_MOD'
NL_SET_ERR_MSG_FMT_MOD(extack,
^~~~~~~~~~~~~~~~~~~~~~


vim +116 include/linux/netlink.h

2d4bc93368f5a0 Johannes Berg 2017-04-12 107
51c352bdbcd23d Edward Cree 2022-10-18 108 /* We splice fmt with %s at each end even in the snprintf so that both calls
51c352bdbcd23d Edward Cree 2022-10-18 109 * can use the same string constant, avoiding its duplication in .ro
51c352bdbcd23d Edward Cree 2022-10-18 110 */
51c352bdbcd23d Edward Cree 2022-10-18 111 #define NL_SET_ERR_MSG_FMT(extack, fmt, args...) do { \
51c352bdbcd23d Edward Cree 2022-10-18 112 struct netlink_ext_ack *__extack = (extack); \
51c352bdbcd23d Edward Cree 2022-10-18 113 \
51c352bdbcd23d Edward Cree 2022-10-18 114 if (!__extack) \
51c352bdbcd23d Edward Cree 2022-10-18 115 break; \
51c352bdbcd23d Edward Cree 2022-10-18 @116 if (snprintf(__extack->_msg_buf, NETLINK_MAX_FMTMSG_LEN, \
51c352bdbcd23d Edward Cree 2022-10-18 117 "%s" fmt "%s", "", ##args, "") >= \
51c352bdbcd23d Edward Cree 2022-10-18 118 NETLINK_MAX_FMTMSG_LEN) \
51c352bdbcd23d Edward Cree 2022-10-18 119 net_warn_ratelimited("%s" fmt "%s", "truncated extack: ", \
51c352bdbcd23d Edward Cree 2022-10-18 120 ##args, "\n"); \
51c352bdbcd23d Edward Cree 2022-10-18 121 \
51c352bdbcd23d Edward Cree 2022-10-18 122 do_trace_netlink_extack(__extack->_msg_buf); \
51c352bdbcd23d Edward Cree 2022-10-18 123 \
51c352bdbcd23d Edward Cree 2022-10-18 124 __extack->_msg = __extack->_msg_buf; \
51c352bdbcd23d Edward Cree 2022-10-18 125 } while (0)
51c352bdbcd23d Edward Cree 2022-10-18 126

:::::: The code at line 116 was first introduced by commit
:::::: 51c352bdbcd23d7ce46b06c1e64c82754dc44044 netlink: add support for formatted extack messages

:::::: TO: Edward Cree <ecree.xilinx@xxxxxxxxx>
:::::: CC: Jakub Kicinski <kuba@xxxxxxxxxx>

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