Messages in this thread | | | Date | Thu, 17 Mar 2022 20:26:59 +0800 | From | kernel test robot <> | Subject | [mingo-tip:master 592/2335] 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 master head: 85293bf3fca6d85608cff1447ce3097583f15fab commit: 37139bbbb8552f3151a0344dc39d572fabbf4061 [592/2335] 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/20220317/202203172007.S4q5m0Xm-lkp@intel.com/config) compiler: gcc-9 (Ubuntu 9.4.0-1ubuntu1~20.04) 9.4.0 reproduce (this is a W=1 build): # https://git.kernel.org/pub/scm/linux/kernel/git/mingo/tip.git/commit/?id=37139bbbb8552f3151a0344dc39d572fabbf4061 git remote add mingo-tip git://git.kernel.org/pub/scm/linux/kernel/git/mingo/tip.git git fetch --no-tags mingo-tip master git checkout 37139bbbb8552f3151a0344dc39d572fabbf4061 # 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@intel.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 https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
| |