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 8B295168C4; Mon, 27 May 2024 19:21:49 +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=1716837709; cv=none; b=GAux/vV+u+pY4QNlHXardmljL385vNg2AfO+Vnbx30doZ0LrVmnaWAm1FbxDbmNCbbupZXAoaJGP68U/8XNsLA/zzmE+Z/eHl4xtVLM8zwCyPcxskzx8OfFNc53hx26gNqy2KW6VM0VYHJJBJo9ZklOxeLRNJgvdY/xhNVeDK+8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716837709; c=relaxed/simple; bh=Z+1Ihfln+g+XLwKZGWziGatHafQkjRWp6XgTfKFGLr8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZjOy8QKGxL7ZD/SvdkdfsY2aVIT5S8oGx4+PCjyl++gTwgTGmGtuw7EFxozchl2DlCdv4fikF46YFSwAfGAeWCOMNIkPMbOoTOoHPIzZsM5o3KcfGZ3kPZZZVnoGRuO7M8OU2vct+nElfByVolhtWPDZ+Ko97uIo7yVqKCKuFwc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=zmXykM5h; 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="zmXykM5h" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D453C2BBFC; Mon, 27 May 2024 19:21:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1716837709; bh=Z+1Ihfln+g+XLwKZGWziGatHafQkjRWp6XgTfKFGLr8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zmXykM5hUptWQsG2W6SZ7Ky7w1IEqFlzjcjd0YCrsuRmOwfwVy8EUalgLr+BkIS/z oD9P9cvIdm5tMfCojPm0NC3Pvjzu7icCAFdpfH0pLjJTT+Pr17tzfUWl9iEn4A5/FG 3kN7fSc3lVxb6pTw3fQvnuLmGFoZR3g1UFMEqYRM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Oliver Glitta , Vlastimil Babka , Daniel Latypov , Marco Elver , Guenter Roeck , Sasha Levin Subject: [PATCH 6.8 113/493] mm/slub, kunit: Use inverted data to corrupt kmem cache Date: Mon, 27 May 2024 20:51:55 +0200 Message-ID: <20240527185634.223861337@linuxfoundation.org> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240527185626.546110716@linuxfoundation.org> References: <20240527185626.546110716@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.8-stable review patch. If anyone has any objections, please let me know. ------------------ From: Guenter Roeck [ Upstream commit b1080c667b3b2c8c38a7fa83ca5567124887abae ] Two failure patterns are seen randomly when running slub_kunit tests with CONFIG_SLAB_FREELIST_RANDOM and CONFIG_SLAB_FREELIST_HARDENED enabled. Pattern 1: # test_clobber_zone: pass:1 fail:0 skip:0 total:1 ok 1 test_clobber_zone # test_next_pointer: EXPECTATION FAILED at lib/slub_kunit.c:72 Expected 3 == slab_errors, but slab_errors == 0 (0x0) # test_next_pointer: EXPECTATION FAILED at lib/slub_kunit.c:84 Expected 2 == slab_errors, but slab_errors == 0 (0x0) # test_next_pointer: pass:0 fail:1 skip:0 total:1 not ok 2 test_next_pointer In this case, test_next_pointer() overwrites p[s->offset], but the data at p[s->offset] is already 0x12. Pattern 2: ok 1 test_clobber_zone # test_next_pointer: EXPECTATION FAILED at lib/slub_kunit.c:72 Expected 3 == slab_errors, but slab_errors == 2 (0x2) # test_next_pointer: pass:0 fail:1 skip:0 total:1 not ok 2 test_next_pointer In this case, p[s->offset] has a value other than 0x12, but one of the expected failures is nevertheless missing. Invert data instead of writing a fixed value to corrupt the cache data structures to fix the problem. Fixes: 1f9f78b1b376 ("mm/slub, kunit: add a KUnit test for SLUB debugging functionality") Cc: Oliver Glitta Cc: Vlastimil Babka CC: Daniel Latypov Cc: Marco Elver Signed-off-by: Guenter Roeck Signed-off-by: Vlastimil Babka Signed-off-by: Sasha Levin --- lib/slub_kunit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/slub_kunit.c b/lib/slub_kunit.c index d4a3730b08fa7..4ce9604388069 100644 --- a/lib/slub_kunit.c +++ b/lib/slub_kunit.c @@ -55,7 +55,7 @@ static void test_next_pointer(struct kunit *test) ptr_addr = (unsigned long *)(p + s->offset); tmp = *ptr_addr; - p[s->offset] = 0x12; + p[s->offset] = ~p[s->offset]; /* * Expecting three errors. -- 2.43.0