Linux Hardening
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Kees Cook <keescook@chromium.org>, linux-hardening@vger.kernel.org
Cc: oe-kbuild-all@lists.linux.dev, Kees Cook <keescook@chromium.org>,
	Andy Shevchenko <andy@kernel.org>,
	Cezary Rojewski <cezary.rojewski@intel.com>,
	Puyou Lu <puyou.lu@gmail.com>, Mark Brown <broonie@kernel.org>,
	Josh Poimboeuf <jpoimboe@kernel.org>,
	Brendan Higgins <brendan.higgins@linux.dev>,
	David Gow <davidgow@google.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linux Memory Management List <linux-mm@kvack.org>,
	Nathan Chancellor <nathan@kernel.org>,
	Alexander Potapenko <glider@google.com>,
	Zhaoyang Huang <zhaoyang.huang@unisoc.com>,
	Randy Dunlap <rdunlap@infradead.org>,
	Geert Uytterhoeven <geert+renesas@glider.be>,
	Miguel Ojeda <ojeda@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Liam Howlett <liam.howlett@oracle.com>,
	Vlastimil Babka <vbabka@suse.cz>,
	Dan Williams <dan.j.williams@intel.com>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	Yury Norov <yury.norov@gmail.com>,
	"Jason A. Donenfeld" <Jason@zx2c4.com>,
	Sander Vanheule <sander@svanheule.net>,
	Eric Biggers <ebiggers@google.com>,
	"Masami Hiramatsu (Google)" <mhiramat@kernel.org>,
	Andrey Konovalov <andreyknvl@gmail.com>,
	Linus Walleij <linus.walleij@linaro.org>
Subject: Re: [PATCH 3/9] string: Add Kunit tests for strcat() family
Date: Thu, 6 Apr 2023 12:19:46 +0800	[thread overview]
Message-ID: <202304061243.Bx5SK1xq-lkp@intel.com> (raw)
In-Reply-To: <20230406000212.3442647-3-keescook@chromium.org>

Hi Kees,

kernel test robot noticed the following build warnings:

