From patchwork Thu Aug 12 14:53:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: andrey.konovalov@linux.dev X-Patchwork-Id: 12433731 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=-8.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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 4882FC432BE for ; Thu, 12 Aug 2021 14:53:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BC09D6103A for ; Thu, 12 Aug 2021 14:53:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BC09D6103A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.dev Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 0F45B8D0003; Thu, 12 Aug 2021 10:53:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E4DD38D0009; Thu, 12 Aug 2021 10:53:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C51F48D0001; Thu, 12 Aug 2021 10:53:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0224.hostedemail.com [216.40.44.224]) by kanga.kvack.org (Postfix) with ESMTP id 8839C8D0003 for ; Thu, 12 Aug 2021 10:53:54 -0400 (EDT) Received: from smtpin35.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 1072223E41 for ; Thu, 12 Aug 2021 14:53:54 +0000 (UTC) X-FDA: 78466723188.35.8FE6716 Received: from out2.migadu.com (out2.migadu.com [188.165.223.204]) by imf01.hostedemail.com (Postfix) with ESMTP id 6B352504359A for ; Thu, 12 Aug 2021 14:53:53 +0000 (UTC) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1628780031; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=y4INfxuNvGKmJ7fA8mFpegB4/XD7G/W0BELDU6wu598=; b=olo/lvSAvBkGdMgJajSr08q+Aq3l7q9njOKWjWFce2KNAfP7eaZ31El3QqgK3k8fvjPGh1 IKEl7ot+Re6s9j8P9hPd34yzy0QNWjkpm0Nl5lc7Y0CUDvi947qU3b5nIOtTJW86Zc6ezu f+stVRrmpOwC7pm6T3tDAY3HU9RDyg0= From: andrey.konovalov@linux.dev To: Andrew Morton Cc: Andrey Konovalov , Andrey Ryabinin , Marco Elver , Dmitry Vyukov , Alexander Potapenko , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 0/8] kasan: test: avoid crashing the kernel with HW_TAGS Date: Thu, 12 Aug 2021 16:53:27 +0200 Message-Id: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: andrey.konovalov@linux.dev Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="olo/lvSA"; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf01.hostedemail.com: domain of andrey.konovalov@linux.dev designates 188.165.223.204 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev X-Stat-Signature: fcdiywytn7878agdxnkia5nf4q435w7a X-Rspamd-Queue-Id: 6B352504359A X-Rspamd-Server: rspam05 X-HE-Tag: 1628780033-878758 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: From: Andrey Konovalov KASAN tests do out-of-bounds and use-after-free accesses. Running the tests works fine for the GENERIC mode, as it uses qurantine and redzones. But the HW_TAGS mode uses neither, and running the tests might crash the kernel. Rework the tests to avoid corrupting kernel memory. Changes v1->v2: - Touch both good and bad memory in memset tests as suggested by Marco. Andrey Konovalov (8): kasan: test: rework kmalloc_oob_right kasan: test: avoid writing invalid memory kasan: test: avoid corrupting memory via memset kasan: test: disable kmalloc_memmove_invalid_size for HW_TAGS kasan: test: only do kmalloc_uaf_memset for generic mode kasan: test: clean up ksize_uaf kasan: test: avoid corrupting memory in copy_user_test kasan: test: avoid corrupting memory in kasan_rcu_uaf lib/test_kasan.c | 80 +++++++++++++++++++++++++++++------------ lib/test_kasan_module.c | 20 +++++------ 2 files changed, 66 insertions(+), 34 deletions(-) Reviewed-by: Marco Elver