From patchwork Fri Jan 15 17:52:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 12023521 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.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 ADA54C433E0 for ; Fri, 15 Jan 2021 17:54:52 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6719822262 for ; Fri, 15 Jan 2021 17:54:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6719822262 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:From:Subject:Mime-Version:Message-Id:Date: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=YJ8UL1J1Ag6heeBct1VHA/dmVOQFqhYOnTom5MyYTzo=; b=J80HhQVhHvVo6fsjb6F0w1kecU aAeGOyBE87mjCXiKMOaJgiq3djys0xidG1LutBnHfybls82WGcXfnjlZPdYMxdhdQM8QzX+t22Jac dz2NQmF8i7RcPDWwhSy9m+Wt++0WlCPj+KVGakQEUPeERPrTw5WC5LMDNREEEcLqyPRtzbrAVL+l9 JckRt3suAzNPSF1GzwsByAVwy2SCxuId0YwqR76wxxQV/BfpwKZSl4W0jHbjH6EYxiy8/fOBh6TI3 4r1WQ8vXa6l9dqSwbJRBWEWYeqDKx7JrNDJWwHj2YtF/1QKqemNBl+Aj2esElio/CnfSRINWAaHty BMzYYGnA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l0THU-0003Px-Ra; Fri, 15 Jan 2021 17:53:04 +0000 Received: from mail-wr1-x44a.google.com ([2a00:1450:4864:20::44a]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l0THS-0003P8-At for linux-arm-kernel@lists.infradead.org; Fri, 15 Jan 2021 17:53:03 +0000 Received: by mail-wr1-x44a.google.com with SMTP id v5so4474579wrr.0 for ; Fri, 15 Jan 2021 09:53:00 -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=RYO/TR1Bbm4mW1iECzdQbQ7ZTGAweoPPzyjiEaLEaqY=; b=V3MEXFzAfm6O1FvX8MH9E2c/cNrk8iXVj8ItAgiMFTqZM5o/X5AjOwZwKENM0Idqd4 ZJ1jnjUK1t4aSH5ejtcq+ohqtE3hN4nvlrhH8B8wmSkPyWWVHtLQysbPxtAz8BIq5+VH HfPjHdcqflkFxM22fcpJ8+tOaoJJCmFGWGh9XW/zG4lPfKHWpofI/SftBwcqlOQE1o+t pf1l14nu5KYEHzIfsw+q8PKLTXbmG5+sXeVdXrIxVNxTilgWy+LjVSpZrR2x4ydpm0Jn zgEHF9T1KiOxZez1mb1+2NICyi1vuPwCx6ChPYzvm+JYaAIg3/PhKpGQBGlukojuzNGo NbGQ== 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=RYO/TR1Bbm4mW1iECzdQbQ7ZTGAweoPPzyjiEaLEaqY=; b=MzSrPKw1wqwvIk511VefcWP1aWaiGoR2aESBE5j2PT4eZ5x6VzqsB3JiGPYSJPmRMO ICJdVM81KKgFVGKf8i9LGH3/6+7S7EnKvlC9uBrq35ciSKD7Sa25d5MX2YsM2JCAsZqt mofDohsfpMJe9BMorglXPQ/l8ZcKRWjyEW6waKSug+Xd08mv71en7aZRkdoSygJjMVZo 3fN9Gg9t3wh/OuRhpDV9k17myYgJAtgxcT1ZyGg6h4duN2NttV+vTOenX271oJm9eVRH XSfjohkfDZ0RQwi5QYmNKcR+jK/vTFtj4Fo8pljo78F+BqwyrZKA5Cpvlk2WahNX4ENF 04eg== X-Gm-Message-State: AOAM532cklvtQHhwuEMWz1GHZGE+RQrUqKN+G8rjBnHNuJx10UfX9a1e DWhbOQ7TVs74b5g+nIABg8mCfh5c7o/WPjo/ X-Google-Smtp-Source: ABdhPJwG7faCpWeSX1O6QyfKQBzOXvqJrvQ3oBy9bg4d19WgkuuCGOUUerhmN4bT/0H9a4FTovsR3D5BFWBKy5hj X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:7220:84ff:fe09:7e9d]) (user=andreyknvl job=sendgmr) by 2002:adf:c64f:: with SMTP id u15mr13855560wrg.270.1610733179247; Fri, 15 Jan 2021 09:52:59 -0800 (PST) Date: Fri, 15 Jan 2021 18:52:37 +0100 Message-Id: Mime-Version: 1.0 X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7-goog Subject: [PATCH v4 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210115_125302_425138_D4C5EA95 X-CRM114-Status: GOOD ( 13.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Branislav Rankov , Andrey Konovalov , Kevin Brodsky , Will Deacon , linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, Andrey Ryabinin , Peter Collingbourne , Evgenii Stepanov Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patchset adds support for running KASAN-KUnit tests with the hardware tag-based mode and also contains a few fixes. Changes v3->v4: - Fix using tabs instead of spaces in bulk tests. - Simplify is_write calculation in report_tag_fault(). - Add a comment about tests to report_tag_fault(). 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 | 20 +- 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, 563 insertions(+), 282 deletions(-)