Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp728507pxt; Thu, 12 Aug 2021 08:20:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywy+RSSq5Vz9myVDd1+G1GATsTcL4WJ0jz2hukUegQHobiJrrfniTAFOQg6ZRN9dymvcrU X-Received: by 2002:a05:6402:3481:: with SMTP id v1mr5920957edc.60.1628781601440; Thu, 12 Aug 2021 08:20:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628781601; cv=none; d=google.com; s=arc-20160816; b=UEzDloxkMbgHOAg5TUzKsNgS9uWMEG9wqLtn5d0PxmD/vTBDCY+64rT3582yAOfs+m 4fCAEMnxlK1Ac8e2DNnohETgbunDhkfELTbtDt3wg+u2iXfxFHXxIWrGP4QaUgvtZRNX 5nYrsmXZCHwxly4mu4PteCj/qG6HkxtdNzKjFs63//rHGRApy7+9lE9rAQGN5sKjVx8+ D60danaeCEFJ206dhfzFK2/96guOGFKywUQbiXGkt3EiJ7xAnoyIXL6+FCw2RPL/LUFY wb5LTwskZjhoDZi/g4OYS9fX+jONVX5Z4BjpQyMA3UPSCRGcH0gV97JBA5YqxiS0fEaq Jk4g== 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=3Rw7L29Rl9lI7li/pGD4SgpCx3KCWINRLEY+hWljSMg=; b=bfNuyCx/6KwXofG6G8PVQx1IkvgcSdvMQWRxzPlbzs9BkGzw3CCwfcIgZgIO9SVbVc axgdT8Mz94A9eeD3JuT3fQQ9Zm7Lg+MgouMnh+LUA4fbfYUZLPJJu8UQU3wdkBzHWzWs zNsb2CktDd4ZRIYve6w/LPrQCE9+cSNr3qYOxYqq9bwX4XmRG9VswjCMOFpWQ8ZYpna8 /chqtXLII2TUSeymdgqwUFieCeV1MzjaAGpdiqKmwdExr/Nl7Xp82VzoQthAknligCvM 22nEbbupSZcJKqyNf5+ck1sDPGTk8rBR2XEm+oWqnA0W9W4cQX91WehgTGyyChmp7Ljf 1bZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=omGleRtp; 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 va25si2672285ejb.481.2021.08.12.08.19.34; Thu, 12 Aug 2021 08:20:01 -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=omGleRtp; 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 S238242AbhHLOy2 (ORCPT + 99 others); Thu, 12 Aug 2021 10:54:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238191AbhHLOyT (ORCPT ); Thu, 12 Aug 2021 10:54:19 -0400 Received: from out2.migadu.com (out2.migadu.com [IPv6:2001:41d0:2:aacc::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC282C061756 for ; Thu, 12 Aug 2021 07:53:54 -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=1628780033; 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=3Rw7L29Rl9lI7li/pGD4SgpCx3KCWINRLEY+hWljSMg=; b=omGleRtpyvxWbz5TtreIGYBJe+5q5as7BlBu4evJOh1sVulPoLbAFzL/6newVraJs1nofK P/C642BePeDmIXJPxDx29g5o2htU5/nSLX+ZE89nQBswpUSC17RDlaSh54uUk2IJeXvVsx M5P/KRRzzcS3gE/inx1S0d6+vXXyvNA= 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 4/8] kasan: test: disable kmalloc_memmove_invalid_size for HW_TAGS Date: Thu, 12 Aug 2021 16:53:31 +0200 Message-Id: <088733a06ac21eba29aa85b6f769d2abd74f9638.1628779805.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 db73bc9e3fa2..1f533a7346d9 100644 --- a/lib/test_kasan.c +++ b/lib/test_kasan.c @@ -501,11 +501,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