Linux Security Modules development
 help / color / mirror / Atom feed
* [PATCH] security/landlock: Add KUnit test for mixed valid and unknown namespace bits
@ 2026-11-15 17:14 Terence White
  2026-11-15 17:29 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Terence White @ 2026-11-15 17:14 UTC (permalink / raw)
  To: linux-security-module; +Cc: gnoack, mic

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

Good evening,

This patch adds a KUnit test case (test_ns_types_to_bits_mixed) to exercise
landlock_ns_types_to_bits() with a mixed bitmask containing both a valid
namespace type (CLONE_NEWNS) and an unknown high bit. This verifies that
the WARN_ON_ONCE truncation guard behaves as expected under
partial-taint inputs.

Tested locally with all 40 KUnit tests passing successfully.

With kind regards,

Terry White

[-- Attachment #2: 0001-security-landlock-Add-KUnit-test-for-mixed-valid-and.patch --]
[-- Type: application/octet-stream, Size: 1736 bytes --]

From 052d35c9f82dfc7275fe23359f6b6ec8d7242e16 Mon Sep 17 00:00:00 2001
From: Terry White <terrywhite2025@gmail.com>
Date: Sun, 15 Nov 2026 16:57:33 +0000
Subject: [PATCH] security/landlock: Add KUnit test for mixed valid and unknown
 namespace bits

Add a KUnit test case (test_ns_types_to_bits_mixed) to exercise
landlock_ns_types_to_bits() with a mixed bitmask containing both
a valid namespace type (CLONE_NEWNS) and an unknown high bit.
This ensures the WARN_ON_ONCE truncation guard functions correctly
under partial-taint inputs.

Signed-off-by: Terry White <terrywhite2025@gmail.com>
---
 security/landlock/ns.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/security/landlock/ns.c b/security/landlock/ns.c
index 06d978474..d82028942 100644
--- a/security/landlock/ns.c
+++ b/security/landlock/ns.c
@@ -217,6 +217,20 @@ static void test_ns_types_to_bits_unknown(struct kunit *const test)
 	}
 }
 
+static void test_ns_types_to_bits_mixed(struct kunit *const test)
+{
+	if (!IS_ENABLED(CONFIG_BUG))
+		kunit_skip(test, "requires CONFIG_BUG");
+
+	/* clang-format off */
+	kunit_warning_suppress(test) {
+		/* clang-format on */
+		KUNIT_EXPECT_NE(test, 0ULL,
+				landlock_ns_types_to_bits(CLONE_NEWNS | (1ULL << 62)));
+		KUNIT_EXPECT_SUPPRESSED_WARNING_COUNT(test, 1);
+	}
+}
+
 static void test_ns_types_to_bits_zero(struct kunit *const test)
 {
 	KUNIT_EXPECT_EQ(test, 0ULL, landlock_ns_types_to_bits(0));
@@ -228,6 +242,7 @@ static struct kunit_case test_cases[] = {
 	KUNIT_CASE(test_ns_types_to_bits_all),
 	KUNIT_CASE(test_ns_types_to_bits_single),
 	KUNIT_CASE(test_ns_types_to_bits_unknown),
+	KUNIT_CASE(test_ns_types_to_bits_mixed),
 	KUNIT_CASE(test_ns_types_to_bits_zero),
 	{}
 };
-- 
2.43.0


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

end of thread, other threads:[~2026-11-15 17:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-15 17:14 [PATCH] security/landlock: Add KUnit test for mixed valid and unknown namespace bits Terence White
2026-11-15 17:29 ` sashiko-bot

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