From patchwork Thu Jan 14 19:36:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 12020743 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=-11.6 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 6C042C433E0 for ; Thu, 14 Jan 2021 19:36:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0A16823A52 for ; Thu, 14 Jan 2021 19:36:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0A16823A52 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7D8DA8D0114; Thu, 14 Jan 2021 14:36:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7880A8D00F0; Thu, 14 Jan 2021 14:36:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 676928D0114; Thu, 14 Jan 2021 14:36:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0213.hostedemail.com [216.40.44.213]) by kanga.kvack.org (Postfix) with ESMTP id 4F79C8D00F0 for ; Thu, 14 Jan 2021 14:36:36 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 13BA53638 for ; Thu, 14 Jan 2021 19:36:36 +0000 (UTC) X-FDA: 77705387592.26.lamp97_4d0119c27529 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin26.hostedemail.com (Postfix) with ESMTP id E2A1718010A67 for ; Thu, 14 Jan 2021 19:36:35 +0000 (UTC) X-HE-Tag: lamp97_4d0119c27529 X-Filterd-Recvd-Size: 5616 Received: from mail-qv1-f73.google.com (mail-qv1-f73.google.com [209.85.219.73]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Thu, 14 Jan 2021 19:36:35 +0000 (UTC) Received: by mail-qv1-f73.google.com with SMTP id cc1so5472098qvb.3 for ; Thu, 14 Jan 2021 11:36:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=R63zbbCAwIca54YwZmiIwYnYLBR+THCEQGhD+FuGdpk=; b=swxZvrs/FyBUYyfMULYTNVyP+KnTw21pr9Aiiqx7Q46Yx/Ut5r2yaF5AVCRuhq/+qf U+GtJUGu288gKpEedjG8+E9MOJsAOKPjfLUhdmkBfAN/AYExLqyFthP1Q6aAzb32CSkc KaMVXz4yb51GNIVqOYZ8ks1UkuhO1eVAc2q8PxT16Gfsk0Cj2SVUVvIUco1fk1j0HbPz caWuq2bW15nwFh/knGbnoPd41H6ZddRXPBpThpo703woe6zwphpuUGiZsNkOlfFwkATT NWh9eYF1LC4Ln5qhMwFeGKmdF5E8Vf2akSKQVJkvUjL4lepD/g3Z05a8XdUM2vZ7qR6M QAqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=R63zbbCAwIca54YwZmiIwYnYLBR+THCEQGhD+FuGdpk=; b=nAj51hI+SLiWxTZX4ABeRhNTPNfQPV17H4bF7Sj5cqoON4vQWzUWO9DvFa3Hdw1ieg KEl63sJKjeGF2pE2q15g9fDwcSagrYJ9J60WS13c4ZGgP8SMvx9YOHx4VcDgznC+5p0U ZDbzlCayT2WCvKVZpxfj+6MO0JZREhitlR4XwKEoctud+vD9RruvzMJN+1gOZ62tUGje wWoIXp9ste9vKL/TxGTVPoiU+kiZc4Y0N+t6ZPWRRFEw1E0aXckombFfx8NBe5tj5+18 ZRqHTpu90WkNbaDKWIjwdjvWIrzPbtpTCJCx9KGB3QvP4nY/wx0PmGP1P1/GKU1DT6Ja 0/sg== X-Gm-Message-State: AOAM533T3Gc7yLZGNw1bVIZUph5+Abk6az6IyvxTT648A/NSXdb+jatl RDqAlAG/58z0qb1MfgGSHqIKZeNbabRyGYBo X-Google-Smtp-Source: ABdhPJzTwS7gDhbMJeWMCLyUR7WhVrcIzT1QADDy3zJiUE3fwfmlECttiTh3d1GYrDqZu6WWlM6UTcfC/EjW5ohN X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:7220:84ff:fe09:7e9d]) (user=andreyknvl job=sendgmr) by 2002:ad4:4643:: with SMTP id y3mr8625481qvv.3.1610652994549; Thu, 14 Jan 2021 11:36:34 -0800 (PST) Date: Thu, 14 Jan 2021 20:36:16 +0100 Message-Id: Mime-Version: 1.0 X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7-goog Subject: [PATCH v3 00/15] kasan: HW_TAGS tests support and fixes From: Andrey Konovalov To: Andrew Morton , Catalin Marinas , Vincenzo Frascino , Dmitry Vyukov , Alexander Potapenko , Marco Elver Cc: Will Deacon , Andrey Ryabinin , Peter Collingbourne , Evgenii Stepanov , Branislav Rankov , Kevin Brodsky , kasan-dev@googlegroups.com, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This patchset adds support for running KASAN-KUnit tests with the hardware tag-based mode and also contains a few fixes. Changes v2->v3: - Don't call kmalloc(0) when generating random size. - Use ARRAY_SIZE() in kmem_cache_bulk_alloc() test. - Print error message when tests are being ran with kasan.mode=off. - Move _RET_IP_ to inline wrappers for kasan annotations. Andrey Konovalov (15): kasan: prefix global functions with kasan_ kasan: clarify HW_TAGS impact on TBI kasan: clean up comments in tests kasan: add macros to simplify checking test constraints kasan: add match-all tag tests kasan, arm64: allow using KUnit tests with HW_TAGS mode kasan: rename CONFIG_TEST_KASAN_MODULE kasan: add compiler barriers to KUNIT_EXPECT_KASAN_FAIL kasan: adapt kmalloc_uaf2 test to HW_TAGS mode kasan: fix memory corruption in kasan_bitops_tags test kasan: move _RET_IP_ to inline wrappers kasan: fix bug detection via ksize for HW_TAGS mode kasan: add proper page allocator tests kasan: add a test for kmem_cache_alloc/free_bulk kasan: don't run tests when KASAN is not enabled Documentation/dev-tools/kasan.rst | 24 +- arch/arm64/include/asm/memory.h | 1 + arch/arm64/include/asm/mte-kasan.h | 12 + arch/arm64/kernel/mte.c | 12 + arch/arm64/mm/fault.c | 16 +- include/linux/kasan-checks.h | 6 + include/linux/kasan.h | 37 ++- lib/Kconfig.kasan | 6 +- lib/Makefile | 2 +- lib/test_kasan.c | 424 +++++++++++++++++++++-------- lib/test_kasan_module.c | 5 +- mm/kasan/common.c | 56 ++-- mm/kasan/generic.c | 38 +-- mm/kasan/kasan.h | 69 +++-- mm/kasan/quarantine.c | 22 +- mm/kasan/report.c | 15 +- mm/kasan/report_generic.c | 8 +- mm/kasan/report_hw_tags.c | 8 +- mm/kasan/report_sw_tags.c | 8 +- mm/kasan/shadow.c | 26 +- mm/kasan/sw_tags.c | 20 +- mm/mempool.c | 2 +- mm/slab.c | 2 +- mm/slab_common.c | 16 +- mm/slub.c | 4 +- tools/objtool/check.c | 2 +- 26 files changed, 559 insertions(+), 282 deletions(-)