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: 12017305 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 B5611C433E0 for ; Wed, 13 Jan 2021 16:25:31 +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 F1EAF23370 for ; Wed, 13 Jan 2021 16:25:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F1EAF23370 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=AbvhcM0YoFMeZRlbRLatEXXWigV6WfV6QaCOcVvGxwI=; b=SlFw5bBq6FDokT08S2oJMjvc+M 80a4zIM8TgOI1p0uuiLrF7OcFjuixeLFBCda5nqoTE64MrTSBocN0rvPXxECVEvaaEielzb4l+9Bi nQFGXTVAOB8Uad2lzx1hgK0gHAjm94b0vnElWGE3COvDYb1Au8deg3pDsB3akAan9c6/InJjRZaOd 2erEUHXCVgV2gPrOuD2km8wXgNErg60ccyDfU+2PKlBIB0yIfGBjHawDXglPWH8xYKZIOpoyqtCi1 g7zUDiDYcGv/BzAsVae5PHgAHVUGLoIr4EhaKEPaVDvgdL0xtzT2DsvXRMpWK/i3X98oA4z2zrl88 LYsj41KQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kziu7-00079o-LB; Wed, 13 Jan 2021 16:21:51 +0000 Received: from mail-qv1-xf4a.google.com ([2607:f8b0:4864:20::f4a]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kziu4-00078a-SI for linux-arm-kernel@lists.infradead.org; Wed, 13 Jan 2021 16:21:49 +0000 Received: by mail-qv1-xf4a.google.com with SMTP id bp20so1810342qvb.20 for ; Wed, 13 Jan 2021 08:21:47 -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=q5WDNLebHDj7JduZXWWFcDdMHD/HBxHSONSgWCYPNDYVi91IUkSNisVftJqH6x3Qip sdg3vz3jVN7Lanx/tUHq8VX8Hph+dCVbIF5TfhRKzudsUnZtRQFNja3tIoR2/e0b006n tMUlKl+u30OXNRz4rM4+uE4RkTgXUMSL2IzElHl6gXzmApxgayYnIqIl/40YBrkOcuhs FYir6LQHfXUAOHRGSEqa3PoCPbtr9NdOsAENhk1V/inzmSyCE90p1iBuRDb2stOVRgEs RPBSrklNHchv3R78LPQt+lqBD27ei8nQdt83uRV4I8xmxuwMaJvCuyiJFYQ3Zki+goZ9 iDzA== X-Gm-Message-State: AOAM530ts5sSPyDlTCKKckVsNRgusqWZstgRZ4PuXHdZFBX4c7MEzu6F JLG7Qi6Z4ek8RrfjScU+ill3o914SotsLfZe 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210113_112148_955773_7B5196EF X-CRM114-Status: GOOD ( 14.97 ) 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 , Andrew Morton , 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 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(-)