Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp340067rbb; Sat, 24 Feb 2024 03:00:38 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX5SzC1Vz2iWl33x7qukbS3rceljlH/gD2lVnzWyjerp+U6cmqpnR1nO5dENFP1X0qup3s16g6fTE2hwKKNx02H517aod5oBWa0jHxRPg== X-Google-Smtp-Source: AGHT+IEng3aCiaihGjO9lEkBakxwODJ+pqxjQ/Bz2RGZ83bw2lBG7q37UQWnKX5NvOMjQz7lie+0 X-Received: by 2002:a05:6830:2a8d:b0:6e4:75cd:85ef with SMTP id s13-20020a0568302a8d00b006e475cd85efmr2434543otu.36.1708772437908; Sat, 24 Feb 2024 03:00:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708772437; cv=pass; d=google.com; s=arc-20160816; b=d0kUCAYeMaPaPvmmNv9Zcs8Oe2jXJ0b+/wUfj5Tg5WAtm3X6Pabz9zcbUaYsfApO0c t5P5YjWmM5AUJ7GLfEB3uIoCbFnpibf+399lw/eHYblkuPgFBJ/SHzgmbX+p3yhOEQEy w7v3+N1u78Xgnk1HUcPmo/VSUINCAgOuN+cv0DyTomxWY/uR//ohk1wNj0eKpA5pb3WA MEw6ipAEhxNRaYYmd+F3mJSGECt8Ucdd+ucZyyIru/KwnDvyUp+sjZDl7ZqQ3+IdHDlZ arALisuOVJiObncLLxvc2o6Ve3rpgFx3r7Tx8OHjAyPonPw4X8XfFa4uLdYgM91hRvTs 3nPA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=uRexiL1hDopWJGrXPsILxKWh+xq4dfVumK602P+IOzs=; fh=uV27StYz1PuPNiZbuPO3IZ+o+DZj4i861k70n+rSjJc=; b=GQ2RClWnDlLxXH0MJ6R3gW8daoBADaVFAkLROENz+jkmVWMhCFfqkV8F/tVvZ/on+7 ZRWI2t3BTu4L9oulezdqadWvdXbfrtXkfUyqj80PKVCg33C7XfzmC77LGlqEcxlc0HpR +tuP7Yf5xIwoFgGU/fCIWIKFDnZfeIZ6lQfKkOTQNBPZcho10CpR/2XXEJVraSVYm5Gn fZNafOzOAb93jh10F0wVNnkGzMPyeWy2I5XLoTVD0NompzZ3Pfg5tNgDnEXQIxEuFJGi XCkiIgkBo1LsVDTSLOs/IYNzTt+/oKzbFz6bGnuY/QDatT/ExjLgu2O2/dnXgLiEuIPF loNA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@tum.de header.s=tu-postout21 header.b="Scx8/Edg"; arc=pass (i=1 spf=pass spfdomain=tum.de dkim=pass dkdomain=tum.de dmarc=pass fromdomain=tum.de); spf=pass (google.com: domain of linux-kernel+bounces-79574-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79574-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tum.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id kq17-20020a056a004b1100b006e4cf39bc99si752528pfb.383.2024.02.24.03.00.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Feb 2024 03:00:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79574-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@tum.de header.s=tu-postout21 header.b="Scx8/Edg"; arc=pass (i=1 spf=pass spfdomain=tum.de dkim=pass dkdomain=tum.de dmarc=pass fromdomain=tum.de); spf=pass (google.com: domain of linux-kernel+bounces-79574-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79574-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tum.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 9190D283121 for ; Sat, 24 Feb 2024 11:00:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3531C210E8; Sat, 24 Feb 2024 11:00:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tum.de header.i=@tum.de header.b="Scx8/Edg" Received: from postout2.mail.lrz.de (postout2.mail.lrz.de [129.187.255.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 637B61B7E8 for ; Sat, 24 Feb 2024 11:00:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=129.187.255.138 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708772419; cv=none; b=ATKCjbMmjYNVYpCwgNJm9Kx+yWhUC9vvFUdk5vcz6M+FifLCldFCF4V3B1UL1kxVqVwKk/GNAjB1PDYx7jhMESuftJX/8dzYASdDwJYsuNNBf4sy8RTx2CMz2XYvvtHqMiqhP94b1DZtX6PYUxH91YPVd9m3/U9n79Noz2au9Qw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708772419; c=relaxed/simple; bh=TZfMEar/WGv3z6Vr+zFmVB2K7TNo7XIS9DBxR4kHKAM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=dd+q70NVEF4om+RldyV+m4SOrDILEhKCSKWmk0yXrB/RFNM384EQXnWh22rvcb+NKe0lJcMQBGgL8ikZv4modhVIUEx/ixhUr99bRugspq/2ihdlrSPpmLCc0cl3pjH3yM8kuA5+q4kJhmCjGtn1cPgfcjwqWzu82fiqglb6tEA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=tum.de; spf=pass smtp.mailfrom=tum.de; dkim=pass (2048-bit key) header.d=tum.de header.i=@tum.de header.b=Scx8/Edg; arc=none smtp.client-ip=129.187.255.138 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=tum.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=tum.de Received: from lxmhs52.srv.lrz.de (localhost [127.0.0.1]) by postout2.mail.lrz.de (Postfix) with ESMTP id 4ThkK95Rs3zyZG; Sat, 24 Feb 2024 11:54:21 +0100 (CET) Authentication-Results: postout.lrz.de (amavisd-new); dkim=pass (2048-bit key) reason="pass (just generated, assumed good)" header.d=tum.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tum.de; h= content-transfer-encoding:content-type:content-type:mime-version :references:in-reply-to:x-mailer:message-id:date:date:subject :subject:from:from:received:received; s=tu-postout21; t= 1708772061; bh=TZfMEar/WGv3z6Vr+zFmVB2K7TNo7XIS9DBxR4kHKAM=; b=S cx8/Edgu2nmGsS4l7bzFuVLeZygh4C5RVN7X0385BXX0YcaMDMGFBRcwcBofkFcK abzN375IT+cn+QMTgM4E6YKnis9fnZgmPZtc3Rt+D2SQVjfr4S0hiC6gX9gY4eYs Aps6ZlPnGCv8pfJuMW8G221NmA8cG8q9FVp2jtU9GwvdxYDKw7pZcPe3fwOvdge3 i+zfPPMjaDsC4B7Jxaxy7dhFINOXAAZme3xwEXUtdboZBPI5GIaPiiqD1+lofJSE 1PXWbcwvLOunAb+QWe+DkQUOiZjcQBxJK9d1HsvpEwxbFPBjrm++tCLtSeKSVk2r +pofugRBOoMfjFbyVQDmg== X-Virus-Scanned: by amavisd-new at lrz.de in lxmhs52.srv.lrz.de X-Spam-Flag: NO X-Spam-Score: -0.382 X-Spam-Level: Received: from postout2.mail.lrz.de ([127.0.0.1]) by lxmhs52.srv.lrz.de (lxmhs52.srv.lrz.de [127.0.0.1]) (amavisd-new, port 20024) with LMTP id t3smiUimcLMl; Sat, 24 Feb 2024 11:54:21 +0100 (CET) Received: from sienna.fritz.box (ppp-93-104-78-110.dynamic.mnet-online.de [93.104.78.110]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by postout2.mail.lrz.de (Postfix) with ESMTPSA id 4ThkK821SYzyZF; Sat, 24 Feb 2024 11:54:20 +0100 (CET) From: =?UTF-8?q?Paul=20Heidekr=C3=BCger?= To: akpm@linux-foundation.org Cc: andreyknvl@gmail.com, dvyukov@google.com, elver@google.com, glider@google.com, kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, mark.rutland@arm.com, paul.heidekrueger@tum.de, ryabinin.a.a@gmail.com, vincenzo.frascino@arm.com Subject: [PATCH] kasan: fix a2 allocation and remove explicit cast in atomic tests Date: Sat, 24 Feb 2024 10:54:14 +0000 Message-Id: <20240224105414.211995-1-paul.heidekrueger@tum.de> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240223161020.9b4184e1e74b35f906e0ec78@linux-foundation.org> References: <20240223161020.9b4184e1e74b35f906e0ec78@linux-foundation.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Address the additional feedback since "kasan: add atomic tests" (4e76c8cc3378a20923965e3345f40f6b8ae0bdba) by removing an explicit cast and fixing the size as well as the check of the allocation of `a2`. CC: Marco Elver CC: Andrey Konovalov Link: https://lore.kernel.org/all/20240131210041.686657-1-paul.heidekrueger@tum.de/T/#u Fixes: 4e76c8cc3378a20923965e3345f40f6b8ae0bdba Closes: https://bugzilla.kernel.org/show_bug.cgi?id=214055 Reviewed-by: Marco Elver Tested-by: Marco Elver Acked-by: Mark Rutland Reviewed-by: Andrey Konovalov Signed-off-by: Paul Heidekrüger --- @Andrew: I wasn't sure whether you'd be squashing this patch into v1 or if it'll end up as a separate commit. Hope this works either way! Changes PATCH v2 -> PATCH v3: * Fix the wrong variable being used when checking a2 after allocation * Add Andrey's reviewed-by tag Changes PATCH v1 -> PATCH v2: * Make explicit cast implicit as per Mark's feedback * Increase the size of the "a2" allocation as per Andrey's feedback * Add tags Changes PATCH RFC v2 -> PATCH v1: * Remove casts to void* * Remove i_safe variable * Add atomic_long_* test cases * Carry over comment from kasan_bitops_tags() Changes PATCH RFC v1 -> PATCH RFC v2: * Adjust size of allocations to make kasan_atomics() work with all KASan modes * Remove comments and move tests closer to the bitops tests * For functions taking two addresses as an input, test each address in a separate function call. * Rename variables for clarity * Add tests for READ_ONCE(), WRITE_ONCE(), smp_load_acquire() and smp_store_release() mm/kasan/kasan_test.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/kasan/kasan_test.c b/mm/kasan/kasan_test.c index 4ef2280c322c..7f0f87a2c3c4 100644 --- a/mm/kasan/kasan_test.c +++ b/mm/kasan/kasan_test.c @@ -1152,7 +1152,7 @@ static void kasan_bitops_tags(struct kunit *test) static void kasan_atomics_helper(struct kunit *test, void *unsafe, void *safe) { - int *i_unsafe = (int *)unsafe; + int *i_unsafe = unsafe; KUNIT_EXPECT_KASAN_FAIL(test, READ_ONCE(*i_unsafe)); KUNIT_EXPECT_KASAN_FAIL(test, WRITE_ONCE(*i_unsafe, 42)); @@ -1218,8 +1218,8 @@ static void kasan_atomics(struct kunit *test) */ a1 = kzalloc(48, GFP_KERNEL); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, a1); - a2 = kzalloc(sizeof(int), GFP_KERNEL); - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, a1); + a2 = kzalloc(sizeof(atomic_long_t), GFP_KERNEL); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, a2); /* Use atomics to access the redzone. */ kasan_atomics_helper(test, a1 + 48, a2); -- 2.40.1