From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43427C3DA4A for ; Wed, 14 Aug 2024 20:38:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CCA776B007B; Wed, 14 Aug 2024 16:38:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C796D6B0082; Wed, 14 Aug 2024 16:38:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B41826B0083; Wed, 14 Aug 2024 16:38:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 8E3FC6B007B for ; Wed, 14 Aug 2024 16:38:25 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 366F6A849B for ; Wed, 14 Aug 2024 20:38:25 +0000 (UTC) X-FDA: 82452013770.18.DCAFAAE Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) by imf05.hostedemail.com (Postfix) with ESMTP id 02A1E100009 for ; Wed, 14 Aug 2024 20:38:22 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=mailbox.org header.s=mail20150812 header.b=ym89Oi8C; spf=pass (imf05.hostedemail.com: domain of erhard_f@mailbox.org designates 80.241.56.171 as permitted sender) smtp.mailfrom=erhard_f@mailbox.org; dmarc=pass (policy=reject) header.from=mailbox.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723667831; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=TIsWcyNQLZ1L3dpzsMlhD2bWOPEsXI8zeJwnW7xOHks=; b=gsh6iQfXwDZalRfWi6pKQTV+4XKqszE8+Af3wwksVDt8JH10ur50EkXCHkbIQDtNBwGW2P d/YYW4dgCQD7Eq4dkLWQ2H0nM4h6PGRpH9fMH9j2Vsa8pwfXBX0f1raioh/fzQRW8Kv+AU OfTVk+xc2cQjOcXG3ozvRBPYqhTah3w= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723667831; a=rsa-sha256; cv=none; b=KZi1mJfccsAFTe6593PuzGceDiHwyw3bu1pbT9/whTWZdBUbwVLI/Ivn6INVnoXNzmliA0 u0N4ljvwTlQGidyt57gtPbzO3237LXcIqjJSjfu2m+wS42rpcllZwUMehiYKwYOp9n8rJr 3r3tpXcp8hcd+4q9GEYuc0SxNrD1A/c= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=mailbox.org header.s=mail20150812 header.b=ym89Oi8C; spf=pass (imf05.hostedemail.com: domain of erhard_f@mailbox.org designates 80.241.56.171 as permitted sender) smtp.mailfrom=erhard_f@mailbox.org; dmarc=pass (policy=reject) header.from=mailbox.org Received: from smtp1.mailbox.org (smtp1.mailbox.org [10.196.197.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4Wkg7Z0p2Vz9stT; Wed, 14 Aug 2024 22:38:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1723667898; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TIsWcyNQLZ1L3dpzsMlhD2bWOPEsXI8zeJwnW7xOHks=; b=ym89Oi8CetNeVTN7hd+zs+6xPYpNWxIGNqaj7ze7i2/mDT6AOLEHotp1+e3GemmaUr0gIb mCKyAZl4YgJ5CDZAEQbibWs5E1M0+WjK1h4wG/Cgx3x5X5qUEZC6VLvf/wb9I6LpJVnE7S AcZalEpL6aDYmvQo0o+Z6fBq09Zxzm17Y/Ibk+y1lmPJerw7DojoINZiX0gJmzqJr9YDOI +QkWw25mYaoFJ2BRshhCjmy1MinTO+LTjzygvt+tBnx5GF3LKQkjHhceh3B2dEho6O4ryT +8i16GX/g/38NWnOPuo7w4CvVisK0SlcuCHxuwL7Dbahw1JCDBOYvz5YcAe3Ng== Date: Wed, 14 Aug 2024 22:38:13 +0200 From: Erhard Furtner To: Kees Cook Cc: linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, David Gow , kunit-dev@googlegroups.com Subject: Re: OVERFLOW_KUNIT_TEST fails with BUG: KASAN: stack-out-of-bounds in string_nocheck+0x168/0x1c8 (kernel 6.11-rc2, PowerMac G4 DP) Message-ID: <20240814223813.7b301ad4@yea> In-Reply-To: <202408121146.1D02EB6E@keescook> References: <20240809231537.7c9ee7ea@yea> <202408121146.1D02EB6E@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-MBO-RS-META: 7dux6gigon1dmwyopgh45ippfihtjaz6 X-MBO-RS-ID: adbad2d7a6ebe8f9592 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 02A1E100009 X-Stat-Signature: bpzhnhie98ezry568m8rwawa17k34taz X-HE-Tag: 1723667902-271509 X-HE-Meta: U2FsdGVkX1+Mh/75E5HGif+jNlA3bkqoELWh8bSe8LBp0KiCrd3t0Rph4ChebJQGt8Zd7RIl8U8uziFWE9VwILGyJUZ5OQwI2UP7RmLoteH7pqpm2OWoCAY2DxydmpJUsmYAKU0RZtosECZ9YkD1jlvajVnzNieC5B4bsS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SF92leO+/mEq2saN5dggb91ZtmOLYBZA87m9Hm0KKwEr0++8SFgxin+Q== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Mon, 12 Aug 2024 11:54:11 -0700 Kees Cook wrote: > On Fri, Aug 09, 2024 at 11:15:37PM +0200, Erhard Furtner wrote: > > Greetings! > > > > When KASAN is enabled the Overflow KUnit test fails: > > > > [...] > > ok 16 shift_nonsense_test > > # overflow_allocation_test: 11 allocation overflow tests finished > > ================================================================== > > BUG: KASAN: stack-out-of-bounds in string_nocheck+0x168/0x1c8 > > Read of size 1 at addr c976be40 by task kunit_try_catch/1843 > > > > CPU: 0 UID: 0 PID: 1843 Comm: kunit_try_catch Tainted: G N 6.11.0-rc2-PMacG4 #1 > > Tainted: [N]=TEST > > Hardware name: PowerMac3,6 7455 0x80010303 PowerMac > > Call Trace: > > [c992fb80] [c16651c0] dump_stack_lvl+0x80/0xac (unreliable) > > [c992fba0] [c04e0420] print_report+0xdc/0x504 > > [c992fc00] [c04e01d8] kasan_report+0xf8/0x108 > > [c992fc80] [c16ae4c8] string_nocheck+0x168/0x1c8 > > [c992fcf0] [c16b37a4] string+0xa8/0xbc > > [c992fd60] [c16b8134] vsnprintf+0x868/0x1750 > > [c992fdf0] [c0b8490c] kvasprintf+0xa4/0x13c > > [c992fe60] [c0b84c3c] kasprintf+0xb4/0xc8 > > [c992fed0] [c0f4c954] module_remove_driver+0x1f0/0x2fc > > [c992ff00] [c0f21628] bus_remove_driver+0x1d0/0x240 > > [c992ff30] [bfd0cd40] kunit_put_resource+0x128/0x134 [kunit] > > [c992ff50] [bfd0a120] kunit_cleanup+0x140/0x144 [kunit] > > [c992ff90] [bfd10d64] kunit_generic_run_threadfn_adapter+0xf8/0x148 [kunit] > > [c992ffc0] [c00f57e0] kthread+0x36c/0x37c > > [c992fff0] [c0028304] start_kernel_thread+0x10/0x14 > > > > The buggy address belongs to the physical page: > > page: refcount:0 mapcount:0 mapping:00000000 index:0x0 pfn:0x976b > > flags: 0x0(zone=0) > > raw: 00000000 00000000 eef2bb10 00000000 00000000 00000000 ffffffff 00000000 > > raw: 00000000 > > page dumped because: kasan: bad access detected > > > > Memory state around the buggy address: > > c976bd00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > > c976bd80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > > >c976be00: 00 00 00 00 00 00 00 00 f1 f1 f1 f1 04 f2 04 f2 > > ^ > > c976be80: 00 04 f3 f3 00 00 00 00 00 00 00 00 00 00 00 00 > > c976bf00: 00 00 f1 f1 f1 f1 00 f3 f3 f3 00 00 00 00 00 00 > > ================================================================== > > Disabling lock debugging due to kernel taint > > not ok 17 overflow_allocation_test > > # overflow_size_helpers_test: 43 overflow size helper tests finished > > ok 18 overflow_size_helpers_test > > # overflows_type_test: 378 overflows_type() tests finished > > ok 19 overflows_type_test > > # same_type_test: 0 __same_type() tests finished > > ok 20 same_type_test > > # castable_to_type_test: 75 castable_to_type() tests finished > > ok 21 castable_to_type_test > > ok 22 DEFINE_FLEX_test > > # overflow: pass:21 fail:1 skip:0 total:22 > > # Totals: pass:21 fail:1 skip:0 total:22 > > not ok 1 overflow > > > > > > This is reproducible on my machine and always happens when running the test via 'modprobe -v overflow_kunit'. Without KASAN enabled (but KFENCE) overflow_allocation_test passes. > > Hmm, this implies some kind of corruption is sneaking in and the kunit > resource freeing code is exploding. I don't immediately see the problem, > though. Not the 1st memory corruption I got on ppc32 (https://lore.kernel.org/all/20240811165230.91DCFA0660@freki.localdomain/) btw., but this does not seem related. I just did a kernel build with overflow_kunit statically built in to run at boot. This way I don't get the "BUG: KASAN: stack-out-of-bounds in string_nocheck+0x168/0x1c8" on the PowerMac and on qemu. Run directly at boot the overflow_kunit just passes. As soon as I build it as module and modprobe it later, I hit the issue. Strange... A hint that not the test itself might cause the stack corruption but another process. Regards, Erhard