Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp8945889ybi; Tue, 23 Jul 2019 18:38:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqxFh5jN6QQWCnmON3A3dUc2DzUTTAJACIymxsLbprO6BgA/CGaERMfiDG+DjecwXO/MjPn/ X-Received: by 2002:a63:2cd5:: with SMTP id s204mr63999639pgs.95.1563932312236; Tue, 23 Jul 2019 18:38:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563932312; cv=none; d=google.com; s=arc-20160816; b=JTyoNLPy059/DPtELgDeQRN0nOY0pzPDEI2yR8SIGN7kGXzsN7DUKzVZtZBevhCDPb VGeWy6zJG/PrSstCpVaXkRc4hS7Nn6l3xe5RJPSwcXij4xxCRtTZMLW1fpbQWHDP+zwR WtjtHSaaciILFo1s95v5E1DWWIp23jyJx1FB9uKVEC2gyuE88/lnLCvnhLCG2vqLJ7Rm 5wWQsc+Tq1uUNojpOWkQWatYdxx3C0ffx+HcwOgW70iXlUQ4BDLqDo0Is2iuJIacP6H6 nylxsihLLYcy2neUsSxmtmj8+tMVMZa0oHvjEl1dJ+kUprh5/+YzqI9w42hBv7kcSeXS 4IyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=P/ukJIx+SOx9JE2DP2ABaOJWk92MtaCXggShecwUP5o=; b=tSDLwVy9rnDgg06WAD8iGQoFTdAS0EUybKvE0/xT2JzMrH6PpZ5H9pfe1aA7HdWUgI ySLoY0ni5E+3wXTJy4ZJpLT5XIX+0b7ETo/UXQFn9aQZaFBXzDWWCD/jUC1hC7te8Tcd BF4C2hqLATb7oTvFFsFqyruvYudy4edpndR56+6320oIcim5kne8sDB62TS4Fd5taI/P Ei5XzFwRHFRsQUYx4uHAnI6OOXJkMV/0B3Ztthze1/Nctc2s+WqzIpydB7vM95y56uu6 vxTTTwgcrtQ5x+jtYWX4B/UI7EXKcbVKmuV3KOgxs+r8MYIfTrk7NYnpIIBz/3E6vmP3 lWLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=XRAh43Dh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 36si13661114pla.80.2019.07.23.18.38.15; Tue, 23 Jul 2019 18:38:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=XRAh43Dh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388206AbfGWQtQ (ORCPT + 99 others); Tue, 23 Jul 2019 12:49:16 -0400 Received: from mail-ot1-f65.google.com ([209.85.210.65]:35844 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729558AbfGWQtQ (ORCPT ); Tue, 23 Jul 2019 12:49:16 -0400 Received: by mail-ot1-f65.google.com with SMTP id r6so44727330oti.3 for ; Tue, 23 Jul 2019 09:49:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=P/ukJIx+SOx9JE2DP2ABaOJWk92MtaCXggShecwUP5o=; b=XRAh43DhYHr6hqbYWH2TPLCxkWTRBuf0im761f4sciXdQQBq28WEAawzlWsQmVK5xY jalcZFxUeB96wU0xx5DAAjnvu2wLtNWupPF+ahljpX5MoAtBMzXth62D85W/XjbEanon 1watVi0MXu7uKcu7u4yPN/cKECawgxtLOuRc6OlzaFMbSw02IgdGAERs5y8tTbhQJCIh UBS5oFzobf4oV0e4kW5cFqkS2xe5hPjmOMHdLBLFNBovKrLA7klqMYw+Cvnr69RCCT5A Zxtonyc4GZVbfl9/dPaq8hVc2zeC6J8aIEWNoyCNKJFm14i3cMEt5Wx2bUqGLn8iFtaY 02sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=P/ukJIx+SOx9JE2DP2ABaOJWk92MtaCXggShecwUP5o=; b=B4ShOeSHJlJV9RVHf2BxsGhtlmjV8LOknoStdD3s+DBoZ356i5A1FYuGctgyH0ZgsS yPGzIdPujxTxFQzQGZnWdPOKrPvrLmo6nUPV+E9RtiVWDzNxCF/fJHRdJLrQnt/1ThuB BEHwmIQMFiufxa9MkNhx/HpA5yQueZ7SwcNJCfKcdcLRCtJoVBIhIoYAUt5BnmyYOR0R IPngcmwiIRk0AHmumIX/VSn6qlD7etmmp+jV23pwZ4gT3zL+W4+ff7ZkhodH4ytDzQSy zmse16eGZIVIYQuuj6gT4VsfJfyeBLcZvwyRmcYb+GOEiYJaS3klP89DBP2s10Sk4HML 5Cdw== X-Gm-Message-State: APjAAAUPevMcNIbtfO/BlMMx8ObGsZJap93a5zQnic55K1UWzNWay3T+ MheqjXyrdbOT8ton5qyh9LT8PSy0fSMpC3G3X1Agug== X-Received: by 2002:a9d:560f:: with SMTP id e15mr22483518oti.251.1563900554830; Tue, 23 Jul 2019 09:49:14 -0700 (PDT) MIME-Version: 1.0 References: <20190719132818.40258-1-elver@google.com> <20190719132818.40258-2-elver@google.com> <20190723162403.GA56959@lakrids.cambridge.arm.com> In-Reply-To: <20190723162403.GA56959@lakrids.cambridge.arm.com> From: Marco Elver Date: Tue, 23 Jul 2019 18:49:03 +0200 Message-ID: Subject: Re: [PATCH 2/2] lib/test_kasan: Add stack overflow test To: Mark Rutland Cc: LKML , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Andrey Konovalov , Peter Zijlstra , "the arch/x86 maintainers" , kasan-dev Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 23 Jul 2019 at 18:24, Mark Rutland wrote: > > On Fri, Jul 19, 2019 at 03:28:18PM +0200, Marco Elver wrote: > > Adds a simple stack overflow test, to check the error being reported on > > an overflow. Without CONFIG_STACK_GUARD_PAGE, the result is typically > > some seemingly unrelated KASAN error message due to accessing random > > other memory. > > Can't we use the LKDTM_EXHAUST_STACK case to check this? > > I was also under the impression that the other KASAN self-tests weren't > fatal, and IIUC this will kill the kernel. > > Given that, and given this is testing non-KASAN functionality, I'm not > sure it makes sense to bundle this with the KASAN tests. Thanks for pointing out LKDTM_EXHAUST_STACK. This patch can be dropped! -- Marco > Thanks, > Mark. > > > > > Signed-off-by: Marco Elver > > Cc: Thomas Gleixner > > Cc: Ingo Molnar > > Cc: Borislav Petkov > > Cc: "H. Peter Anvin" > > Cc: Andrey Ryabinin > > Cc: Alexander Potapenko > > Cc: Dmitry Vyukov > > Cc: Andrey Konovalov > > Cc: Mark Rutland > > Cc: Peter Zijlstra > > Cc: x86@kernel.org > > Cc: linux-kernel@vger.kernel.org > > Cc: kasan-dev@googlegroups.com > > --- > > lib/test_kasan.c | 36 ++++++++++++++++++++++++++++++++++++ > > 1 file changed, 36 insertions(+) > > > > diff --git a/lib/test_kasan.c b/lib/test_kasan.c > > index b63b367a94e8..3092ec01189d 100644 > > --- a/lib/test_kasan.c > > +++ b/lib/test_kasan.c > > @@ -15,6 +15,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > @@ -709,6 +710,32 @@ static noinline void __init kmalloc_double_kzfree(void) > > kzfree(ptr); > > } > > > > +#ifdef CONFIG_STACK_GUARD_PAGE > > +static noinline void __init stack_overflow_via_recursion(void) > > +{ > > + volatile int n = 512; > > + > > + BUILD_BUG_ON(IS_ENABLED(CONFIG_STACK_GROWSUP)); > > + > > + /* About to overflow: overflow via alloca'd array and try to write. */ > > + if (!object_is_on_stack((void *)&n - n)) { > > + volatile char overflow[n]; > > + > > + overflow[0] = overflow[0]; > > + return; > > + } > > + > > + stack_overflow_via_recursion(); > > +} > > + > > +static noinline void __init kasan_stack_overflow(void) > > +{ > > + pr_info("stack overflow begin\n"); > > + stack_overflow_via_recursion(); > > + pr_info("stack overflow end\n"); > > +} > > +#endif > > + > > static int __init kmalloc_tests_init(void) > > { > > /* > > @@ -753,6 +780,15 @@ static int __init kmalloc_tests_init(void) > > kasan_bitops(); > > kmalloc_double_kzfree(); > > > > +#ifdef CONFIG_STACK_GUARD_PAGE > > + /* > > + * Only test with CONFIG_STACK_GUARD_PAGE, as without we get other > > + * random KASAN violations, due to accessing other random memory (we > > + * want to avoid actually corrupting memory in these tests). > > + */ > > + kasan_stack_overflow(); > > +#endif > > + > > kasan_restore_multi_shot(multishot); > > > > return -EAGAIN; > > -- > > 2.22.0.657.g960e92d24f-goog > > > > -- > You received this message because you are subscribed to the Google Groups "kasan-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an email to kasan-dev+unsubscribe@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/kasan-dev/20190723162403.GA56959%40lakrids.cambridge.arm.com.