[auto build test WARNING on kees/for-next/hardening]
[also build test WARNING on kees/for-next/pstore kees/for-next/kspp akpm-mm/mm-everything linus/master v6.3-rc5 next-20230405]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Kees-Cook/kunit-tool-Enable-CONFIG_FORTIFY_SOURCE-under-UML/20230406-081014
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/hardening
patch link:    https://lore.kernel.org/r/20230406000212.3442647-3-keescook%40chromium.org
patch subject: [PATCH 3/9] string: Add Kunit tests for strcat() family
config: riscv-randconfig-r042-20230403 (https://download.01.org/0day-ci/archive/20230406/202304061243.Bx5SK1xq-lkp@intel.com/config)
compiler: riscv64-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/1cdc1d7eeb09497f84367bfc2919d5fcc380e454
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Kees-Cook/kunit-tool-Enable-CONFIG_FORTIFY_SOURCE-under-UML/20230406-081014
        git checkout 1cdc1d7eeb09497f84367bfc2919d5fcc380e454
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=riscv olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202304061243.Bx5SK1xq-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from include/linux/err.h:5,
                    from include/kunit/assert.h:12,
                    from include/kunit/test.h:12,
                    from lib/strcat_kunit.c:8:
   lib/strcat_kunit.c: In function 'strncat_test':
>> lib/strcat_kunit.c:52:33: warning: 'strncat' output truncated copying 2 bytes from a string of length 4 [-Wstringop-truncation]
      52 |         KUNIT_EXPECT_TRUE(test, strncat(dest, "ABCD", 2) == dest);
         |                                 ^~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:77:45: note: in definition of macro 'likely'
      77 | # define likely(x)      __builtin_expect(!!(x), 1)
         |                                             ^
   include/kunit/test.h:545:9: note: in expansion of macro 'KUNIT_UNARY_ASSERTION'
     545 |         KUNIT_UNARY_ASSERTION(test,                                            \
         |         ^~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:736:9: note: in expansion of macro 'KUNIT_TRUE_MSG_ASSERTION'
     736 |         KUNIT_TRUE_MSG_ASSERTION(test,                                         \
         |         ^~~~~~~~~~~~~~~~~~~~~~~~
   include/kunit/test.h:733:9: note: in expansion of macro 'KUNIT_EXPECT_TRUE_MSG'
     733 |         KUNIT_EXPECT_TRUE_MSG(test, condition, NULL)
         |         ^~~~~~~~~~~~~~~~~~~~~
   lib/strcat_kunit.c:52:9: note: in expansion of macro 'KUNIT_EXPECT_TRUE'
      52 |         KUNIT_EXPECT_TRUE(test, strncat(dest, "ABCD", 2) == dest);
         |         ^~~~~~~~~~~~~~~~~


vim +/strncat +52 lib/strcat_kunit.c

    29	
    30	static void strncat_test(struct kunit *test)
    31	{
    32		char dest[8];
    33	
    34		/* Destination is terminated. */
    35		memset(dest, 0, sizeof(dest));
    36		KUNIT_EXPECT_EQ(test, strlen(dest), 0);
    37		/* Empty copy of size 0 does nothing. */
    38		KUNIT_EXPECT_TRUE(test, strncat(dest, "", 0) == dest);
    39		KUNIT_EXPECT_STREQ(test, dest, "");
    40		/* Empty copy of size 1 does nothing too. */
    41		KUNIT_EXPECT_TRUE(test, strncat(dest, "", 1) == dest);
    42		KUNIT_EXPECT_STREQ(test, dest, "");
    43		/* Copy of max 0 characters should do nothing. */
    44		KUNIT_EXPECT_TRUE(test, strncat(dest, "asdf", 0) == dest);
    45		KUNIT_EXPECT_STREQ(test, dest, "");
    46	
    47		/* 4 characters copied in, even if max is 8. */
    48		KUNIT_EXPECT_TRUE(test, strncat(dest, "four\000123", 8) == dest);
    49		KUNIT_EXPECT_STREQ(test, dest, "four");
    50		KUNIT_EXPECT_EQ(test, dest[5], '\0');
    51		/* 2 characters copied in okay, 2 ignored. */
  > 52		KUNIT_EXPECT_TRUE(test, strncat(dest, "ABCD", 2) == dest);
    53		KUNIT_EXPECT_STREQ(test, dest, "fourAB");
    54	}
    55	

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

  reply	other threads:[~2023-04-06  4:20 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-06  0:01 [PATCH 0/9] fortify: Add KUnit tests for runtime overflows Kees Cook
2023-04-06  0:02 ` [PATCH 1/9] kunit: tool: Enable CONFIG_FORTIFY_SOURCE under UML Kees Cook
2023-04-06  3:10   ` Kees Cook
2023-04-06  0:02 ` [PATCH 2/9] fortify: Allow KUnit test to build without FORTIFY Kees Cook
2023-04-06  1:22   ` Daniel Latypov
2023-04-06 23:09     ` Kees Cook
2023-04-06  0:02 ` [PATCH 3/9] string: Add Kunit tests for strcat() family Kees Cook
2023-04-06  4:19   ` kernel test robot [this message]
2023-04-06  9:11   ` Alexander Potapenko
2023-04-06 23:07     ` Kees Cook
2023-04-12 12:34       ` Alexander Potapenko
2023-04-06  0:02 ` [PATCH 4/9] fortify: Add protection for strlcat() Kees Cook
2023-04-06 13:32   ` Miguel Ojeda
2023-04-06 22:58     ` Kees Cook
2023-04-06  0:02 ` [PATCH 5/9] fortify: strcat: Move definition to use fortified strlcat() Kees Cook
2023-04-06  0:02 ` [PATCH 6/9] fortify: Split reporting and avoid passing string pointer Kees Cook
2023-04-06 10:20   ` Andy Shevchenko
2023-04-06 22:57     ` Kees Cook
2023-04-07  8:34       ` Andy Shevchenko
2023-04-07 19:49         ` Kees Cook
2023-04-06 11:19   ` kernel test robot
2024-02-22 13:00     ` Arnd Bergmann
2024-02-22 16:30       ` Kees Cook
2024-02-22 17:11         ` Andy Shevchenko
2023-04-06 13:44   ` Miguel Ojeda
2023-04-06 22:54     ` Kees Cook
2023-04-06 15:23   ` Alexander Lobakin
2023-04-06 22:54     ` Kees Cook
2023-04-07 10:26   ` kernel test robot
2023-04-06  0:02 ` [PATCH 7/9] fortify: Provide KUnit counters for failure testing Kees Cook
2023-04-06  0:02 ` [PATCH 8/9] fortify: Add KUnit tests for runtime overflows Kees Cook
2023-04-06  0:02 ` [PATCH 9/9] fortify: Improve buffer overflow reporting Kees Cook

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=202304061243.Bx5SK1xq-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=Jason@zx2c4.com \
    --cc=akpm@linux-foundation.org \
    --cc=andreyknvl@gmail.com \
    --cc=andy@kernel.org \
    --cc=brendan.higgins@linux.dev \
    --cc=broonie@kernel.org \
    --cc=cezary.rojewski@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=davidgow@google.com \
    --cc=ebiggers@google.com \
    --cc=geert+renesas@glider.be \
    --cc=glider@google.com \
    --cc=jpoimboe@kernel.org \
    --cc=keescook@chromium.org \
    --cc=liam.howlett@oracle.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=mhiramat@kernel.org \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=ojeda@kernel.org \
    --cc=puyou.lu@gmail.com \
    --cc=rdunlap@infradead.org \
    --cc=sander@svanheule.net \
    --cc=vbabka@suse.cz \
    --cc=yury.norov@gmail.com \
    --cc=zhaoyang.huang@unisoc.com \
    /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