Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp728320pxt; Thu, 12 Aug 2021 08:19:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqZlxCY3QpRMBbmtoJLaJ0hLceoNBnim2uLPg1UFDHglNGGD6aNc/QVTeB2oFsVcu4CMHE X-Received: by 2002:a17:906:6b1b:: with SMTP id q27mr4122711ejr.169.1628781583203; Thu, 12 Aug 2021 08:19:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628781583; cv=none; d=google.com; s=arc-20160816; b=mZbwEHvdPhNbcd0emAmZchd36L5ddLxcOLHlN7mIQDHoC7WvkMPpBmaJg0s9n1v+yk 8LIkewCNm69vXrHejACzEGQen/miOtUANGzy9A5jVeiVs4XPxLr83C2VAB3KEOF8i2tN HjnGXhO9TfpX8PRZM7JIEVEX0mO6ueSkZv2GLVsKO4Th8HKzGtH18IY3x4d3JymBrhPK fNFClZphvTXDZ4JF5BSGxxRKtYPPuM9s0W/bzXZGX0B77mDdVg5GLAapPtg/lpb0BzGu mCXzBGrgzkaViITcHU9Xz2sDokzaEUgU/GFnV0kvaSrF5mkUwUKfoFVcZ/NBtJe8PCQ8 Oscw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=y4INfxuNvGKmJ7fA8mFpegB4/XD7G/W0BELDU6wu598=; b=x5tQhus4379OWOqtUZMTWxOpJsgosgS4PpiYi0uqEH1HXQW6TI6mslx4WhTc1Bh9t6 mS96O0wK2vf2r7Br70qLynyT1ecy7ttln9Tlg15C8g2pWl/DVCHFQOwQIe6R3Y5mKicB QTwfqKN04+5KMp201KY2hqXziEYBmQqOn4xGHt7b93KGshN2ZKjuCXjF7pHptqMcJi0l kM9AFauRUZ0BFN0WumcxVcdIy4oxbynqzT/0obDmRtAI/GPiB+KtaKIhY806QQ3Y3exa csL59myDZjBMpP3tTrBJmpR6RcQc6TE3zZXsp0iHnz/29c79ud5/vp1att/P9GAZ1C2s hqRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="olo/lvSA"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m13si2751422edv.524.2021.08.12.08.19.19; Thu, 12 Aug 2021 08:19:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="olo/lvSA"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238196AbhHLOyV (ORCPT + 99 others); Thu, 12 Aug 2021 10:54:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236470AbhHLOyS (ORCPT ); Thu, 12 Aug 2021 10:54:18 -0400 Received: from out2.migadu.com (out2.migadu.com [IPv6:2001:41d0:2:aacc::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F877C061756 for ; Thu, 12 Aug 2021 07:53:53 -0700 (PDT) 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 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: andrey.konovalov@linux.dev Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.25.1