From patchwork Tue Sep 15 03:58:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gow X-Patchwork-Id: 255209 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93DE2C433E2 for ; Tue, 15 Sep 2020 03:59:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 53B14208FE for ; Tue, 15 Sep 2020 03:59:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="ABVIJhX8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726212AbgIOD7l (ORCPT ); Mon, 14 Sep 2020 23:59:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726131AbgIOD6m (ORCPT ); Mon, 14 Sep 2020 23:58:42 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04706C06178A for ; Mon, 14 Sep 2020 20:58:41 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id g189so2055774ybg.9 for ; Mon, 14 Sep 2020 20:58:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=SFW2h14ECMMfzbUIsG9wID+6ZK02/eLwTYcr5ku/IMk=; b=ABVIJhX806jGHQsihIKzkFUUo5qTWDAPwGoVM4EELEx7GxuYd9/3DVkQH0tB+L9/58 4zUPnndURQxy5TGqlNP8bCSPy0LsWjFlRt06sxcYwvDCf47PjmOp7vEMX74F+Ihl30tM Kglcdp5Dz9PhiYi9XZ6YntSvBSF3+djugiHJFHsET1N1FR/HTkBEuJ9MJXivTRCxfr0W ELbTvZb8m6xq5PFCQ8k9H4S2NPLSOmLsAtYRyyWNgNfyOYRpjRLd39Th1zgcpHY980Gy zzO6XT3FDxKyiz3gkav411niylSDBCCJH/TUS3YLOyoU5Ey/jyEICehafq7SH/a8ElW6 298Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=SFW2h14ECMMfzbUIsG9wID+6ZK02/eLwTYcr5ku/IMk=; b=p6jheRmb0RyM18TfNeCSwugEcDKK1Mn1D5wnI0Oy44d+9AOhfcNvVWu8F3cUc3eNOF gMzXin6dADSSIIYTJBbuKoSX7O+A8HYtz/W9du3lDdRGm64uTX9gf8qiT0MVF1ARIqRy 8D4LVJfy70D3xY4cKYwlaRwf8dcYPQ0I5tDHMj4GCiWWONO+O3JEH+WDzL2qFe4zrkXK IYZsHf9XbftRfmHFebaQFg9aVkOrbqmuHsa5Urf7VLmiLKMWtdVBghTfKbPQ3w+2904v 3cRSDEU/LCnGxc+bwTF2yqZf9D1NAzA4HokQlecbJCM8XphWEGYqukSXkPGmlWViHPqU SGOQ== X-Gm-Message-State: AOAM532INsVaVZp+5qH8HlbbrELkOnGfFMQWfHq6c41NeSUpBCp2MUiR Hi/GUF2pGkNiWtyawyNKvclwTt/SndDjZQ== X-Google-Smtp-Source: ABdhPJwUTN/q5oIZgo9BR3mgcGZqMpJPurbhBbHip39SJ5emScGzGYX2IC7yh46SEHu0YQRihBfnbKwONFvC+A== X-Received: from spirogrip.svl.corp.google.com ([2620:15c:2cb:201:42a8:f0ff:fe4d:3548]) (user=davidgow job=sendgmr) by 2002:a25:be13:: with SMTP id h19mr27646628ybk.50.1600142319270; Mon, 14 Sep 2020 20:58:39 -0700 (PDT) Date: Mon, 14 Sep 2020 20:58:24 -0700 In-Reply-To: <20200915035828.570483-1-davidgow@google.com> Message-Id: <20200915035828.570483-2-davidgow@google.com> Mime-Version: 1.0 References: <20200915035828.570483-1-davidgow@google.com> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [PATCH v14 1/5] Add KUnit Struct to Current Task From: David Gow To: trishalfonso@google.com, brendanhiggins@google.com, aryabinin@virtuozzo.com, dvyukov@google.com, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, andreyknvl@google.com, shuah@kernel.org, akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, David Gow Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org From: Patricia Alfonso In order to integrate debugging tools like KASAN into the KUnit framework, add KUnit struct to the current task to keep track of the current KUnit test. Signed-off-by: Patricia Alfonso Reviewed-by: Brendan Higgins Tested-by: Andrey Konovalov Signed-off-by: David Gow --- include/linux/sched.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/sched.h b/include/linux/sched.h index afe01e232935..9df9416c5a40 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1203,6 +1203,10 @@ struct task_struct { #endif #endif +#if IS_ENABLED(CONFIG_KUNIT) + struct kunit *kunit_test; +#endif + #ifdef CONFIG_FUNCTION_GRAPH_TRACER /* Index of current stored address in ret_stack: */ int curr_ret_stack; From patchwork Tue Sep 15 03:58:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gow X-Patchwork-Id: 255210 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E566FC433E2 for ; Tue, 15 Sep 2020 03:59:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A5CE0208FE for ; Tue, 15 Sep 2020 03:59:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="Qg6CHZ5g" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726146AbgIOD65 (ORCPT ); Mon, 14 Sep 2020 23:58:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726148AbgIOD6s (ORCPT ); Mon, 14 Sep 2020 23:58:48 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFA48C061351 for ; Mon, 14 Sep 2020 20:58:47 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id r9so2050102ybd.20 for ; Mon, 14 Sep 2020 20:58:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=jND5K7nrTIUr/jnKohKbWFO0ev/Az4T5zj9+dc82ED0=; b=Qg6CHZ5gHjhda+KwUOhclR4Q3kDy3biP0i2FZHBxpfArWudV4ORqkavGZ804ogOMUy 8AUNGmNkzsDG73STZid0h0HXNjcgdhU4z3oj6pqyPjdc1v1BMSCNOBh546+lDwWinBM4 cSlB1yrVcuwV2HUQQYnA6r4/PxntWOm1hhTkIerea3b0w8zu6c5UEDEtj+WcoE3hx7R1 YA1AxmrHGF7aGsI8eMd0/1MjlansTNSSQzyABO6LIF06D7toFkjbaSfU/b9S5nvjHrim VBUPtn9VDxBpNA7C2qX9ZnMsLj+kasG45T7Fsvm4BO4z47Kg6OcXsgjtIINYa94fy2AP jaQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=jND5K7nrTIUr/jnKohKbWFO0ev/Az4T5zj9+dc82ED0=; b=HPeSB0fZHuPo95KLwaG7uyHNcqChF4QO1V8yzt8Su0inem17AthzUj4k0hnytraZOl TqkZWZV80iysGn6claOWQ0KueMQeA01JkNwgRUuO5LXJZzCLfGL/5lB7hMKsAmZoa13h 6S1x38fKvNzTDb3WAJfjttLkI9wpEnU0aBDwkrco0baV3z/oEMT22LpzkbrrJJkZV9AP HwUYxMbrakAeHUKp5GVicsU1NqRegBQwchRaW8rtal3tNmx1X2dp5DbtN9UHuWwNyDMb Ye7Zw40BPOlW7bKE9ZbHqYppNqaa09URqSzaVONyNhKsuqFd8iN2p0QsuJlEYYjQoGaG lalA== X-Gm-Message-State: AOAM533hmcNXLgBkQmsVjRXHjeATsCAoOpZVsz8X4Wo8dZkoi0fSr2OY r10DGlYJtw0W6cBUQX7jnKvRN1niK5UQcQ== X-Google-Smtp-Source: ABdhPJwNy5/SF/gC/zNSc6jUHjF6RdEpH1yc/KAlxvozMks7rfzxf+Z68GE5eK2NaQQX5jQCMnFNIydwDzj4gw== X-Received: from spirogrip.svl.corp.google.com ([2620:15c:2cb:201:42a8:f0ff:fe4d:3548]) (user=davidgow job=sendgmr) by 2002:a25:10c1:: with SMTP id 184mr23945299ybq.407.1600142327208; Mon, 14 Sep 2020 20:58:47 -0700 (PDT) Date: Mon, 14 Sep 2020 20:58:28 -0700 In-Reply-To: <20200915035828.570483-1-davidgow@google.com> Message-Id: <20200915035828.570483-6-davidgow@google.com> Mime-Version: 1.0 References: <20200915035828.570483-1-davidgow@google.com> X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [PATCH v14 5/5] mm: kasan: Do not panic if both panic_on_warn and kasan_multishot set From: David Gow To: trishalfonso@google.com, brendanhiggins@google.com, aryabinin@virtuozzo.com, dvyukov@google.com, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, andreyknvl@google.com, shuah@kernel.org, akpm@linux-foundation.org Cc: David Gow , linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, linux-mm@kvack.org Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org KASAN errors will currently trigger a panic when panic_on_warn is set. This renders kasan_multishot useless, as further KASAN errors won't be reported if the kernel has already paniced. By making kasan_multishot disable this behaviour for KASAN errors, we can still have the benefits of panic_on_warn for non-KASAN warnings, yet be able to use kasan_multishot. This is particularly important when running KASAN tests, which need to trigger multiple KASAN errors: previously these would panic the system if panic_on_warn was set, now they can run (and will panic the system should non-KASAN warnings show up). Signed-off-by: David Gow Reviewed-by: Andrey Konovalov Reviewed-by: Brendan Higgins Tested-by: Andrey Konovalov --- mm/kasan/report.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/kasan/report.c b/mm/kasan/report.c index e2c14b10bc81..00a53f1355ae 100644 --- a/mm/kasan/report.c +++ b/mm/kasan/report.c @@ -95,7 +95,7 @@ static void end_report(unsigned long *flags) pr_err("==================================================================\n"); add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE); spin_unlock_irqrestore(&report_lock, *flags); - if (panic_on_warn) { + if (panic_on_warn && !test_bit(KASAN_BIT_MULTI_SHOT, &kasan_flags)) { /* * This thread may hit another WARN() in the panic path. * Resetting this prevents additional WARN() from panicking the