diff mbox series

[2/2] selftests/lkdtm: add config

Message ID 20220217205620.2512094-2-usama.anjum@collabora.com
State New
Headers show
Series [1/2] selftests/lkdtm: add config and turn off CFI_FORWARD_PROTO | expand

Commit Message

Muhammad Usama Anjum Feb. 17, 2022, 8:56 p.m. UTC
Add config option which is needed for SLAB_LINEAR_OVERFLOW test. It
needs KASAN enabled.

Cc: Kees Cook <keescook@chromium.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Fixes: 9c4f6ebc3665 ("lkdtm/heap: Add vmalloc linear overflow test")
Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
 tools/testing/selftests/lkdtm/config | 1 +
 1 file changed, 1 insertion(+)

Comments

Kees Cook March 9, 2022, 7:23 p.m. UTC | #1
On Fri, Feb 18, 2022 at 01:56:20AM +0500, Muhammad Usama Anjum wrote:
> Add config option which is needed for SLAB_LINEAR_OVERFLOW test. It
> needs KASAN enabled.

I'd prefer this use the SLAB_DEBUG options -- KASAN is very heavy.

-Kees

> 
> Cc: Kees Cook <keescook@chromium.org>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Fixes: 9c4f6ebc3665 ("lkdtm/heap: Add vmalloc linear overflow test")
> Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
> ---
>  tools/testing/selftests/lkdtm/config | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tools/testing/selftests/lkdtm/config b/tools/testing/selftests/lkdtm/config
> index adc9fa60057c5..4e8af0f712f74 100644
> --- a/tools/testing/selftests/lkdtm/config
> +++ b/tools/testing/selftests/lkdtm/config
> @@ -7,6 +7,7 @@ CONFIG_HARDENED_USERCOPY=y
>  CONFIG_RANDOMIZE_KSTACK_OFFSET_DEFAULT=y
>  CONFIG_INIT_ON_FREE_DEFAULT_ON=y
>  CONFIG_INIT_ON_ALLOC_DEFAULT_ON=y
> +CONFIG_KASAN=y
>  CONFIG_UBSAN=y
>  CONFIG_UBSAN_BOUNDS=y
>  CONFIG_UBSAN_TRAP=y
> -- 
> 2.30.2
>
Muhammad Usama Anjum March 10, 2022, 5:22 p.m. UTC | #2
On 3/10/22 12:23 AM, Kees Cook wrote:
> On Fri, Feb 18, 2022 at 01:56:20AM +0500, Muhammad Usama Anjum wrote:
>> Add config option which is needed for SLAB_LINEAR_OVERFLOW test. It
>> needs KASAN enabled.
> 
> I'd prefer this use the SLAB_DEBUG options -- KASAN is very heavy.
I'll test it out and update in the next patch version.
Muhammad Usama Anjum March 15, 2022, 11:55 a.m. UTC | #3
On 3/10/22 10:22 PM, Muhammad Usama Anjum wrote:
> On 3/10/22 12:23 AM, Kees Cook wrote:
>> On Fri, Feb 18, 2022 at 01:56:20AM +0500, Muhammad Usama Anjum wrote:
>>> Add config option which is needed for SLAB_LINEAR_OVERFLOW test. It
>>> needs KASAN enabled.
>>
>> I'd prefer this use the SLAB_DEBUG options -- KASAN is very heavy.
> I'll test it out and update in the next patch version.
> I've tested by removing KASAN and adding the following config:
CONFIG_SLAB=y
CONFIG_DEBUG_SLAB=y

The result of SLAB_LINEAR_OVERFLOW test doesn't remain deterministic in
this config. The task never crashes and hence stack trace never appears.
When executed several times we get "Slab corruption" logs and after some
more tries whole kernel crashes. I've not used DEBUG_SLAB before and not
sure if this is the expected behavior. If we aren't sure, we can keep
KASAN turned on instead.
Muhammad Usama Anjum April 4, 2022, 7:50 a.m. UTC | #4
Hi Kees,

Any thoughts?

On 3/15/22 4:55 PM, Muhammad Usama Anjum wrote:
> On 3/10/22 10:22 PM, Muhammad Usama Anjum wrote:
>> On 3/10/22 12:23 AM, Kees Cook wrote:
>>> On Fri, Feb 18, 2022 at 01:56:20AM +0500, Muhammad Usama Anjum wrote:
>>>> Add config option which is needed for SLAB_LINEAR_OVERFLOW test. It
>>>> needs KASAN enabled.
>>>
>>> I'd prefer this use the SLAB_DEBUG options -- KASAN is very heavy.
>> I'll test it out and update in the next patch version.
>> I've tested by removing KASAN and adding the following config:
> CONFIG_SLAB=y
> CONFIG_DEBUG_SLAB=y
> 
> The result of SLAB_LINEAR_OVERFLOW test doesn't remain deterministic in
> this config. The task never crashes and hence stack trace never appears.
> When executed several times we get "Slab corruption" logs and after some
> more tries whole kernel crashes. I've not used DEBUG_SLAB before and not
> sure if this is the expected behavior. If we aren't sure, we can keep
> KASAN turned on instead.
>
Kees Cook April 16, 2022, 9:13 p.m. UTC | #5
On Mon, Apr 04, 2022 at 12:50:01PM +0500, Muhammad Usama Anjum wrote:
> Hi Kees,
> 
> Any thoughts?
> 
> On 3/15/22 4:55 PM, Muhammad Usama Anjum wrote:
> > On 3/10/22 10:22 PM, Muhammad Usama Anjum wrote:
> >> On 3/10/22 12:23 AM, Kees Cook wrote:
> >>> On Fri, Feb 18, 2022 at 01:56:20AM +0500, Muhammad Usama Anjum wrote:
> >>>> Add config option which is needed for SLAB_LINEAR_OVERFLOW test. It
> >>>> needs KASAN enabled.
> >>>
> >>> I'd prefer this use the SLAB_DEBUG options -- KASAN is very heavy.
> >> I'll test it out and update in the next patch version.
> >> I've tested by removing KASAN and adding the following config:
> > CONFIG_SLAB=y
> > CONFIG_DEBUG_SLAB=y

I recommend slub instead:

CONFIG_SLUB=y
CONFIG_SLUB_DEBUG=y

and one more, see below...

> > 
> > The result of SLAB_LINEAR_OVERFLOW test doesn't remain deterministic in
> > this config. The task never crashes and hence stack trace never appears.
> > When executed several times we get "Slab corruption" logs and after some
> > more tries whole kernel crashes. I've not used DEBUG_SLAB before and not
> > sure if this is the expected behavior. If we aren't sure, we can keep
> > KASAN turned on instead.

I think you need to enable the actual kmem debugging with a boot param
("slub_debug=ZF"), or with CONFIG_SLUB_DEBUG_ON=y.
diff mbox series

Patch

diff --git a/tools/testing/selftests/lkdtm/config b/tools/testing/selftests/lkdtm/config
index adc9fa60057c5..4e8af0f712f74 100644
--- a/tools/testing/selftests/lkdtm/config
+++ b/tools/testing/selftests/lkdtm/config
@@ -7,6 +7,7 @@  CONFIG_HARDENED_USERCOPY=y
 CONFIG_RANDOMIZE_KSTACK_OFFSET_DEFAULT=y
 CONFIG_INIT_ON_FREE_DEFAULT_ON=y
 CONFIG_INIT_ON_ALLOC_DEFAULT_ON=y
+CONFIG_KASAN=y
 CONFIG_UBSAN=y
 CONFIG_UBSAN_BOUNDS=y
 CONFIG_UBSAN_TRAP=y