mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [GIT PULL] kunit fixes update for Linux 7.1.-rc6
@ 2026-05-26 19:43 Shuah Khan
  2026-05-26 23:41 ` pr-tracker-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Shuah Khan @ 2026-05-26 19:43 UTC (permalink / raw)
  To: Linus Torvalds
  Cc: shuah, Shuah Khan, David Gow, Brendan Higgins, Rae Moar,
	linux-kselftest, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2537 bytes --]

Hi Linus,

Please pull this kunit fixes update for Linux 7.1-rc6.

Fixes use-after-free in kunit debugfs when using kunit.filter when
the executor frees dynamically allocated resources after running
boot-time tests. This resulted in fatal hardware exception due to
invalidation of capability flags on the reclaimed memory on some
architectures such as CHERI RISC-V that support the feature, and
silent memory corruption on others.

Fix for this UAF couples the coupling the lifetime of the filtered
suite memory allocation to the lifetime of the kunit subsystem and its
associated VFS nodes. Ownership of the boot-time suite_set is now
transferred to a global tracker ('kunit_boot_suites'), and the memory
is cleanly released in kunit_exit() during module teardown.

diff is attached.

thanks,
-- Shuah

----------------------------------------------------------------
The following changes since commit 8f80b5b227ef9ea422080487715c841856339aed:

   kunit: config: KUNIT_DEBUGFS should depend on DEBUG_FS (2026-05-04 12:10:40 -0600)

are available in the Git repository at:

   git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest tags/linux_kselftest-kunit-fixes-7.1-rc6

for you to fetch changes up to fb6988b83b4cafe8db63999c1ddff1b7c66d2ff5:

   kunit: fix use-after-free in debugfs when using kunit.filter (2026-05-21 10:45:49 -0600)

----------------------------------------------------------------
linux_kselftest-kunit-fixes-7.1-rc6

Fixes use-after-free in kunit debugfs when using kunit.filter when
the executor frees dynamically allocated resources after running
boot-time tests. This resulted in fatal hardware exception due to
invalidation of capability flags on the reclaimed memory on some
architectures such as CHERI RISC-V that support the feature, and
silent memory corruption on others.

Fix for this UAF couples the coupling the lifetime of the filtered
suite memory allocation to the lifetime of the kunit subsystem and its
associated VFS nodes. Ownership of the boot-time suite_set is now
transferred to a global tracker ('kunit_boot_suites'), and the memory
is cleanly released in kunit_exit() during module teardown.

----------------------------------------------------------------
Florian Schmaus (1):
       kunit: fix use-after-free in debugfs when using kunit.filter

  include/kunit/test.h |  1 +
  lib/kunit/executor.c | 19 ++++++++++++++++---
  lib/kunit/test.c     |  1 +
  3 files changed, 18 insertions(+), 3 deletions(-)

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

[-- Attachment #2: linux_kselftest-kunit-fixes-7.1-rc6.diff --]
[-- Type: text/x-patch, Size: 1946 bytes --]

diff --git a/include/kunit/test.h b/include/kunit/test.h
index 9cd1594ab697..ce0573e196ce 100644
--- a/include/kunit/test.h
+++ b/include/kunit/test.h
@@ -613,6 +613,7 @@ unsigned long kunit_vm_mmap(struct kunit *test, struct file *file,
 			    unsigned long offset);
 
 void kunit_cleanup(struct kunit *test);
+void kunit_free_boot_suites(void);
 
 void __printf(2, 3) kunit_log_append(struct string_stream *log, const char *fmt, ...);
 
diff --git a/lib/kunit/executor.c b/lib/kunit/executor.c
index 1fef217de11d..b0f8a41d61d3 100644
--- a/lib/kunit/executor.c
+++ b/lib/kunit/executor.c
@@ -15,6 +15,16 @@ extern struct kunit_suite * const __kunit_suites_end[];
 extern struct kunit_suite * const __kunit_init_suites_start[];
 extern struct kunit_suite * const __kunit_init_suites_end[];
 
+static struct kunit_suite_set kunit_boot_suites;
+
+void kunit_free_boot_suites(void)
+{
+	if (kunit_boot_suites.start) {
+		kunit_free_suite_set(kunit_boot_suites);
+		kunit_boot_suites = (struct kunit_suite_set){ NULL, NULL };
+	}
+}
+
 static char *action_param;
 
 module_param_named(action, action_param, charp, 0400);
@@ -411,9 +421,12 @@ int kunit_run_all_tests(void)
 		pr_err("kunit executor: unknown action '%s'\n", action_param);
 
 free_out:
-	if (filter_glob_param || filter_param)
-		kunit_free_suite_set(suite_set);
-	else if (init_num_suites > 0)
+	if (filter_glob_param || filter_param) {
+		if (err)
+			kunit_free_suite_set(suite_set);
+		else
+			kunit_boot_suites = suite_set;
+	} else if (init_num_suites > 0)
 		/* Don't use kunit_free_suite_set because suites aren't individually allocated */
 		kfree(suite_set.start);
 
diff --git a/lib/kunit/test.c b/lib/kunit/test.c
index 41e1c89799b6..99773e000e1b 100644
--- a/lib/kunit/test.c
+++ b/lib/kunit/test.c
@@ -1075,6 +1075,7 @@ static void __exit kunit_exit(void)
 	kunit_bus_shutdown();
 
 	kunit_debugfs_cleanup();
+	kunit_free_boot_suites();
 }
 module_exit(kunit_exit);
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [GIT PULL] kunit fixes update for Linux 7.1.-rc6
  2026-05-26 19:43 [GIT PULL] kunit fixes update for Linux 7.1.-rc6 Shuah Khan
@ 2026-05-26 23:41 ` pr-tracker-bot
  0 siblings, 0 replies; 2+ messages in thread
From: pr-tracker-bot @ 2026-05-26 23:41 UTC (permalink / raw)
  To: Shuah Khan
  Cc: Linus Torvalds, shuah, Shuah Khan, David Gow, Brendan Higgins,
	Rae Moar, linux-kselftest, linux-kernel

The pull request you sent on Tue, 26 May 2026 13:43:32 -0600:

> git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest tags/linux_kselftest-kunit-fixes-7.1-rc6

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/e909cedf6800ef493063f18a089f3632817a8c2d

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/prtracker.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-05-26 23:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-26 19:43 [GIT PULL] kunit fixes update for Linux 7.1.-rc6 Shuah Khan
2026-05-26 23:41 ` pr-tracker-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®