2021-09-17 12:37:14

by Brendan Higgins

[permalink] [raw]
Subject: [PATCH v1 6/6] bitfield: build kunit tests without structleak plugin

From: Arnd Bergmann <[email protected]>

The structleak plugin causes the stack frame size to grow immensely:

lib/bitfield_kunit.c: In function 'test_bitfields_constants':
lib/bitfield_kunit.c:93:1: error: the frame size of 7440 bytes is larger than 2048 bytes [-Werror=frame-larger-than=]

Turn it off in this file.

Signed-off-by: Arnd Bergmann <[email protected]>
Signed-off-by: Brendan Higgins <[email protected]>
---
lib/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/Makefile b/lib/Makefile
index 5efd1b435a37c..c93c4b59af969 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -351,7 +351,7 @@ obj-$(CONFIG_OBJAGG) += objagg.o
obj-$(CONFIG_PLDMFW) += pldmfw/

# KUnit tests
-CFLAGS_bitfield_kunit.o := $(call cc-option,-Wframe-larger-than=10240)
+CFLAGS_bitfield_kunit.o := $(call cc-option,-Wframe-larger-than=10240) $(DISABLE_STRUCTLEAK_PLUGIN)
obj-$(CONFIG_BITFIELD_KUNIT) += bitfield_kunit.o
obj-$(CONFIG_LIST_KUNIT_TEST) += list-test.o
obj-$(CONFIG_LINEAR_RANGES_TEST) += test_linear_ranges.o
--
2.33.0.464.g1972c5931b-goog


2021-09-17 12:59:47

by Arnd Bergmann

[permalink] [raw]
Subject: Re: [PATCH v1 6/6] bitfield: build kunit tests without structleak plugin

On Fri, Sep 17, 2021 at 8:11 AM Brendan Higgins
<[email protected]> wrote:
>
> From: Arnd Bergmann <[email protected]>
>
> The structleak plugin causes the stack frame size to grow immensely:
>
> lib/bitfield_kunit.c: In function 'test_bitfields_constants':
> lib/bitfield_kunit.c:93:1: error: the frame size of 7440 bytes is larger than 2048 bytes [-Werror=frame-larger-than=]
>
> Turn it off in this file.
>
> Signed-off-by: Arnd Bergmann <[email protected]>
> Signed-off-by: Brendan Higgins <[email protected]>
> ---
> lib/Makefile | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/Makefile b/lib/Makefile
> index 5efd1b435a37c..c93c4b59af969 100644
> --- a/lib/Makefile
> +++ b/lib/Makefile
> @@ -351,7 +351,7 @@ obj-$(CONFIG_OBJAGG) += objagg.o
> obj-$(CONFIG_PLDMFW) += pldmfw/
>
> # KUnit tests
> -CFLAGS_bitfield_kunit.o := $(call cc-option,-Wframe-larger-than=10240)
> +CFLAGS_bitfield_kunit.o := $(call cc-option,-Wframe-larger-than=10240) $(DISABLE_STRUCTLEAK_PLUGIN)

I think the $(call cc-option,-Wframe-larger-than=10240) needs to be dropped
here. This was not in my original patch and it is definitely broken on
all architectures
with 8KB stack size or less if the function needs that much. What is the amount
of actual stack usage you observe without this? If we still get a warning, then
I think this needs to be fixed in the code.

Arnd

2021-09-18 00:12:25

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH v1 6/6] bitfield: build kunit tests without structleak plugin

On Fri, Sep 17, 2021 at 09:22:08AM +0200, Arnd Bergmann wrote:
> On Fri, Sep 17, 2021 at 8:11 AM Brendan Higgins
> <[email protected]> wrote:
> >
> > From: Arnd Bergmann <[email protected]>
> >
> > The structleak plugin causes the stack frame size to grow immensely:
> >
> > lib/bitfield_kunit.c: In function 'test_bitfields_constants':
> > lib/bitfield_kunit.c:93:1: error: the frame size of 7440 bytes is larger than 2048 bytes [-Werror=frame-larger-than=]
> >
> > Turn it off in this file.
> >
> > Signed-off-by: Arnd Bergmann <[email protected]>
> > Signed-off-by: Brendan Higgins <[email protected]>
> > ---
> > lib/Makefile | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/lib/Makefile b/lib/Makefile
> > index 5efd1b435a37c..c93c4b59af969 100644
> > --- a/lib/Makefile
> > +++ b/lib/Makefile
> > @@ -351,7 +351,7 @@ obj-$(CONFIG_OBJAGG) += objagg.o
> > obj-$(CONFIG_PLDMFW) += pldmfw/
> >
> > # KUnit tests
> > -CFLAGS_bitfield_kunit.o := $(call cc-option,-Wframe-larger-than=10240)
> > +CFLAGS_bitfield_kunit.o := $(call cc-option,-Wframe-larger-than=10240) $(DISABLE_STRUCTLEAK_PLUGIN)
>
> I think the $(call cc-option,-Wframe-larger-than=10240) needs to be dropped
> here. This was not in my original patch and it is definitely broken on
> all architectures
> with 8KB stack size or less if the function needs that much. What is the amount
> of actual stack usage you observe without this? If we still get a warning, then
> I think this needs to be fixed in the code.

With the frame-larger-than dropped:

Reviewed-by: Kees Cook <[email protected]>


--
Kees Cook

2021-09-29 22:27:49

by Brendan Higgins

[permalink] [raw]
Subject: Re: [PATCH v1 6/6] bitfield: build kunit tests without structleak plugin

On Fri, Sep 17, 2021 at 12:22 AM Arnd Bergmann <[email protected]> wrote:
>
> On Fri, Sep 17, 2021 at 8:11 AM Brendan Higgins
> <[email protected]> wrote:
> >
> > From: Arnd Bergmann <[email protected]>
> >
> > The structleak plugin causes the stack frame size to grow immensely:
> >
> > lib/bitfield_kunit.c: In function 'test_bitfields_constants':
> > lib/bitfield_kunit.c:93:1: error: the frame size of 7440 bytes is larger than 2048 bytes [-Werror=frame-larger-than=]
> >
> > Turn it off in this file.
> >
> > Signed-off-by: Arnd Bergmann <[email protected]>
> > Signed-off-by: Brendan Higgins <[email protected]>
> > ---
> > lib/Makefile | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/lib/Makefile b/lib/Makefile
> > index 5efd1b435a37c..c93c4b59af969 100644
> > --- a/lib/Makefile
> > +++ b/lib/Makefile
> > @@ -351,7 +351,7 @@ obj-$(CONFIG_OBJAGG) += objagg.o
> > obj-$(CONFIG_PLDMFW) += pldmfw/
> >
> > # KUnit tests
> > -CFLAGS_bitfield_kunit.o := $(call cc-option,-Wframe-larger-than=10240)
> > +CFLAGS_bitfield_kunit.o := $(call cc-option,-Wframe-larger-than=10240) $(DISABLE_STRUCTLEAK_PLUGIN)
>
> I think the $(call cc-option,-Wframe-larger-than=10240) needs to be dropped
> here. This was not in my original patch and it is definitely broken on

Ah, someone else put that there, so I just left it, but I can drop it.

> all architectures
> with 8KB stack size or less if the function needs that much. What is the amount
> of actual stack usage you observe without this?

Well STRUCTLEAK claims 7440 bytes, but I don't entirely believe that.
Regardless, it is definitely less than 8KB.

> If we still get a warning, then
> I think this needs to be fixed in the code.
>
> Arnd

Cheers