From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 9D44E4315A; Sun, 7 Sep 2025 20:42:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757277758; cv=none; b=CBMIeJV+6ZigOowUCYIEdlBlgg4Jp7afTxd+FV5LFScGEm88phzOci7hX7DCg3nh9ex/YX62GtOGUJzLBnIcwoZOgOTDHUThNfw+bEX5iFAfxr1zOwLxgcTeDFhxMbRGZJ3uz7qDXRQNOEx7XuuPO94tNkGWsEdB+Y6dbsl7boE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757277758; c=relaxed/simple; bh=KDuaTDsxARTKnDqmfuzLy4QndI6K/c0edDKTa8EXfNY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mmToIAmemH+tJqvUquBgWhMEVGRdHEXH1HUQunwyiMCWRGtfOysLdvTEmCpuAjbngp0j4ApdcKspFNPB63RIh7iULvqQNknyGDf3KiDS7Q5cI5I450HWLC27b3QIXdbmB9J39+PjwG3yHbWNA7W31t0+YuHn76msvrfVIugygws= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=HfigNR+c; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="HfigNR+c" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8BFEC4CEF0; Sun, 7 Sep 2025 20:42:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1757277758; bh=KDuaTDsxARTKnDqmfuzLy4QndI6K/c0edDKTa8EXfNY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HfigNR+cdpDH/xMIl0A9ICzn+6+0le71f0InouvhcQDtGMWQu131LJeFva8l5DPVZ GWzPwQNo9LJMEi3qNo6M2++nR6rGJfdELFgyKY99Epjm0nwWV/BtDP98TC5J4frMyv JfLGp+THrCdUO29VnqEFYugfnBPU2+VTcNDTio5k= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yeoreum Yun , Alexander Potapenko , Andrey Konovalov , Andrey Ryabinin , Dmitriy Vyukov , Vincenzo Frascino , Andrew Morton Subject: [PATCH 6.16 112/183] kunit: kasan_test: disable fortify string checker on kasan_strings() test Date: Sun, 7 Sep 2025 21:58:59 +0200 Message-ID: <20250907195618.454015521@linuxfoundation.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250907195615.802693401@linuxfoundation.org> References: <20250907195615.802693401@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yeoreum Yun commit 7a19afee6fb39df63ddea7ce78976d8c521178c6 upstream. Similar to commit 09c6304e38e4 ("kasan: test: fix compatibility with FORTIFY_SOURCE") the kernel is panicing in kasan_string(). This is due to the `src` and `ptr` not being hidden from the optimizer which would disable the runtime fortify string checker. Call trace: __fortify_panic+0x10/0x20 (P) kasan_strings+0x980/0x9b0 kunit_try_run_case+0x68/0x190 kunit_generic_run_threadfn_adapter+0x34/0x68 kthread+0x1c4/0x228 ret_from_fork+0x10/0x20 Code: d503233f a9bf7bfd 910003fd 9424b243 (d4210000) ---[ end trace 0000000000000000 ]--- note: kunit_try_catch[128] exited with irqs disabled note: kunit_try_catch[128] exited with preempt_count 1 # kasan_strings: try faulted: last ** replaying previous printk message ** # kasan_strings: try faulted: last line seen mm/kasan/kasan_test_c.c:1600 # kasan_strings: internal error occurred preventing test case from running: -4 Link: https://lkml.kernel.org/r/20250801120236.2962642-1-yeoreum.yun@arm.com Fixes: 73228c7ecc5e ("KASAN: port KASAN Tests to KUnit") Signed-off-by: Yeoreum Yun Cc: Alexander Potapenko Cc: Andrey Konovalov Cc: Andrey Ryabinin Cc: Dmitriy Vyukov Cc: Vincenzo Frascino Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- mm/kasan/kasan_test_c.c | 2 ++ 1 file changed, 2 insertions(+) --- a/mm/kasan/kasan_test_c.c +++ b/mm/kasan/kasan_test_c.c @@ -1578,9 +1578,11 @@ static void kasan_strings(struct kunit * ptr = kmalloc(size, GFP_KERNEL | __GFP_ZERO); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ptr); + OPTIMIZER_HIDE_VAR(ptr); src = kmalloc(KASAN_GRANULE_SIZE, GFP_KERNEL | __GFP_ZERO); strscpy(src, "f0cacc1a0000000", KASAN_GRANULE_SIZE); + OPTIMIZER_HIDE_VAR(src); /* * Make sure that strscpy() does not trigger KASAN if it overreads into