linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Stephen Boyd <swboyd@chromium.org>
Cc: oe-kbuild-all@lists.linux.dev, linux-kernel@vger.kernel.org,
	Bixuan Cui <cuibixuan@huawei.com>,
	Randy Dunlap <rdunlap@infradead.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linux Memory Management List <linux-mm@kvack.org>
Subject: kernel/kallsyms.c:436:17: warning: 'strcpy' source argument is the same as destination
Date: Fri, 3 Nov 2023 05:13:35 +0800	[thread overview]
Message-ID: <202311030538.uBMcnne0-lkp@intel.com> (raw)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   4652b8e4f3ffa48c706ec334f048c217a7d9750d
commit: 9294523e3768030ae8afb84110bcecc66425a647 module: add printk formats to add module build ID to stacktraces
date:   2 years, 4 months ago
config: x86_64-buildonly-randconfig-002-20231102 (https://download.01.org/0day-ci/archive/20231103/202311030538.uBMcnne0-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231103/202311030538.uBMcnne0-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/202311030538.uBMcnne0-lkp@intel.com/

All warnings (new ones prefixed by >>):

   kernel/kallsyms.c:566:12: warning: no previous prototype for 'arch_get_kallsym' [-Wmissing-prototypes]
     566 | int __weak arch_get_kallsym(unsigned int symnum, unsigned long *value,
         |            ^~~~~~~~~~~~~~~~
   kernel/kallsyms.c: In function '__sprint_symbol.constprop':
>> kernel/kallsyms.c:436:17: warning: 'strcpy' source argument is the same as destination [-Wrestrict]
     436 |                 strcpy(buffer, name);
         |                 ^~~~~~~~~~~~~~~~~~~~


vim +/strcpy +436 kernel/kallsyms.c

a5c43dae7ae38c Alexey Dobriyan 2007-05-08  418  
42e380832a6911 Robert Peterson 2007-04-30  419  /* Look up a kernel symbol and return it in a text buffer. */
0f77a8d378254f Namhyung Kim    2011-03-24  420  static int __sprint_symbol(char *buffer, unsigned long address,
9294523e376803 Stephen Boyd    2021-07-07  421  			   int symbol_offset, int add_offset, int add_buildid)
^1da177e4c3f41 Linus Torvalds  2005-04-16  422  {
^1da177e4c3f41 Linus Torvalds  2005-04-16  423  	char *modname;
9294523e376803 Stephen Boyd    2021-07-07  424  	const unsigned char *buildid;
^1da177e4c3f41 Linus Torvalds  2005-04-16  425  	const char *name;
^1da177e4c3f41 Linus Torvalds  2005-04-16  426  	unsigned long offset, size;
966c8c12dc9e77 Hugh Dickins    2008-11-19  427  	int len;
^1da177e4c3f41 Linus Torvalds  2005-04-16  428  
0f77a8d378254f Namhyung Kim    2011-03-24  429  	address += symbol_offset;
9294523e376803 Stephen Boyd    2021-07-07  430  	name = kallsyms_lookup_buildid(address, &size, &offset, &modname, &buildid,
9294523e376803 Stephen Boyd    2021-07-07  431  				       buffer);
^1da177e4c3f41 Linus Torvalds  2005-04-16  432  	if (!name)
b86280aa48b67c Namhyung Kim    2014-08-08  433  		return sprintf(buffer, "0x%lx", address - symbol_offset);
19769b762607fe Andrew Morton   2007-07-15  434  
966c8c12dc9e77 Hugh Dickins    2008-11-19  435  	if (name != buffer)
966c8c12dc9e77 Hugh Dickins    2008-11-19 @436  		strcpy(buffer, name);
966c8c12dc9e77 Hugh Dickins    2008-11-19  437  	len = strlen(buffer);
0f77a8d378254f Namhyung Kim    2011-03-24  438  	offset -= symbol_offset;
966c8c12dc9e77 Hugh Dickins    2008-11-19  439  
4796dd200db943 Stephen Boyd    2012-05-29  440  	if (add_offset)
4796dd200db943 Stephen Boyd    2012-05-29  441  		len += sprintf(buffer + len, "+%#lx/%#lx", offset, size);
4796dd200db943 Stephen Boyd    2012-05-29  442  
9294523e376803 Stephen Boyd    2021-07-07  443  	if (modname) {
9294523e376803 Stephen Boyd    2021-07-07  444  		len += sprintf(buffer + len, " [%s", modname);
9294523e376803 Stephen Boyd    2021-07-07  445  #if IS_ENABLED(CONFIG_STACKTRACE_BUILD_ID)
9294523e376803 Stephen Boyd    2021-07-07  446  		if (add_buildid && buildid) {
9294523e376803 Stephen Boyd    2021-07-07  447  			/* build ID should match length of sprintf */
9294523e376803 Stephen Boyd    2021-07-07  448  #if IS_ENABLED(CONFIG_MODULES)
9294523e376803 Stephen Boyd    2021-07-07  449  			static_assert(sizeof(typeof_member(struct module, build_id)) == 20);
9294523e376803 Stephen Boyd    2021-07-07  450  #endif
9294523e376803 Stephen Boyd    2021-07-07  451  			len += sprintf(buffer + len, " %20phN", buildid);
9294523e376803 Stephen Boyd    2021-07-07  452  		}
9294523e376803 Stephen Boyd    2021-07-07  453  #endif
9294523e376803 Stephen Boyd    2021-07-07  454  		len += sprintf(buffer + len, "]");
9294523e376803 Stephen Boyd    2021-07-07  455  	}
966c8c12dc9e77 Hugh Dickins    2008-11-19  456  
966c8c12dc9e77 Hugh Dickins    2008-11-19  457  	return len;
^1da177e4c3f41 Linus Torvalds  2005-04-16  458  }
0f77a8d378254f Namhyung Kim    2011-03-24  459  

:::::: The code at line 436 was first introduced by commit
:::::: 966c8c12dc9e77f931e2281ba25d2f0244b06949 sprint_symbol(): use less stack

:::::: TO: Hugh Dickins <hugh@veritas.com>
:::::: CC: Linus Torvalds <torvalds@linux-foundation.org>

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


                 reply	other threads:[~2023-11-02 21:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202311030538.uBMcnne0-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=cuibixuan@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=rdunlap@infradead.org \
    --cc=swboyd@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox