linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: kbuild test robot <lkp@intel.com>
To: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: kbuild-all@01.org, linux-kernel@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: include/linux/string.h:246:9: warning: '__builtin_strncpy' output truncated before terminating nul copying 4 bytes from a string of the same length
Date: Tue, 29 May 2018 09:35:43 +0800	[thread overview]
Message-ID: <201805290939.AjijeyJf%fengguang.wu@intel.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 3142 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   786b71f5b754273ccef6d9462e52062b3e1f9877
commit: 854e55ad289ef8888e7991f0ada85d5846f5afb9 objtool, perf: Fix GCC 8 -Wrestrict error
date:   2 months ago
config: x86_64-randconfig-s4-05290856 (attached as .config)
compiler: gcc-8 (Debian 8.1.0-3) 8.1.0
reproduce:
        git checkout 854e55ad289ef8888e7991f0ada85d5846f5afb9
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   In file included from include/linux/bitmap.h:9,
                    from include/linux/cpumask.h:12,
                    from arch/x86/include/asm/cpumask.h:5,
                    from arch/x86/include/asm/msr.h:11,
                    from arch/x86/include/asm/processor.h:21,
                    from arch/x86/include/asm/cpufeature.h:5,
                    from arch/x86/include/asm/thread_info.h:53,
                    from include/linux/thread_info.h:38,
                    from arch/x86/include/asm/preempt.h:7,
                    from include/linux/preempt.h:81,
                    from include/linux/spinlock.h:51,
                    from include/linux/seqlock.h:36,
                    from include/linux/time.h:6,
                    from include/linux/stat.h:19,
                    from include/linux/module.h:10,
                    from drivers/video/fbdev/uvesafb.c:12:
   In function 'strncpy',
       inlined from 'uvesafb_vbe_getinfo' at drivers/video/fbdev/uvesafb.c:425:2:
>> include/linux/string.h:246:9: warning: '__builtin_strncpy' output truncated before terminating nul copying 4 bytes from a string of the same length [-Wstringop-truncation]
     return __builtin_strncpy(p, q, size);
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vim +/__builtin_strncpy +246 include/linux/string.h

6974f0c4 Daniel Micay 2017-07-12  237  
6974f0c4 Daniel Micay 2017-07-12  238  #if !defined(__NO_FORTIFY) && defined(__OPTIMIZE__) && defined(CONFIG_FORTIFY_SOURCE)
6974f0c4 Daniel Micay 2017-07-12  239  __FORTIFY_INLINE char *strncpy(char *p, const char *q, __kernel_size_t size)
6974f0c4 Daniel Micay 2017-07-12  240  {
6974f0c4 Daniel Micay 2017-07-12  241  	size_t p_size = __builtin_object_size(p, 0);
6974f0c4 Daniel Micay 2017-07-12  242  	if (__builtin_constant_p(size) && p_size < size)
6974f0c4 Daniel Micay 2017-07-12  243  		__write_overflow();
6974f0c4 Daniel Micay 2017-07-12  244  	if (p_size < size)
6974f0c4 Daniel Micay 2017-07-12  245  		fortify_panic(__func__);
6974f0c4 Daniel Micay 2017-07-12 @246  	return __builtin_strncpy(p, q, size);
6974f0c4 Daniel Micay 2017-07-12  247  }
6974f0c4 Daniel Micay 2017-07-12  248  

:::::: The code at line 246 was first introduced by commit
:::::: 6974f0c4555e285ab217cee58b6e874f776ff409 include/linux/string.h: add the option of fortified string.h functions

:::::: TO: Daniel Micay <danielmicay@gmail.com>
:::::: CC: Linus Torvalds <torvalds@linux-foundation.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 35030 bytes --]

             reply	other threads:[~2018-05-29  1:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-29  1:35 kbuild test robot [this message]
2018-06-05 15:19 ` include/linux/string.h:246:9: warning: '__builtin_strncpy' output truncated before terminating nul copying 4 bytes from a string of the same length Andy Shevchenko
2018-06-05 15:30   ` Josh Poimboeuf
2018-06-05 15:31     ` Andy Shevchenko
2018-06-06 15:34     ` David Laight

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=201805290939.AjijeyJf%fengguang.wu@intel.com \
    --to=lkp@intel.com \
    --cc=acme@redhat.com \
    --cc=jpoimboe@redhat.com \
    --cc=kbuild-all@01.org \
    --cc=linux-kernel@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).