2020-03-05 05:39:01

by Stephen Rothwell

[permalink] [raw]
Subject: linux-next: build warning after merge of the akpm-current tree

Hi all,

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

mm/kasan/common.o: warning: objtool: kasan_report()+0x17: call to report_enabled() with UACCESS enabled
In file included from include/linux/bitmap.h:9,
from include/linux/cpumask.h:12,
from arch/x86/include/asm/paravirt.h:17,
from arch/x86/include/asm/irqflags.h:72,
from include/linux/irqflags.h:16,
from include/linux/rcupdate.h:26,
from include/linux/rculist.h:11,
from include/linux/pid.h:5,
from include/linux/sched.h:14,
from include/linux/uaccess.h:6,
from arch/x86/include/asm/fpu/xstate.h:5,
from arch/x86/include/asm/pgtable.h:26,
from include/linux/kasan.h:15,
from lib/test_kasan.c:12:
In function 'memmove',
inlined from 'kmalloc_memmove_invalid_size' at lib/test_kasan.c:301:2:
include/linux/string.h:441:9: warning: '__builtin_memmove' specified bound 18446744073709551614 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
441 | return __builtin_memmove(p, q, size);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Introduced by commit

519e500fac64 ("kasan: add test for invalid size in memmove")

That's a bit annoying during a normal x86_64 allmodconfig build ...

--
Cheers,
Stephen Rothwell


Attachments:
(No filename) (499.00 B)
OpenPGP digital signature

2020-03-05 05:55:05

by Dmitry Vyukov

[permalink] [raw]
Subject: Re: linux-next: build warning after merge of the akpm-current tree

On Thu, Mar 5, 2020 at 6:37 AM Stephen Rothwell <[email protected]> wrote:
>
> Hi all,
>
> After merging the akpm-current tree, today's linux-next build (x86_64
> allmodconfig) produced this warning:
>
> mm/kasan/common.o: warning: objtool: kasan_report()+0x17: call to report_enabled() with UACCESS enabled
> In file included from include/linux/bitmap.h:9,
> from include/linux/cpumask.h:12,
> from arch/x86/include/asm/paravirt.h:17,
> from arch/x86/include/asm/irqflags.h:72,
> from include/linux/irqflags.h:16,
> from include/linux/rcupdate.h:26,
> from include/linux/rculist.h:11,
> from include/linux/pid.h:5,
> from include/linux/sched.h:14,
> from include/linux/uaccess.h:6,
> from arch/x86/include/asm/fpu/xstate.h:5,
> from arch/x86/include/asm/pgtable.h:26,
> from include/linux/kasan.h:15,
> from lib/test_kasan.c:12:
> In function 'memmove',
> inlined from 'kmalloc_memmove_invalid_size' at lib/test_kasan.c:301:2:
> include/linux/string.h:441:9: warning: '__builtin_memmove' specified bound 18446744073709551614 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]

+kasan-dev

We probably need to make this 18446744073709551614 constant "dynamic"
so that compiler does not see it.

Walter, will you take a look? Thanks

> 441 | return __builtin_memmove(p, q, size);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Introduced by commit
>
> 519e500fac64 ("kasan: add test for invalid size in memmove")
>
> That's a bit annoying during a normal x86_64 allmodconfig build ...
>
> --
> Cheers,
> Stephen Rothwell

2020-03-05 08:55:15

by Walter Wu

[permalink] [raw]
Subject: Re: linux-next: build warning after merge of the akpm-current tree

On Thu, 2020-03-05 at 16:37 +1100, Stephen Rothwell wrote:
> Hi all,
>
> After merging the akpm-current tree, today's linux-next build (x86_64
> allmodconfig) produced this warning:
>
> mm/kasan/common.o: warning: objtool: kasan_report()+0x17: call to report_enabled() with UACCESS enabled
> In file included from include/linux/bitmap.h:9,
> from include/linux/cpumask.h:12,
> from arch/x86/include/asm/paravirt.h:17,
> from arch/x86/include/asm/irqflags.h:72,
> from include/linux/irqflags.h:16,
> from include/linux/rcupdate.h:26,
> from include/linux/rculist.h:11,
> from include/linux/pid.h:5,
> from include/linux/sched.h:14,
> from include/linux/uaccess.h:6,
> from arch/x86/include/asm/fpu/xstate.h:5,
> from arch/x86/include/asm/pgtable.h:26,
> from include/linux/kasan.h:15,
> from lib/test_kasan.c:12:
> In function 'memmove',
> inlined from 'kmalloc_memmove_invalid_size' at lib/test_kasan.c:301:2:
> include/linux/string.h:441:9: warning: '__builtin_memmove' specified bound 18446744073709551614 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
> 441 | return __builtin_memmove(p, q, size);
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Introduced by commit
>
> 519e500fac64 ("kasan: add test for invalid size in memmove")
>
> That's a bit annoying during a normal x86_64 allmodconfig build ...
>

