Message ID | 20231212232659.18839-1-npache@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp8064759vqy; Tue, 12 Dec 2023 15:27:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IF4+hD8mJlY4OFWjAiPbj/5pXJrY07hEG7bWcJnh+m75VBSadNC9HWB41vss/KdCIYAdtzt X-Received: by 2002:a17:903:2283:b0:1d0:45c6:1cc1 with SMTP id b3-20020a170903228300b001d045c61cc1mr8289194plh.27.1702423640842; Tue, 12 Dec 2023 15:27:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702423640; cv=none; d=google.com; s=arc-20160816; b=knJltxxSSTUA3rycMaac1hcn7dwDvC8YFB+C5SL4RmK8dgZqtddxniOnFKiFy735P/ pRdHRBa6e4RMKo5viYo8NZOpb3VBYQT4Tkqyjvi19ODvAYZsmiBD9ZXUHErV/zxfvJos odZzaVROJsfy2eTLI7/TLsmbmdOi6v1HHhTovl/zSdwELhU0lXLvSpUsBrCyuv771Gzq Kd6DnQCsWUuV7V0snBxKr/gR8D7wsGwvtNBGbBEJli6O9hqmW72/0ZLKxcKkApYzAT56 s3as79N0RyDEpe/99dU0TBPjQ/hU3h/wefJfgZLL7k/pVnVbJQhpWt+5pVAnkXVnsv/s xh5w== 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=ZwFQ3GQCbPFAax8NUohZK89OPMuLW9MEl5mvS51Lzts=; fh=t4pyiPcCBIC9Y+5xkCTP+ifpPVuOKc4r2DwOkdw1hDY=; b=Bn0OaF/2Eo36mIAeY501mrm7INhMYn+b3cOdXcH6Qqeld7+ocGdi/tmXCvLULbBdq3 ZVek3LLBzKKxOL2t2esxA6EzkFhgqvQv13Rjg5Qa0OkuRPzs08douq1G+irLLaCxBETE +/UD4NDqLiENJLjElqL8l2kh3qFVdkw1oJqjAaYs2+j3Caj4tXYytIXQZ2DM2DqIGdfD 1nKhn3KM8zlrGR4XimTc8ctdZrvDHoA327F5YnQtX4zRqg/uLnsRSdGbx2c8TBLg4lJH Pg7Ye9b6XvvtbM3d7R7Ylctde3Ej+bwFU+LLdXgIB0oWIr4j/3SaIlphJ7m/vAEfgeS4 ppzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Qb6rEPep; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id 19-20020a170902c21300b001cfa6128913si8354829pll.115.2023.12.12.15.27.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 15:27:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Qb6rEPep; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 30D9B80DAC44; Tue, 12 Dec 2023 15:27:13 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232376AbjLLX1D (ORCPT <rfc822;dexuan.linux@gmail.com> + 99 others); Tue, 12 Dec 2023 18:27:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232301AbjLLX1B (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 12 Dec 2023 18:27:01 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54E92F2 for <linux-kernel@vger.kernel.org>; Tue, 12 Dec 2023 15:27:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702423624; 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=ZwFQ3GQCbPFAax8NUohZK89OPMuLW9MEl5mvS51Lzts=; b=Qb6rEPepNg/r1A/4ycL+MxCwfAeoRRx9JRESXZNnMHwx51B0+PdWmNQ1gs11C6mIFP/YGl 6OaZ3/ufSM9dfytM3RZLMTH6JCADT5ye200VAi0CO0gnL5HTa5zF4pDoDh31uN4xNCUmVE aJYaLugb7REp/xMQ9Z/JoT9Z/r82mBQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-45-6YG-K_zxMJKQP8zTqBW2aQ-1; Tue, 12 Dec 2023 18:27:03 -0500 X-MC-Unique: 6YG-K_zxMJKQP8zTqBW2aQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4552A80BEC1; Tue, 12 Dec 2023 23:27:02 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.22.34.149]) by smtp.corp.redhat.com (Postfix) with ESMTP id 800551121306; Tue, 12 Dec 2023 23:27:01 +0000 (UTC) From: Nico Pache <npache@redhat.com> To: linux-kernel@vger.kernel.org, linux-mm@kvack.org, kasan-dev@googlegroups.com Cc: akpm@linux-foundation.org, vincenzo.frascino@arm.com, dvyukov@google.com, andreyknvl@gmail.com, glider@google.com, ryabinin.a.a@gmail.com Subject: [PATCH] kunit: kasan_test: disable fortify string checker on kmalloc_oob_memset Date: Tue, 12 Dec 2023 16:26:59 -0700 Message-ID: <20231212232659.18839-1-npache@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 12 Dec 2023 15:27:13 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785120571641274806 X-GMAIL-MSGID: 1785120571641274806 |
Series |
kunit: kasan_test: disable fortify string checker on kmalloc_oob_memset
|
|
Commit Message
Nico Pache
Dec. 12, 2023, 11:26 p.m. UTC
similar to commit 09c6304e38e4 ("kasan: test: fix compatibility with
FORTIFY_SOURCE") the kernel is panicing in kmalloc_oob_memset_*.
This is due to the `ptr` not being hidden from the optimizer which would
disable the runtime fortify string checker.
kernel BUG at lib/string_helpers.c:1048!
Call Trace:
[<00000000272502e2>] fortify_panic+0x2a/0x30
([<00000000272502de>] fortify_panic+0x26/0x30)
[<001bffff817045c4>] kmalloc_oob_memset_2+0x22c/0x230 [kasan_test]
Hide the `ptr` variable from the optimizer to fix the kernel panic.
Also define a size2 variable and hide that as well. This cleans up
the code and follows the same convention as other tests.
Signed-off-by: Nico Pache <npache@redhat.com>
---
mm/kasan/kasan_test.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
Comments
On Wed, Dec 13, 2023 at 12:27 AM Nico Pache <npache@redhat.com> wrote: > > similar to commit 09c6304e38e4 ("kasan: test: fix compatibility with > FORTIFY_SOURCE") the kernel is panicing in kmalloc_oob_memset_*. > > This is due to the `ptr` not being hidden from the optimizer which would > disable the runtime fortify string checker. > > kernel BUG at lib/string_helpers.c:1048! > Call Trace: > [<00000000272502e2>] fortify_panic+0x2a/0x30 > ([<00000000272502de>] fortify_panic+0x26/0x30) > [<001bffff817045c4>] kmalloc_oob_memset_2+0x22c/0x230 [kasan_test] > > Hide the `ptr` variable from the optimizer to fix the kernel panic. > Also define a size2 variable and hide that as well. This cleans up > the code and follows the same convention as other tests. > > Signed-off-by: Nico Pache <npache@redhat.com> > --- > mm/kasan/kasan_test.c | 20 ++++++++++++++++---- > 1 file changed, 16 insertions(+), 4 deletions(-) > > diff --git a/mm/kasan/kasan_test.c b/mm/kasan/kasan_test.c > index 8281eb42464b..5aeba810ba70 100644 > --- a/mm/kasan/kasan_test.c > +++ b/mm/kasan/kasan_test.c > @@ -493,14 +493,17 @@ static void kmalloc_oob_memset_2(struct kunit *test) > { > char *ptr; > size_t size = 128 - KASAN_GRANULE_SIZE; > + size_t size2 = 2; Let's name this variable access_size or memset_size. Here and in the other changed tests. > KASAN_TEST_NEEDS_CHECKED_MEMINTRINSICS(test); > > ptr = kmalloc(size, GFP_KERNEL); > KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); > > + OPTIMIZER_HIDE_VAR(ptr); > OPTIMIZER_HIDE_VAR(size); > - KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 1, 0, 2)); > + OPTIMIZER_HIDE_VAR(size2); > + KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 1, 0, size2)); > kfree(ptr); > } > > @@ -508,14 +511,17 @@ static void kmalloc_oob_memset_4(struct kunit *test) > { > char *ptr; > size_t size = 128 - KASAN_GRANULE_SIZE; > + size_t size2 = 4; > > KASAN_TEST_NEEDS_CHECKED_MEMINTRINSICS(test); > > ptr = kmalloc(size, GFP_KERNEL); > KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); > > + OPTIMIZER_HIDE_VAR(ptr); > OPTIMIZER_HIDE_VAR(size); > - KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 3, 0, 4)); > + OPTIMIZER_HIDE_VAR(size2); > + KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 3, 0, size2)); > kfree(ptr); > } > > @@ -523,14 +529,17 @@ static void kmalloc_oob_memset_8(struct kunit *test) > { > char *ptr; > size_t size = 128 - KASAN_GRANULE_SIZE; > + size_t size2 = 8; > > KASAN_TEST_NEEDS_CHECKED_MEMINTRINSICS(test); > > ptr = kmalloc(size, GFP_KERNEL); > KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); > > + OPTIMIZER_HIDE_VAR(ptr); > OPTIMIZER_HIDE_VAR(size); > - KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 7, 0, 8)); > + OPTIMIZER_HIDE_VAR(size2); > + KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 7, 0, size2)); > kfree(ptr); > } > > @@ -538,14 +547,17 @@ static void kmalloc_oob_memset_16(struct kunit *test) > { > char *ptr; > size_t size = 128 - KASAN_GRANULE_SIZE; > + size_t size2 = 16; > > KASAN_TEST_NEEDS_CHECKED_MEMINTRINSICS(test); > > ptr = kmalloc(size, GFP_KERNEL); > KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); > > + OPTIMIZER_HIDE_VAR(ptr); > OPTIMIZER_HIDE_VAR(size); > - KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 15, 0, 16)); > + OPTIMIZER_HIDE_VAR(size2); > + KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 15, 0, size2)); > kfree(ptr); > } > > -- > 2.43.0 > With the fix mentioned above addressed: Reviewed-by: Andrey Konovalov <andreyknvl@gmail.com>
On Wed, Dec 13, 2023 at 7:34 AM Andrey Konovalov <andreyknvl@gmail.com> wrote: > > On Wed, Dec 13, 2023 at 12:27 AM Nico Pache <npache@redhat.com> wrote: > > > > similar to commit 09c6304e38e4 ("kasan: test: fix compatibility with > > FORTIFY_SOURCE") the kernel is panicing in kmalloc_oob_memset_*. > > > > This is due to the `ptr` not being hidden from the optimizer which would > > disable the runtime fortify string checker. > > > > kernel BUG at lib/string_helpers.c:1048! > > Call Trace: > > [<00000000272502e2>] fortify_panic+0x2a/0x30 > > ([<00000000272502de>] fortify_panic+0x26/0x30) > > [<001bffff817045c4>] kmalloc_oob_memset_2+0x22c/0x230 [kasan_test] > > > > Hide the `ptr` variable from the optimizer to fix the kernel panic. > > Also define a size2 variable and hide that as well. This cleans up > > the code and follows the same convention as other tests. > > > > Signed-off-by: Nico Pache <npache@redhat.com> > > --- > > mm/kasan/kasan_test.c | 20 ++++++++++++++++---- > > 1 file changed, 16 insertions(+), 4 deletions(-) > > > > diff --git a/mm/kasan/kasan_test.c b/mm/kasan/kasan_test.c > > index 8281eb42464b..5aeba810ba70 100644 > > --- a/mm/kasan/kasan_test.c > > +++ b/mm/kasan/kasan_test.c > > @@ -493,14 +493,17 @@ static void kmalloc_oob_memset_2(struct kunit *test) > > { > > char *ptr; > > size_t size = 128 - KASAN_GRANULE_SIZE; > > + size_t size2 = 2; > > Let's name this variable access_size or memset_size. Here and in the > other changed tests. Hi Andrey, I agree that is a better variable name, but I chose size2 because other kasan tests follow the same pattern. Please let me know if you still want me to update it given that info and I'll send a V2. Cheers, -- Nico > > > KASAN_TEST_NEEDS_CHECKED_MEMINTRINSICS(test); > > > > ptr = kmalloc(size, GFP_KERNEL); > > KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); > > > > + OPTIMIZER_HIDE_VAR(ptr); > > OPTIMIZER_HIDE_VAR(size); > > - KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 1, 0, 2)); > > + OPTIMIZER_HIDE_VAR(size2); > > + KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 1, 0, size2)); > > kfree(ptr); > > } > > > > @@ -508,14 +511,17 @@ static void kmalloc_oob_memset_4(struct kunit *test) > > { > > char *ptr; > > size_t size = 128 - KASAN_GRANULE_SIZE; > > + size_t size2 = 4; > > > > KASAN_TEST_NEEDS_CHECKED_MEMINTRINSICS(test); > > > > ptr = kmalloc(size, GFP_KERNEL); > > KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); > > > > + OPTIMIZER_HIDE_VAR(ptr); > > OPTIMIZER_HIDE_VAR(size); > > - KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 3, 0, 4)); > > + OPTIMIZER_HIDE_VAR(size2); > > + KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 3, 0, size2)); > > kfree(ptr); > > } > > > > @@ -523,14 +529,17 @@ static void kmalloc_oob_memset_8(struct kunit *test) > > { > > char *ptr; > > size_t size = 128 - KASAN_GRANULE_SIZE; > > + size_t size2 = 8; > > > > KASAN_TEST_NEEDS_CHECKED_MEMINTRINSICS(test); > > > > ptr = kmalloc(size, GFP_KERNEL); > > KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); > > > > + OPTIMIZER_HIDE_VAR(ptr); > > OPTIMIZER_HIDE_VAR(size); > > - KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 7, 0, 8)); > > + OPTIMIZER_HIDE_VAR(size2); > > + KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 7, 0, size2)); > > kfree(ptr); > > } > > > > @@ -538,14 +547,17 @@ static void kmalloc_oob_memset_16(struct kunit *test) > > { > > char *ptr; > > size_t size = 128 - KASAN_GRANULE_SIZE; > > + size_t size2 = 16; > > > > KASAN_TEST_NEEDS_CHECKED_MEMINTRINSICS(test); > > > > ptr = kmalloc(size, GFP_KERNEL); > > KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); > > > > + OPTIMIZER_HIDE_VAR(ptr); > > OPTIMIZER_HIDE_VAR(size); > > - KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 15, 0, 16)); > > + OPTIMIZER_HIDE_VAR(size2); > > + KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 15, 0, size2)); > > kfree(ptr); > > } > > > > -- > > 2.43.0 > > > > With the fix mentioned above addressed: > > Reviewed-by: Andrey Konovalov <andreyknvl@gmail.com> >
On Wed, Dec 13, 2023 at 10:42 PM Nico Pache <npache@redhat.com> wrote: > > > > diff --git a/mm/kasan/kasan_test.c b/mm/kasan/kasan_test.c > > > index 8281eb42464b..5aeba810ba70 100644 > > > --- a/mm/kasan/kasan_test.c > > > +++ b/mm/kasan/kasan_test.c > > > @@ -493,14 +493,17 @@ static void kmalloc_oob_memset_2(struct kunit *test) > > > { > > > char *ptr; > > > size_t size = 128 - KASAN_GRANULE_SIZE; > > > + size_t size2 = 2; > > > > Let's name this variable access_size or memset_size. Here and in the > > other changed tests. > > Hi Andrey, > > I agree that is a better variable name, but I chose size2 because > other kasan tests follow the same pattern. These other tests use size1 and size2 to refer to different sizes of krealloc allocations, which seems reasonable. > Please let me know if you still want me to update it given that info > and I'll send a V2. Yes, please update the name. Thank you!
diff --git a/mm/kasan/kasan_test.c b/mm/kasan/kasan_test.c index 8281eb42464b..5aeba810ba70 100644 --- a/mm/kasan/kasan_test.c +++ b/mm/kasan/kasan_test.c @@ -493,14 +493,17 @@ static void kmalloc_oob_memset_2(struct kunit *test) { char *ptr; size_t size = 128 - KASAN_GRANULE_SIZE; + size_t size2 = 2; KASAN_TEST_NEEDS_CHECKED_MEMINTRINSICS(test); ptr = kmalloc(size, GFP_KERNEL); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); + OPTIMIZER_HIDE_VAR(ptr); OPTIMIZER_HIDE_VAR(size); - KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 1, 0, 2)); + OPTIMIZER_HIDE_VAR(size2); + KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 1, 0, size2)); kfree(ptr); } @@ -508,14 +511,17 @@ static void kmalloc_oob_memset_4(struct kunit *test) { char *ptr; size_t size = 128 - KASAN_GRANULE_SIZE; + size_t size2 = 4; KASAN_TEST_NEEDS_CHECKED_MEMINTRINSICS(test); ptr = kmalloc(size, GFP_KERNEL); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); + OPTIMIZER_HIDE_VAR(ptr); OPTIMIZER_HIDE_VAR(size); - KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 3, 0, 4)); + OPTIMIZER_HIDE_VAR(size2); + KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 3, 0, size2)); kfree(ptr); } @@ -523,14 +529,17 @@ static void kmalloc_oob_memset_8(struct kunit *test) { char *ptr; size_t size = 128 - KASAN_GRANULE_SIZE; + size_t size2 = 8; KASAN_TEST_NEEDS_CHECKED_MEMINTRINSICS(test); ptr = kmalloc(size, GFP_KERNEL); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); + OPTIMIZER_HIDE_VAR(ptr); OPTIMIZER_HIDE_VAR(size); - KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 7, 0, 8)); + OPTIMIZER_HIDE_VAR(size2); + KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 7, 0, size2)); kfree(ptr); } @@ -538,14 +547,17 @@ static void kmalloc_oob_memset_16(struct kunit *test) { char *ptr; size_t size = 128 - KASAN_GRANULE_SIZE; + size_t size2 = 16; KASAN_TEST_NEEDS_CHECKED_MEMINTRINSICS(test); ptr = kmalloc(size, GFP_KERNEL); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); + OPTIMIZER_HIDE_VAR(ptr); OPTIMIZER_HIDE_VAR(size); - KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 15, 0, 16)); + OPTIMIZER_HIDE_VAR(size2); + KUNIT_EXPECT_KASAN_FAIL(test, memset(ptr + size - 15, 0, size2)); kfree(ptr); }