[LTP] [PATCH] cve-2026-46331: fix intermittent ENOENT failure
Cyril Hrubis
chrubis@suse.cz
Mon Jul 20 13:02:32 CEST 2026
Hi!
> #include <sys/sendfile.h>
> +#include <sys/prctl.h>
> +#include <pwd.h>
> #include <linux/rtnetlink.h>
>
> #include "tst_test.h"
> @@ -128,7 +130,31 @@ static int acc_fd = -1;
> static void setup(void)
> {
> struct sockaddr_in addr;
> - int i;
> + struct passwd *pw;
> + static const char *const mods[] = {
> + "sch_ingress", "cls_matchall", "act_pedit"
> + };
> + static const char *cmd[] = {"modprobe", NULL, NULL};
> + unsigned int i;
> +
> + for (i = 0; i < ARRAY_SIZE(mods); i++) {
> + cmd[1] = mods[i];
> +
> + if (tst_cmd(cmd, NULL, "/dev/null", TST_CMD_PASS_RETVAL))
> + tst_brk(TCONF, "kernel module %s is not available", mods[i]);
> + }
We do have tst_module_load().
> + /* Drop privileges so the reproducer runs as an unprivileged user */
> + pw = SAFE_GETPWNAM("nobody");
> + SAFE_SETGID(pw->pw_gid);
> + SAFE_SETUID(pw->pw_uid);
> +
> + /*
> + * setuid() clears the dumpable flag, which makes /proc/self/*
> + * owned by root and prevents tst_setup_netns() from writing the
> + * uid/gid maps. Restore it so the user namespace can be set up.
> + */
> + SAFE_PRCTL(PR_SET_DUMPABLE, 1, 0, 0, 0);
>
> tst_setup_netns();
> NETDEV_SET_STATE("lo", 1);
> @@ -253,7 +279,12 @@ static struct tst_test test = {
> .test_all = run,
> .setup = setup,
> .cleanup = cleanup,
> + .needs_root = 1,
> .needs_tmpdir = 1,
> + .needs_cmds = (struct tst_cmd[]) {
> + {.cmd = "modprobe"},
> + {}
> + },
> .needs_kconfigs = (const char *[]) {
> "CONFIG_USER_NS=y",
> "CONFIG_NET_NS=y",
The check for the module existence should be done by adding:
"CONFIG_NET_SCH_INGRESS",
"CONFIG_NET_CLS_MATCHALL",
"CONFIG_NET_ACT_PEDIT",
to the needs_kconfigs.
And then adding module mappings to tst_kconfig.c
diff --git a/lib/tst_kconfig.c b/lib/tst_kconfig.c
index 44eacc7c2..277ac6068 100644
--- a/lib/tst_kconfig.c
+++ b/lib/tst_kconfig.c
@@ -162,6 +162,9 @@ static struct config_module_map {
{"CONFIG_CAN_RAW", "can-raw"},
{"CONFIG_CAN_BCM", "can-bcm"},
{"CONFIG_IP_SCTP", "sctp"},
+ {"CONFIG_NET_SCH_INGRESS", "sch_ingress"},
+ {"CONFIG_NET_CLS_MATCHALL", "cls_matchall"},
+ {"CONFIG_NET_ACT_PEDIT", "act_pedit"},
{}
};
With that the checks will be done in the test library even before the
test is started.
We may also add a flag to tst_test structure to load the modules mapped
to the config variables, something as .kconfig_load.
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list