From patchwork Wed Aug 11 19:21:16 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: 12431823 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 7695CC4338F for ; Wed, 11 Aug 2021 19:21:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F294760F21 for ; Wed, 11 Aug 2021 19:21:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org F294760F21 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 878236B0075; Wed, 11 Aug 2021 15:21:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 801A56B0072; Wed, 11 Aug 2021 15:21:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 67BB96B007B; Wed, 11 Aug 2021 15:21:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0038.hostedemail.com [216.40.44.38]) by kanga.kvack.org (Postfix) with ESMTP id 2BA016B0072 for ; Wed, 11 Aug 2021 15:21:44 -0400 (EDT) Received: from smtpin40.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id C468C253A2 for ; Wed, 11 Aug 2021 19:21:43 +0000 (UTC) X-FDA: 78463769286.40.ACA7AB4 Received: from out1.migadu.com (out1.migadu.com [91.121.223.63]) by imf09.hostedemail.com (Postfix) with ESMTP id 0AD983005BF6 for ; Wed, 11 Aug 2021 19:21:42 +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=1628709700; 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=lNfCPiEqsvC4j0wratT12NabqkYWU1ro94i4c/TmnC4=; b=XglRGggb+pI2XH3q6+ggFWTuR0jX4ckwAYAUmIfagJThGhgC/7QZX1hfKuOAGhq6xNszaO Z67Nz1sJ248zvpOiPIOsu0g5JNGjEClO3VneWk3KubQNT25rewG5JB2/7EFTDyzniZnNLi huZJrCjAYG/pFvA/50a16+4PbqfGX/o= 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 0/8] kasan: test: avoid crashing the kernel with HW_TAGS Date: Wed, 11 Aug 2021 21:21:16 +0200 Message-Id: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: andrey.konovalov@linux.dev Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=XglRGggb; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf09.hostedemail.com: domain of andrey.konovalov@linux.dev designates 91.121.223.63 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev X-Stat-Signature: 9mf59djsni4sajo3fzmtbmdf13ukutg4 X-Rspamd-Queue-Id: 0AD983005BF6 X-Rspamd-Server: rspam05 X-HE-Tag: 1628709702-607295 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. 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 | 74 ++++++++++++++++++++++++++++------------- lib/test_kasan_module.c | 20 +++++------ 2 files changed, 60 insertions(+), 34 deletions(-)