From patchwork Wed Jan 13 16:21:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 12017269 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 F0A78C433DB for ; Wed, 13 Jan 2021 16:21:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5B7582313C for ; Wed, 13 Jan 2021 16:21:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5B7582313C 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 7041B8D0067; Wed, 13 Jan 2021 11:21:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6D9FA8D002E; Wed, 13 Jan 2021 11:21:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5C8538D0067; Wed, 13 Jan 2021 11:21:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0044.hostedemail.com [216.40.44.44]) by kanga.kvack.org (Postfix) with ESMTP id 39C658D002E for ; Wed, 13 Jan 2021 11:21:49 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id C247D33C4 for ; Wed, 13 Jan 2021 16:21:47 +0000 (UTC) X-FDA: 77701267854.03.wood87_0005abd2751f Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin03.hostedemail.com (Postfix) with ESMTP id D54E728A4ED for ; Wed, 13 Jan 2021 16:21:46 +0000 (UTC) X-HE-Tag: wood87_0005abd2751f X-Filterd-Recvd-Size: 5840 Received: from mail-qv1-f73.google.com (mail-qv1-f73.google.com [209.85.219.73]) by imf14.hostedemail.com (Postfix) with ESMTP for ; Wed, 13 Jan 2021 16:21:46 +0000 (UTC) Received: by mail-qv1-f73.google.com with SMTP id l3so1824876qvr.10 for ; Wed, 13 Jan 2021 08:21:46 -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=TpRL7Y20jiGyVCcZ/tWCsLwlWMyTmyOwumaDR68J98Q=; b=kexc0GKfahtN6+eXQ4ruAoOLfXYOFprgQrXCkxvEJ4XGP0AubHPETXRT+1ZyX93aGJ Ci/Vkgbh7T2Tlu1CDvyHkTxWE4m71vOgvCVcMT7gXv3zVgEcMswloFJO0DVm/ADlZ+E4 4Nqm93YIYHS8WGPImuLEzT5IFzVyZt2ecgM+1TaSfdm6ZGnvi2ppo62W9EjIwgMFZCCH b5uv4pc1LYxe80V9rFyG0NduW3RAEyuyThHWXOHaQAj41HtadaBbp8yXOAHd68oIn8M9 1NLM5xmg+DDnBnt6cRiWr1sGKs7unsxHMJMMvKaT3yVzf6cUhVEEtqn+8arAyLIARqhk cLCA== 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=TpRL7Y20jiGyVCcZ/tWCsLwlWMyTmyOwumaDR68J98Q=; b=W3zwYX0x6QTd7cc2fncr3kH/rscP+VQALwhWADJIkI86v8PRJNd4hihu42PA1qz9r4 UvX1SENcGz79ncpuf0ZwhqvYzTZqp2bL98IcMwpQ2H0GrWfWcgW+sPcD2a4YyuIEICBG HvwgutEXplI8E5KShaxdYPN3BAWcjrLpkRmNozdSML2vjruFEzCIPl9Q51nclKsJKjU0 61NZ1EusRrCSVj5/9qn9G/REtIBa2w492V1UOowHG+RKGw4tEQNMyBf65t7mPyUaDQaF C4ytEY8dtFFvuL0xejxcO25tWlDyNbxhSfn9/iUXYRXog5wG4Qm71R2qfUKNcE4adgtk cx6g== X-Gm-Message-State: AOAM533nuat3aAoi+vipOnVxy/BtOcNo8zvpIH2nLzGO/9n6yFV5c5lR hhuSez1ZTdePQ/8Z+GfP6g339YtDpPUSy7W+ X-Google-Smtp-Source: ABdhPJxln7izs619Q1m6UWhaO6zc4ZsZXg5wmyVBo2nR12ArziZiYlCDdEdTU70Vf5xRC058gEIemBMfjVyu/LOK X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:7220:84ff:fe09:7e9d]) (user=andreyknvl job=sendgmr) by 2002:a0c:b99c:: with SMTP id v28mr1527191qvf.12.1610554905578; Wed, 13 Jan 2021 08:21:45 -0800 (PST) Date: Wed, 13 Jan 2021 17:21:27 +0100 Message-Id: Mime-Version: 1.0 X-Mailer: git-send-email 2.30.0.284.gd98b1dd5eaa7-goog Subject: [PATCH v2 00/14] kasan: HW_TAGS tests support and fixes From: Andrey Konovalov To: Catalin Marinas , Vincenzo Frascino , Dmitry Vyukov , Alexander Potapenko , Marco Elver Cc: Andrew Morton , 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 in v1->v2: - Fix return values of kasan_check_byte(). - Use KASAN_TEST_NEEDS_*() macros for checking configs required for tests. - Fix unused size in match_all_not_assigned(). - Fix typo in KASAN docs: "consist on" => "consist of". - Use READ/WRITE_ONCE() for accessing fail_data fields. - Doesn't leak memory in kmalloc_uaf2(). - Do up to 16 attempts in kmalloc_uaf2(). - Use kasan_report() for reporting from ksize() check. - Rename kasan_check() to kasan_byte_accessible(). - Add a test for kmem_cache_bulk_alloc(). - Checks that pointer tags are assigned from [KASAN_TAG_MIN, KASAN_TAG_KERNEL). - Don't run tests with kasan.mode=off. Andrey Konovalov (14): 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: 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 | 16 ++ lib/Kconfig.kasan | 6 +- lib/Makefile | 2 +- lib/test_kasan.c | 423 +++++++++++++++++++++-------- 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/slab_common.c | 15 +- tools/objtool/check.c | 2 +- 23 files changed, 544 insertions(+), 266 deletions(-)