Hi Stephen and Dmitry,

I'm sorry for the build warning, it doesn't generate in our local
environment(arm64/x86_64). Would you tell me what toolchains can
reproduce it?

Dmitry, Thanks for your suggestion.


Thanks

Walter



2020-03-05 09:34:31

by Stephen Rothwell

[permalink] [raw]
Subject: Re: linux-next: build warning after merge of the akpm-current tree

Hi Walter,

On Thu, 5 Mar 2020 16:54:36 +0800 Walter Wu <[email protected]> wrote:
>
> I'm sorry for the build warning, it doesn't generate in our local
> environment(arm64/x86_64). Would you tell me what toolchains can
> reproduce it?

I am using a PowerPC LE hosted x86_64 gcc v9.2.1 (Debian cross compiler).

$ /usr/bin/x86_64-linux-gnu-gcc --version
x86_64-linux-gnu-gcc (Debian 9.2.1-21) 9.2.1 20191130

--
Cheers,
Stephen Rothwell


Attachments:
(No filename) (499.00 B)
OpenPGP digital signature

2020-03-06 19:01:33

by Walter Wu

[permalink] [raw]
Subject: Re: linux-next: build warning after merge of the akpm-current tree

On Thu, 2020-03-05 at 20:33 +1100, Stephen Rothwell wrote:
> Hi Walter,
>
> On Thu, 5 Mar 2020 16:54:36 +0800 Walter Wu <[email protected]> wrote:
> >
> > I'm sorry for the build warning, it doesn't generate in our local
> > environment(arm64/x86_64). Would you tell me what toolchains can
> > reproduce it?
>
> I am using a PowerPC LE hosted x86_64 gcc v9.2.1 (Debian cross compiler).
>
> $ /usr/bin/x86_64-linux-gnu-gcc --version
> x86_64-linux-gnu-gcc (Debian 9.2.1-21) 9.2.1 20191130
>
Hi Stephen,

Thanks for your information, It doesn't generate warning message in
gcc-8.3.0(Debian 8.3.0-6) after apply below patch.


--- a/lib/test_kasan.c
+++ b/lib/test_kasan.c
@@ -286,17 +286,19 @@ static noinline void __init
kmalloc_oob_in_memset(void)
static noinline void __init kmalloc_memmove_invalid_size(void)
{
char *ptr;
- size_t size = 64;
+ size_t size1 = 64;
+ size_t size2 = 62;

pr_info("invalid size in memmove\n");
- ptr = kmalloc(size, GFP_KERNEL);
+ ptr = kmalloc(size1, GFP_KERNEL);
if (!ptr) {
pr_err("Allocation failed\n");
return;
}

- memset((char *)ptr, 0, 64);
- memmove((char *)ptr, (char *)ptr + 4, -2);
+ memset((char *)ptr, 0, size1);
+ /* the size of memmove() is negative numbers */
+ memmove((char *)ptr, (char *)ptr + 4, size2 - size1);
kfree(ptr);
}

2020-03-06 20:46:31

by Walter Wu

[permalink] [raw]
Subject: Re: linux-next: build warning after merge of the akpm-current tree

On Sat, 2020-03-07 at 02:59 +0800, Walter Wu wrote:
> On Thu, 2020-03-05 at 20:33 +1100, Stephen Rothwell wrote:
> > Hi Walter,
> >
> > On Thu, 5 Mar 2020 16:54:36 +0800 Walter Wu <[email protected]> wrote:
> > >
> > > I'm sorry for the build warning, it doesn't generate in our local
> > > environment(arm64/x86_64). Would you tell me what toolchains can
> > > reproduce it?
> >
> > I am using a PowerPC LE hosted x86_64 gcc v9.2.1 (Debian cross compiler).
> >
> > $ /usr/bin/x86_64-linux-gnu-gcc --version
> > x86_64-linux-gnu-gcc (Debian 9.2.1-21) 9.2.1 20191130
> >
> Hi Stephen,
>
> Thanks for your information, It doesn't generate warning message in
> gcc-8.3.0(Debian 8.3.0-6) after apply below patch.
>
>
> --- a/lib/test_kasan.c
> +++ b/lib/test_kasan.c
> @@ -286,17 +286,19 @@ static noinline void __init
> kmalloc_oob_in_memset(void)
> static noinline void __init kmalloc_memmove_invalid_size(void)
> {
> char *ptr;
> - size_t size = 64;
> + size_t size1 = 64;
> + size_t size2 = 62;
>
> pr_info("invalid size in memmove\n");
> - ptr = kmalloc(size, GFP_KERNEL);
> + ptr = kmalloc(size1, GFP_KERNEL);
> if (!ptr) {
> pr_err("Allocation failed\n");
> return;
> }
>
> - memset((char *)ptr, 0, 64);
> - memmove((char *)ptr, (char *)ptr + 4, -2);
> + memset((char *)ptr, 0, size1);
> + /* the size of memmove() is negative numbers */
> + memmove((char *)ptr, (char *)ptr + 4, size2 - size1);
> kfree(ptr);
> }
>
Hi Stephen,

