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: 12020719 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 D1827C433E6 for ; Thu, 14 Jan 2021 19:38:28 +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 8D37D23A52 for ; Thu, 14 Jan 2021 19:38:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8D37D23A52 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=sJ3gyH4Cbo4/YSc7U3UYA20md/7x6zE8X4I+lCpotT8=; b=yYrWNfkhob3kZeX/YWkRVrciuq Y3i6S4An6Vr2wJeY6+4z1pVlxMJqPYJdx2EGmWIuIqwHuRWiaqwgIS9nqSU4i0JOmPkoHPzzS1lAN 3TUoSTeM369PxJMX/1GZq2W3ND8B4z/BkVJi2vWWtimd6HkIpwRNWyUJZTZId+vagjMSuBWeT/5Rc Jgkm9Ux0bQdN0S3DoetpxMOH61+hRdz2Gebx8GXYc3x+TNmS5EjHRnzWPOQnB/zhzueyp8g6B6qEf k6o77LyuBrhRwenBBGr3N9YXo/GCA0LiYK+ldRdEIt2K/N8oVwyz5I7ghrUvWaPe37Fgf3lyZXdlQ zxs3Zubw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l08QG-0004AY-KL; Thu, 14 Jan 2021 19:36:44 +0000 Received: from mail-qv1-xf49.google.com ([2607:f8b0:4864:20::f49]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l08QB-000481-Oq for linux-arm-kernel@lists.infradead.org; Thu, 14 Jan 2021 19:36:40 +0000 Received: by mail-qv1-xf49.google.com with SMTP id h1so5453972qvr.7 for ; Thu, 14 Jan 2021 11:36:37 -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=OqyWDlGP7x0hC8Mw5JfbXfsMPHF6tmz6+Sh0Tjj1KPCIo7+VzTLchpkYCoy7cqAhBb yLchJJZvf43as87hKlxDvmNTWqaXK/Jy3k2OxBU5I/GftLzVMT9/1/GwHXR0E4muFcwX Moe3X8C0wY39aj2eDrePXpjE1AaYomkyDl57YujyCuhhYyA1bTNxTjWQ6eLi4fLHRfNt NzSYMIOGPwAmJb0K3+bsPEz1pR7p36rnTkZg2GL+4cyM/yBFf4tARys9vvg/x6rpdqku lM0fPqhjbElj63r5byvxYjeORhXPCML1OJ3dzCWLlhd+tsiD6grTGfX2ODJLQluqvEUm UwBg== X-Gm-Message-State: AOAM5308hoNaBn8t0nL6A1OOOCfRv/f/Q+r4ASCIKfSw0zNU3kQSzm9J QjTr4qgjitigynXt+0/NOwClrR4UF2eZM36E 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210114_143639_853774_CD0ED502 X-CRM114-Status: GOOD ( 13.43 ) 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 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(-)