Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp4718277pxt; Wed, 11 Aug 2021 12:24:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLWr9AMMEJxBPk3uffGBFrN1nyRUNO1jIpa8ncVTFVcP67DdYK9zCzFBoPFz7gqhxXd7HE X-Received: by 2002:a92:c503:: with SMTP id r3mr36595ilg.148.1628709880673; Wed, 11 Aug 2021 12:24:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628709880; cv=none; d=google.com; s=arc-20160816; b=jQcvAc8hQGrn3Kk5A9YwpXfWfs/ydriL/lHTvo7JLqEVdYErkaq7cC0UULs0LTjTFJ LVR6HoYt8JM1gl6/aG0K5bv2Ma3+SlumGAUbxsTct5M0dhQw7IefRCPgn0ZmQ+/D+WDp s3ehmi41crekeVGWi1R/9FKTimuJrYTcr8jmOuHfbVoWGoe7RYgh4iyGUIOdY7vylMsx 13U0qOL109feaAl2SckrzCPtuivNPADr7L1lDh4YbYeAF3INwtS5jZCkTy+xq9f/+xFZ AWUuW4GE4zIXs3ryno0dRyvuMa5Y672DKt0ae6UU5NCm3HItZ66OFG8Da4Xey/+kUNId drng== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mDv6lThH9LBlRq+G7bShNnjHZy0fm6nN/s0ZaRwS7lU=; b=rLG0kYdvbSdMZJHnobJHocM0CjLmgb2egkuZnT1tCpaqjf7j8wbPDMxR65HlStzCvF lYRSu5La25wokSBn3/wKpdVRwPaPKj51IUt8haytfoJd5ovWek9Vid8C6V0sdqAvFWl7 dTGLxGsogJjLM6zH2zXRfSJRIVxF2KG8ZXUff4oj7w+Hx74NLcL8yPvjuQ4vFVfySSH7 fMOU3JBoMDyMDV1idhPd3z3MnebW9eQLqt6HtWZfPWeC0k5WwBodDVrfsaCEjDIGIoB7 8Wdm0+f7SfIrKeWtUirKTYb8wCwYM41zUPSBS133BHuSci1omSjfh9ZTCUZ3rAfzpVhs I7wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=IYrielYM; 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 m2si345513ili.39.2021.08.11.12.24.29; Wed, 11 Aug 2021 12:24:40 -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=IYrielYM; 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 S231630AbhHKTWN (ORCPT + 99 others); Wed, 11 Aug 2021 15:22:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231477AbhHKTWI (ORCPT ); Wed, 11 Aug 2021 15:22:08 -0400 Received: from out1.migadu.com (out1.migadu.com [IPv6:2001:41d0:2:863f::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87508C061765 for ; Wed, 11 Aug 2021 12:21:44 -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=1628709703; 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: in-reply-to:in-reply-to:references:references; bh=mDv6lThH9LBlRq+G7bShNnjHZy0fm6nN/s0ZaRwS7lU=; b=IYrielYM/cUXC5oix+bER2LtE+OBDs1gEC5/QYijlKAzZ0X4Lmk3v9FjK7DbPrbsO82zwM jQYf6nr9h3nad13J67sseFkvGTaBhF+Pq0tO29XU9zX0FrmcMO/H9W+nMMOhcMx6NlMKlP hJbCMrFpLJu8yl9c/h8pIPNa9KLWgno= 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 4/8] kasan: test: disable kmalloc_memmove_invalid_size for HW_TAGS Date: Wed, 11 Aug 2021 21:21:20 +0200 Message-Id: <408c63e4a0353633a13403aab4ff25a505e03d93.1628709663.git.andreyknvl@gmail.com> In-Reply-To: References: 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 The HW_TAGS mode doesn't check memmove for negative size. As a result, the kmalloc_memmove_invalid_size test corrupts memory, which can result in a crash. Disable this test with HW_TAGS KASAN. Signed-off-by: Andrey Konovalov --- lib/test_kasan.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/test_kasan.c b/lib/test_kasan.c index fd00cd35e82c..0b5698cd7d1d 100644 --- a/lib/test_kasan.c +++ b/lib/test_kasan.c @@ -495,11 +495,17 @@ static void kmalloc_memmove_invalid_size(struct kunit *test) size_t size = 64; volatile size_t invalid_size = -2; + /* + * Hardware tag-based mode doesn't check memmove for negative size. + * As a result, this test introduces a side-effect memory corruption, + * which can result in a crash. + */ + KASAN_TEST_NEEDS_CONFIG_OFF(test, CONFIG_KASAN_HW_TAGS); + ptr = kmalloc(size, GFP_KERNEL); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); memset((char *)ptr, 0, 64); - KUNIT_EXPECT_KASAN_FAIL(test, memmove((char *)ptr, (char *)ptr + 4, invalid_size)); kfree(ptr); -- 2.25.1