Please ignore previous mail, I miss the message. Below the patch will
fix the warning.


--- a/lib/test_kasan.c
+++ b/lib/test_kasan.c
@@ -286,17 +286,19 @@ static noinline void __init
kmalloc_oob_in_memset(void)
static noinline void __init kmalloc_memmove_invalid_size(void)
{
char *ptr;
- size_t size = 64;
+ size_t size1 = 64;
+ volatile size_t size2 = -2;

pr_info("invalid size in memmove\n");
- ptr = kmalloc(size, GFP_KERNEL);
+ ptr = kmalloc(size1, GFP_KERNEL);
if (!ptr) {
pr_err("Allocation failed\n");
return;
}

- memset((char *)ptr, 0, 64);
- memmove((char *)ptr, (char *)ptr + 4, -2);
+ memset((char *)ptr, 0, size1);
+ /* the size of memmove() is negative number */
+ memmove((char *)ptr, (char *)ptr + 4, size2);
kfree(ptr);
}

2020-03-07 05:10:21

by Walter Wu

[permalink] [raw]
Subject: Re: linux-next: build warning after merge of the akpm-current tree

On Thu, 2020-03-05 at 06:54 +0100, Dmitry Vyukov wrote:
> On Thu, Mar 5, 2020 at 6:37 AM Stephen Rothwell <[email protected]> wrote:
> >
> > Hi all,
> >
> > After merging the akpm-current tree, today's linux-next build (x86_64
> > allmodconfig) produced this warning:
> >
> > mm/kasan/common.o: warning: objtool: kasan_report()+0x17: call to report_enabled() with UACCESS enabled
> > In file included from include/linux/bitmap.h:9,
> > from include/linux/cpumask.h:12,
> > from arch/x86/include/asm/paravirt.h:17,
> > from arch/x86/include/asm/irqflags.h:72,
> > from include/linux/irqflags.h:16,
> > from include/linux/rcupdate.h:26,
> > from include/linux/rculist.h:11,
> > from include/linux/pid.h:5,
> > from include/linux/sched.h:14,
> > from include/linux/uaccess.h:6,
> > from arch/x86/include/asm/fpu/xstate.h:5,
> > from arch/x86/include/asm/pgtable.h:26,
> > from include/linux/kasan.h:15,
> > from lib/test_kasan.c:12:
> > In function 'memmove',
> > inlined from 'kmalloc_memmove_invalid_size' at lib/test_kasan.c:301:2:
> > include/linux/string.h:441:9: warning: '__builtin_memmove' specified bound 18446744073709551614 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
>
> +kasan-dev
>
> We probably need to make this 18446744073709551614 constant "dynamic"
> so that compiler does not see it.
>
> Walter, will you take a look? Thanks

Hi Dmitry,

Yes, I have fixed it. This warning need newer gcc enough to reproduce.
Maybe I should replace original gcc-7.4.0.

Thanks.


--- a/lib/test_kasan.c
+++ b/lib/test_kasan.c
@@ -286,17 +286,19 @@ static noinline void __init
kmalloc_oob_in_memset(void)
static noinline void __init kmalloc_memmove_invalid_size(void)
{
char *ptr;
- size_t size = 64;
+ size_t size1 = 64;
+ volatile size_t size2 = -2;

pr_info("invalid size in memmove\n");
- ptr = kmalloc(size, GFP_KERNEL);
+ ptr = kmalloc(size1, GFP_KERNEL);
if (!ptr) {
pr_err("Allocation failed\n");
return;
}

- memset((char *)ptr, 0, 64);
- memmove((char *)ptr, (char *)ptr + 4, -2);
+ memset((char *)ptr, 0, size1);
+ /* the size of memmove() is negative number */
+ memmove((char *)ptr, (char *)ptr + 4, size2);
kfree(ptr);
}

>
> > 441 | return __builtin_memmove(p, q, size);
> > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> > Introduced by commit
> >
> > 519e500fac64 ("kasan: add test for invalid size in memmove")
> >
> > That's a bit annoying during a normal x86_64 allmodconfig build ...
> >
> > --
> > Cheers,
> > Stephen Rothwell