Commit 2055aa9f authored by Andrey Konovalov's avatar Andrey Konovalov Committed by Wen Zhiwei
Browse files

kasan: remove vmalloc_percpu test

stable inclusion
from stable-v6.6.60
commit 70bbe8d0a949413df1bb6532fd6b19fbf0f88feb
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IB44K1

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=70bbe8d0a949413df1bb6532fd6b19fbf0f88feb

--------------------------------

[ Upstream commit 330d8df81f3673d6fb74550bbc9bb159d81b35f7 ]

Commit 1a2473f0 ("kasan: improve vmalloc tests") added the
vmalloc_percpu KASAN test with the assumption that __alloc_percpu always
uses vmalloc internally, which is tagged by KASAN.

However, __alloc_percpu might allocate memory from the first per-CPU
chunk, which is not allocated via vmalloc().  As a result, the test might
fail.

Remove the test until proper KASAN annotation for the per-CPU allocated
are added; tracked in https://bugzilla.kernel.org/show_bug.cgi?id=215019.

Link: https://lkml.kernel.org/r/20241022160706.38943-1-andrey.konovalov@linux.dev


Fixes: 1a2473f0 ("kasan: improve vmalloc tests")
Signed-off-by: default avatarAndrey Konovalov <andreyknvl@gmail.com>
Reported-by: default avatarSamuel Holland <samuel.holland@sifive.com>
Link: https://lore.kernel.org/all/4a245fff-cc46-44d1-a5f9-fd2f1c3764ae@sifive.com/


Reported-by: default avatarSabyrzhan Tasbolatov <snovitoll@gmail.com>
Link: https://lore.kernel.org/all/CACzwLxiWzNqPBp4C1VkaXZ2wDwvY3yZeetCi1TLGFipKW77drA@mail.gmail.com/


Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Marco Elver <elver@google.com>
Cc: Sabyrzhan Tasbolatov <snovitoll@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarWen Zhiwei <wenzhiwei@kylinos.cn>
parent a4023776
Loading
Loading
Loading
Loading
+0 −27
Original line number Diff line number Diff line
@@ -1381,32 +1381,6 @@ static void vm_map_ram_tags(struct kunit *test)
	free_pages((unsigned long)p_ptr, 1);
}

static void vmalloc_percpu(struct kunit *test)
{
	char __percpu *ptr;
	int cpu;

	/*
	 * This test is specifically crafted for the software tag-based mode,
	 * the only tag-based mode that poisons percpu mappings.
	 */
	KASAN_TEST_NEEDS_CONFIG_ON(test, CONFIG_KASAN_SW_TAGS);

	ptr = __alloc_percpu(PAGE_SIZE, PAGE_SIZE);

	for_each_possible_cpu(cpu) {
		char *c_ptr = per_cpu_ptr(ptr, cpu);

		KUNIT_EXPECT_GE(test, (u8)get_tag(c_ptr), (u8)KASAN_TAG_MIN);
		KUNIT_EXPECT_LT(test, (u8)get_tag(c_ptr), (u8)KASAN_TAG_KERNEL);

		/* Make sure that in-bounds accesses don't crash the kernel. */
		*c_ptr = 0;
	}

	free_percpu(ptr);
}

/*
 * Check that the assigned pointer tag falls within the [KASAN_TAG_MIN,
 * KASAN_TAG_KERNEL) range (note: excluding the match-all tag) for tag-based
@@ -1562,7 +1536,6 @@ static struct kunit_case kasan_kunit_test_cases[] = {
	KUNIT_CASE(vmalloc_oob),
	KUNIT_CASE(vmap_tags),
	KUNIT_CASE(vm_map_ram_tags),
	KUNIT_CASE(vmalloc_percpu),
	KUNIT_CASE(match_all_not_assigned),
	KUNIT_CASE(match_all_ptr_tag),
	KUNIT_CASE(match_all_mem_tag),