From patchwork Wed Aug 5 04:29:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gow X-Patchwork-Id: 255319 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=-20.6 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT, USER_IN_DEF_DKIM_WL 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 7C966C433E1 for ; Wed, 5 Aug 2020 04:29:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6231C22CA0 for ; Wed, 5 Aug 2020 04:29:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="KH87wYJU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726104AbgHEE3w (ORCPT ); Wed, 5 Aug 2020 00:29:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725372AbgHEE3u (ORCPT ); Wed, 5 Aug 2020 00:29:50 -0400 Received: from mail-qt1-x84a.google.com (mail-qt1-x84a.google.com [IPv6:2607:f8b0:4864:20::84a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DDEEC06174A for ; Tue, 4 Aug 2020 21:29:50 -0700 (PDT) Received: by mail-qt1-x84a.google.com with SMTP id k35so25546228qtk.9 for ; Tue, 04 Aug 2020 21:29:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=1s/fGj49wZAcV85LY6dM4ghB8ELbpKuQm5SC6WcoZ6s=; b=KH87wYJUH7h4lE7GNyS9Zkc0/3HRb/qCKsvepF+wF74pNbnprxanLXxWGZSvHNat2a KWa0kEHWNrd7PrwIvCVKfksv1mmUs8g8LsJsxRw8MqeCep8TI+d7HZWQeJasaU/JwQTW AKpMgngEZL/m8NQmYa4KC6mczZeb/RC8JGkMGn0iRU3KSk33CpJ016RNn/IZGuOGUJL2 oV6vVsprw0GfpE7+M7sO/O9plsvSGD0AeS1E2y/MrYtytWkyzdyBOZguaFPwKeQ1WQqS DYh72SsnIMEPVXGCBfQKMj9RN29n+3XzA7q63+xuoi/uaVbvSqOkv2MSoghGEn2bQzLj N8XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=1s/fGj49wZAcV85LY6dM4ghB8ELbpKuQm5SC6WcoZ6s=; b=lVeGlVxLIb0u3dgvRwhhl3v79lujlzkm2gos/BXl51RK9r8tS0THNgvNHEM/hwNp1n Rc8BX3QcRHxQox2jcXlPzx4pPlTkBt3DZNYESyalCcNK8Dt9wlI6LlLR0zZj9dOU+YNO tFAAf5PN06+xxDzeyYBVCoKp37DO/rSS9MOp1ejR2NJU6HheD3xQi3qtQ/zIJf0b79Cr iMpQJHnxUu3oK7muyiXMtYzrpOFNieOyakiaCTfnd1E7j0AIjSyzsDf4el5ZmvQHvzOU 6YDVvqde8nI/EK3rQg/8hNGIdi0jReOphm7SaxzDtPwINaXRc91JqEyKzCrUdHpMjKH0 SJhg== X-Gm-Message-State: AOAM533w6rIMXZvpuF/AyPyVmia41LHR4D0mjcbpWlA8k79OnNhsNMuF CiJACQvUuD2vrri0wSm6KVd8CXLOABcnRA== X-Google-Smtp-Source: ABdhPJylrtvvJBJ9f9qdqVMEdPVylXivJYIOITqT9qZY1M+5gLFwdOVxzioKQUYCPH/JukP+OFQzFLRW8FIJlw== X-Received: by 2002:a05:6214:1742:: with SMTP id dc2mr1836989qvb.90.1596601789643; Tue, 04 Aug 2020 21:29:49 -0700 (PDT) Date: Tue, 4 Aug 2020 21:29:33 -0700 In-Reply-To: <20200805042938.2961494-1-davidgow@google.com> Message-Id: <20200805042938.2961494-2-davidgow@google.com> Mime-Version: 1.0 References: <20200805042938.2961494-1-davidgow@google.com> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog Subject: [PATCH v11 1/6] 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 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 27882a08163f..f3f990b82bde 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1196,6 +1196,10 @@ struct task_struct { struct kcsan_ctx kcsan_ctx; #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 Wed Aug 5 04:29:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gow X-Patchwork-Id: 255317 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=-20.6 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT, USER_IN_DEF_DKIM_WL 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 0FAD5C433DF for ; Wed, 5 Aug 2020 04:30:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E916C22CE3 for ; Wed, 5 Aug 2020 04:30:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Pafk7wW3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726382AbgHEEaR (ORCPT ); Wed, 5 Aug 2020 00:30:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726248AbgHEE34 (ORCPT ); Wed, 5 Aug 2020 00:29:56 -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 0FDE9C061756 for ; Tue, 4 Aug 2020 21:29:56 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id d26so22706850yba.20 for ; Tue, 04 Aug 2020 21:29:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=mFQWzCkGaiFIpXpMkbbRXHow6YpRUyxsgQjGovY4KbU=; b=Pafk7wW34NRlap/R+QTTHb10TijoNPHnI1j9R1KFOtQizsqW9Z+cU+XJnYz/nZZ0/B zT087oCYjbIxd7tWgSd3zReI0bn+eTB4GeaZsr6DsZnFvOlc1gpZDGDGvg7iNoEavP4i 7eSVcN/hInYxYtl1JtOv025ncEAt8kyDQZW8Ubgy+so2hXVZ2g6VsQCADxdLKo2kkpBA TmakdaHtqRt+ZFm4ZmGMLhqb89w34Pmm+JKkaTHSiuwuL2ELcPlW4Pq50LhXMNHxhA8K oSBLF7qEpXVY7jSHAw0MRty7U/0XBtDpVCr3JYyP6XEpoweKTTLEYySZPGQz/uiMkL3B vJ4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=mFQWzCkGaiFIpXpMkbbRXHow6YpRUyxsgQjGovY4KbU=; b=CJ2vIS7DuEkiObrcvOnBRER7845CAKRLSAv7y+mN+05SuaTJdOE6PwMuvVCw8WBlRx 7xALsucwYjYHvjk6b866NBTKuwFyfI5QAs/Oj9T56DAnygZFj8vGNh6oL+D+1qsseHbd WB5INTlzv7O3CjgPy6YYnBO9KW4Yu5viiABT8Y/RriDYCPsc/MGWlaXBF8Tc70fShole UEtXiJ5sD4YvAsCOHeLBgNX6Zpp/FACiFSeFJol/6srtitVSraaDB5U70NnpaiDzbZtI QaX8JRwrbnALllqb7C1DB2gTmAn14AWhN9STMqr3pkZ7u0VI5OhgIUKB1JcB/Z+5zkHe 1HhQ== X-Gm-Message-State: AOAM533o928QkPOuQtMpa+pvrfnn5jucmgQKhsZyRQK9wLOUTtl9lxnv PJchbvyzzQuWZ9miqkhIBTxT8CtRNF4YAA== X-Google-Smtp-Source: ABdhPJzF05VQn25N8IX0+W6dIaLPsJOO/gmDBs2lgBSOzWTR+bXWFf6QNGczIuMYMR1Nm8tW4KtRxupn/70klA== X-Received: by 2002:a25:3803:: with SMTP id f3mr1978981yba.470.1596601795228; Tue, 04 Aug 2020 21:29:55 -0700 (PDT) Date: Tue, 4 Aug 2020 21:29:36 -0700 In-Reply-To: <20200805042938.2961494-1-davidgow@google.com> Message-Id: <20200805042938.2961494-5-davidgow@google.com> Mime-Version: 1.0 References: <20200805042938.2961494-1-davidgow@google.com> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog Subject: [PATCH v11 4/6] kasan: test: Make KASAN KUnit test comply with naming guidelines 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 The proposed KUnit test naming guidelines[1] suggest naming KUnit test modules [suite]_kunit (and hence test source files [suite]_kunit.c). Rename test_kunit.c to kasan_kunit.c to comply with this, and be consistent with other KUnit tests. [1]: https://lore.kernel.org/linux-kselftest/20200702071416.1780522-1-davidgow@google.com/ Signed-off-by: David Gow --- lib/Makefile | 6 +++--- lib/{test_kasan.c => kasan_kunit.c} | 0 2 files changed, 3 insertions(+), 3 deletions(-) rename lib/{test_kasan.c => kasan_kunit.c} (100%) diff --git a/lib/Makefile b/lib/Makefile index adaebfac81c9..8a530bf7078c 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -60,9 +60,9 @@ CFLAGS_test_bitops.o += -Werror obj-$(CONFIG_TEST_SYSCTL) += test_sysctl.o obj-$(CONFIG_TEST_HASH) += test_hash.o test_siphash.o obj-$(CONFIG_TEST_IDA) += test_ida.o -obj-$(CONFIG_KASAN_KUNIT_TEST) += test_kasan.o -CFLAGS_test_kasan.o += -fno-builtin -CFLAGS_test_kasan.o += $(call cc-disable-warning, vla) +obj-$(CONFIG_KASAN_KUNIT_TEST) += kasan_kunit.o +CFLAGS_kasan_kunit.o += -fno-builtin +CFLAGS_kasan_kunit.o += $(call cc-disable-warning, vla) obj-$(CONFIG_TEST_KASAN_MODULE) += test_kasan_module.o obj-$(CONFIG_TEST_UBSAN) += test_ubsan.o CFLAGS_test_ubsan.o += $(call cc-disable-warning, vla) diff --git a/lib/test_kasan.c b/lib/kasan_kunit.c similarity index 100% rename from lib/test_kasan.c rename to lib/kasan_kunit.c From patchwork Wed Aug 5 04:29:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gow X-Patchwork-Id: 255318 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=-20.6 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT, USER_IN_DEF_DKIM_WL 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 31A2AC433E1 for ; Wed, 5 Aug 2020 04:30:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 15DD722CBE for ; Wed, 5 Aug 2020 04:30:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="OtjJ7ZSO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726566AbgHEEaG (ORCPT ); Wed, 5 Aug 2020 00:30:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726518AbgHEEaB (ORCPT ); Wed, 5 Aug 2020 00:30:01 -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 9C759C06174A for ; Tue, 4 Aug 2020 21:30:00 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id u206so17757621ybb.8 for ; Tue, 04 Aug 2020 21:30:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=Y00REmw7cW2Ho0KOM1NABcGJpQIr8u0gXHD6A1O7ZXc=; b=OtjJ7ZSOy+P1/e1/ee1YUJbWdg+u0tTRw6B9Yl1dD1X+EXBfL8hI28LcD2xNuRVxv7 UO+Tg7Ldk8N4W4MYp/ciEcY6LKafeRPJJKXgMRdXWWFT4TdS0cSN9PTQKTnT6iF05IdD cJBozNbmRDQdqlZgNG1KZb5uAi2w1kr8VJLa8QZTXVPR5OY3q9AvRTTEbBt3Hw78zlAn rW8JVHoIrl2OUuJ7SCP3lFRx7Py2mmWxNGTuKU6KTYMQYYwPHmZGUtoCgTTr9WJJZQvZ Zdh8zAzKkkws2u8fNMAzBsh4WCWBRjA4QIwuFdiesJu8oFhsAg368qSQumimvA/t52sh mhBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Y00REmw7cW2Ho0KOM1NABcGJpQIr8u0gXHD6A1O7ZXc=; b=XSqaWpjy/pnI5LiI9sAYczJKXR3CqNo9P8/ybjxSASg5Qm4sstltlkRhOuCCS4dSqH 3zjeZuARiPLn461ehtZyPZpJykLKWCSHC7XY8WvkXQNsQZEjddAwcfrIbjT4hmD5zVjO 2ulh6g26ACJ7th2ONkXvnIyuRI8sAj6qr2fpG5Rcwxbzn4DSbUuyCiHEuwfdTPBFD486 N2FxCSy4BAe4X+IDhWvumUjxNI4K/KXds0ltbA7AEhfc2BT2n4SG/8ovlr7QvsQZ3raN EtWSCMbjaqfaKKN2eUSfC2ipmUTxBwkXDpm6dtVJll5na7fswwzk5/UPw+GDgYu21A4V 6s/Q== X-Gm-Message-State: AOAM531QYc7jrtInDUI5CT359bf1MAxcRImypvt1faF0hgBCrQwthxku RvIwjUlVZAOrxOyLevnjv2WOwuwe/cjiew== X-Google-Smtp-Source: ABdhPJxXjGFwD40kee1mNnaPkbYMTsK0NB+Nl4pE7YyjsA4sfahOk4MpuFQvMN8FFzVOGOoGSQTphyt0akERlg== X-Received: by 2002:a25:8411:: with SMTP id u17mr658207ybk.95.1596601799856; Tue, 04 Aug 2020 21:29:59 -0700 (PDT) Date: Tue, 4 Aug 2020 21:29:38 -0700 In-Reply-To: <20200805042938.2961494-1-davidgow@google.com> Message-Id: <20200805042938.2961494-7-davidgow@google.com> Mime-Version: 1.0 References: <20200805042938.2961494-1-davidgow@google.com> X-Mailer: git-send-email 2.28.0.163.g6104cc2f0b6-goog Subject: [PATCH v11 6/6] 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 --- 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