[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202202240701.bZqYmp7l-lkp@intel.com>
Date: Thu, 24 Feb 2022 07:32:51 +0800
From: kernel test robot <lkp@...el.com>
To: Ingo Molnar <mingo@...nel.org>
Cc: kbuild-all@...ts.01.org, linux-kernel@...r.kernel.org
Subject: [mingo-tip:sched/headers 605/2340] kernel/kallsyms.c:88:3: warning:
'strncpy' specified bound 128 equals destination size
tree: git://git.kernel.org/pub/scm/linux/kernel/git/mingo/tip.git sched/headers
head: 97c5eeb4de3ad324ed2a4656b46465299cfd010a
commit: 0368017257bd4ac64c10d6e64612256d5141d581 [605/2340] kallsyms/objtool: Utilize the kallsyms_syms[] table in kallsyms_expand_symbol() and kallsyms_sym_address()
config: x86_64-defconfig (https://download.01.org/0day-ci/archive/20220224/202202240701.bZqYmp7l-lkp@intel.com/config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
reproduce (this is a W=1 build):
# https://git.kernel.org/pub/scm/linux/kernel/git/mingo/tip.git/commit/?id=0368017257bd4ac64c10d6e64612256d5141d581
git remote add mingo-tip git://git.kernel.org/pub/scm/linux/kernel/git/mingo/tip.git
git fetch --no-tags mingo-tip sched/headers
git checkout 0368017257bd4ac64c10d6e64612256d5141d581
# save the config file to linux build tree
mkdir build_dir
make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@...el.com>
All warnings (new ones prefixed by >>):
kernel/kallsyms.c:636:12: warning: no previous prototype for 'arch_get_kallsym' [-Wmissing-prototypes]
636 | int __weak arch_get_kallsym(unsigned int symnum, unsigned long *value,
| ^~~~~~~~~~~~~~~~
In function 'kallsyms_expand_symbol',
inlined from 'kallsyms_lookup_name' at kernel/kallsyms.c:256:9:
>> kernel/kallsyms.c:88:3: warning: 'strncpy' specified bound 128 equals destination size [-Wstringop-truncation]
88 | strncpy(result, sym->name, maxlen);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vim +/strncpy +88 kernel/kallsyms.c
68
69 /*
70 * Expand a compressed symbol data into the resulting uncompressed string,
71 * if uncompressed string is too long (>= maxlen), it will be truncated,
72 * given the offset to where the symbol is in the compressed stream.
73 */
74 static unsigned int kallsyms_expand_symbol(unsigned int off,
75 char *result, size_t maxlen)
76 {
77 int len, skipped_first = 0;
78 const char *tptr;
79 const u8 *data;
80
81 if (WARN_ON_ONCE(!result || !maxlen))
82 return 0;
83
84 #ifdef CONFIG_KALLSYMS_FAST
85 {
86 struct kallsyms_sym *sym = kallsyms_syms + off;
87
> 88 strncpy(result, sym->name, maxlen);
89
90 return off + 1;
91 }
92 #endif
93 /* Get the compressed symbol length from the first symbol byte. */
94 data = &kallsyms_names[off];
95 len = *data;
96 data++;
97
98 /*
99 * Update the offset to return the offset for the next symbol on
100 * the compressed stream.
101 */
102 off += len + 1;
103
104 /*
105 * For every byte on the compressed symbol data, copy the table
106 * entry for that byte.
107 */
108 while (len) {
109 tptr = &kallsyms_token_table[kallsyms_token_index[*data]];
110 data++;
111 len--;
112
113 while (*tptr) {
114 if (skipped_first) {
115 if (maxlen <= 1)
116 goto tail;
117 *result = *tptr;
118 result++;
119 maxlen--;
120 } else
121 skipped_first = 1;
122 tptr++;
123 }
124 }
125
126 tail:
127 if (maxlen)
128 *result = '\0';
129
130 /* Return to offset to the next symbol. */
131 return off;
132 }
133
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Powered by blists - more mailing lists