git: 9d6b8de8c225 - stable/14 - modstat: allow compat support to fail in tests
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 16 Nov 2026 18:12:52 UTC
The branch stable/14 has been updated by brooks:
URL: https://cgit.FreeBSD.org/src/commit/?id=9d6b8de8c2258a5b9881c8a5993c32da3ee400fe
commit 9d6b8de8c2258a5b9881c8a5993c32da3ee400fe
Author: Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2026-11-13 10:06:52 +0000
Commit: Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2026-11-16 15:57:43 +0000
modstat: allow compat support to fail in tests
v1 and v2 versions of stuct module_stat are now gated by COMPAT_ ifdefs
so allow the otherwise valid query to fail with EINVAL.
Effort: CHERI upstreaming
Reviewed by: markj
Reported by: llm-postcr
Sponsored by: Innovate UK
Fixes: 1ebf46ecb627 ("modstat: don't copyout while holding a lock")
Differential Revision: https://reviews.freebsd.org/D61460
(cherry picked from commit ef726c645300870b6bdf3573079b1f89f3b45c74)
---
tests/sys/kern/module_test.c | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/tests/sys/kern/module_test.c b/tests/sys/kern/module_test.c
index 37cbc3b3271a..b4f66ec9c953 100644
--- a/tests/sys/kern/module_test.c
+++ b/tests/sys/kern/module_test.c
@@ -30,6 +30,7 @@
#include <sys/param.h>
#include <sys/module.h>
#include <errno.h>
+#include <unistd.h>
#include <atf-c.h>
ATF_TC_WITHOUT_HEAD(modfind);
@@ -144,11 +145,14 @@ ATF_TC_BODY(modstat_v1, tc)
ATF_REQUIRE(modstat(modid, (struct module_stat *)&ms) == -1);
ATF_REQUIRE(errno == EINVAL);
+ /* Kernels only support module_stat_v1 when compiled with COMPAT_43 */
ms.version = sizeof(ms);
- ATF_REQUIRE(modstat(modid, (struct module_stat *)&ms) == 0);
- ATF_REQUIRE(ms.id == modid);
- if (strnlen(ms.name, sizeof(ms.name)) < sizeof(ms.name))
- ATF_REQUIRE(modfind(ms.name) == modid);
+ if (modstat(modid, (struct module_stat *)&ms) == 0) {
+ ATF_REQUIRE(ms.id == modid);
+ if (strnlen(ms.name, sizeof(ms.name)) < sizeof(ms.name))
+ ATF_REQUIRE(modfind(ms.name) == modid);
+ } else
+ ATF_REQUIRE(errno == EINVAL);
}
ATF_TC_WITHOUT_HEAD(modstat_v2);
@@ -178,10 +182,14 @@ ATF_TC_BODY(modstat_v2, tc)
ATF_REQUIRE(errno == EINVAL);
ms.version = sizeof(ms);
- ATF_REQUIRE(modstat(modid, (struct module_stat *)&ms) == 0);
- ATF_REQUIRE(ms.id == modid);
- if (strnlen(ms.name, sizeof(ms.name)) < sizeof(ms.name))
- ATF_REQUIRE(modfind(ms.name) == modid);
+ if (modstat(modid, (struct module_stat *)&ms) == 0) {
+ ATF_REQUIRE(ms.id == modid);
+ if (strnlen(ms.name, sizeof(ms.name)) < sizeof(ms.name))
+ ATF_REQUIRE(modfind(ms.name) == modid);
+ } else {
+ ATF_REQUIRE(!feature_present("compat_freebsd13"));
+ ATF_REQUIRE(errno == EINVAL);
+ }
}
ATF_TP_ADD_TCS(tp)