linux-next: build failure after merge of the akpm-current tree

Stephen Rothwell posted 1 patch 4 years, 5 months ago
There is a newer version of this series
lib/test_kasan.c | 2 ++
1 file changed, 2 insertions(+)
linux-next: build failure after merge of the akpm-current tree
Posted by Stephen Rothwell 4 years, 5 months ago
Hi all,

After merging the akpm-current tree, today's linux-next build (x86_64
allmodconfig) failed like this:

lib/test_kasan.c: In function 'vmalloc_oob':
lib/test_kasan.c:1113:71: error: array subscript 2035 is outside array bounds of 'char[2035]' [-Werror=array-bounds]
 1113 |                 KUNIT_EXPECT_KASAN_FAIL(test, ((volatile char *)v_ptr)[size]);
      |                                               ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
lib/test_kasan.c:96:9: note: in definition of macro 'KUNIT_EXPECT_KASAN_FAIL'
   96 |         expression;                                                     \
      |         ^~~~~~~~~~
lib/test_kasan.c:1096:17: note: referencing an object of size 2035 allocated by 'vmalloc'
 1096 |         v_ptr = vmalloc(size);
      |                 ^~~~~~~~~~~~~
lib/test_kasan.c:1116:63: error: array subscript 2040 is outside array bounds of 'char[2035]' [-Werror=array-bounds]
 1116 |         KUNIT_EXPECT_KASAN_FAIL(test, ((volatile char *)v_ptr)[size + 5]);
      |                                       ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
lib/test_kasan.c:96:9: note: in definition of macro 'KUNIT_EXPECT_KASAN_FAIL'
   96 |         expression;                                                     \
      |         ^~~~~~~~~~
lib/test_kasan.c:1096:17: note: referencing an object of size 2035 allocated by 'vmalloc'
 1096 |         v_ptr = vmalloc(size);
      |                 ^~~~~~~~~~~~~

Caused by commit

  96304a5b9bff ("kasan: improve vmalloc tests")

interacting with commit

  d4e0dad4a0cd ("Makefile: Enable -Warray-bounds")

from the kspp tree.

Since the KASAN tests are doing this deliberately, I added the below
hack for today.  Is there something better?

From: Stephen Rothwell <sfr@canb.auug.org.au>
Date: Fri, 28 Jan 2022 14:40:24 +1100
Subject: [PATCH] similar to "kasan: test: fix compatibility with
 FORTIFY_SOURCE"

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
---
 lib/test_kasan.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/test_kasan.c b/lib/test_kasan.c
index 9dd767d05235..c07132c857e7 100644
--- a/lib/test_kasan.c
+++ b/lib/test_kasan.c
@@ -1096,6 +1096,8 @@ static void vmalloc_oob(struct kunit *test)
 	v_ptr = vmalloc(size);
 	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, v_ptr);
 
+	OPTIMIZER_HIDE_VAR(v_ptr);
+
 	/*
 	 * We have to be careful not to hit the guard page in vmalloc tests.
 	 * The MMU will catch that and crash us.
-- 
2.34.1

-- 
Cheers,
Stephen Rothwell
Re: linux-next: build failure after merge of the akpm-current tree
Posted by Andrey Konovalov 4 years, 5 months ago
On Fri, Jan 28, 2022 at 4:48 AM Stephen Rothwell <sfr@canb.auug.org.au> wrote:
>
> Hi all,
>
> After merging the akpm-current tree, today's linux-next build (x86_64
> allmodconfig) failed like this:
>
> lib/test_kasan.c: In function 'vmalloc_oob':
> lib/test_kasan.c:1113:71: error: array subscript 2035 is outside array bounds of 'char[2035]' [-Werror=array-bounds]
>  1113 |                 KUNIT_EXPECT_KASAN_FAIL(test, ((volatile char *)v_ptr)[size]);
>       |                                               ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
> lib/test_kasan.c:96:9: note: in definition of macro 'KUNIT_EXPECT_KASAN_FAIL'
>    96 |         expression;                                                     \
>       |         ^~~~~~~~~~
> lib/test_kasan.c:1096:17: note: referencing an object of size 2035 allocated by 'vmalloc'
>  1096 |         v_ptr = vmalloc(size);
>       |                 ^~~~~~~~~~~~~
> lib/test_kasan.c:1116:63: error: array subscript 2040 is outside array bounds of 'char[2035]' [-Werror=array-bounds]
>  1116 |         KUNIT_EXPECT_KASAN_FAIL(test, ((volatile char *)v_ptr)[size + 5]);
>       |                                       ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
> lib/test_kasan.c:96:9: note: in definition of macro 'KUNIT_EXPECT_KASAN_FAIL'
>    96 |         expression;                                                     \
>       |         ^~~~~~~~~~
> lib/test_kasan.c:1096:17: note: referencing an object of size 2035 allocated by 'vmalloc'
>  1096 |         v_ptr = vmalloc(size);
>       |                 ^~~~~~~~~~~~~
>
> Caused by commit
>
>   96304a5b9bff ("kasan: improve vmalloc tests")
>
> interacting with commit
>
>   d4e0dad4a0cd ("Makefile: Enable -Warray-bounds")
>
> from the kspp tree.
>
> Since the KASAN tests are doing this deliberately, I added the below
> hack for today.  Is there something better?

No, this looks good. I'll add this change into the next version of the
KASAN vmalloc patchset.

Thanks, Stephen!