Linux Test Project
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Andrea Cervesato <andrea.cervesato@suse.de>
Cc: Linux Test Project <ltp@lists.linux.it>
Subject: Re: [LTP] [PATCH] cve-2026-46331: fix intermittent ENOENT failure
Date: Mon, 20 Jul 2026 13:02:32 +0200	[thread overview]
Message-ID: <al4ASHAmTGEYfIVD@yuki.lan> (raw)
In-Reply-To: <20260717-fix_cve-2026-46331_enoent-v1-1-85425e81ff7a@suse.com>

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

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  parent reply	other threads:[~2026-07-20 11:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-17 13:21 [LTP] [PATCH] cve-2026-46331: fix intermittent ENOENT failure Andrea Cervesato
2026-07-20  7:53 ` Sebastian Chlad
2026-07-20 11:02 ` Cyril Hrubis [this message]
2026-07-20 12:06   ` Andrea Cervesato via ltp

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=al4ASHAmTGEYfIVD@yuki.lan \
    --to=chrubis@suse.cz \
    --cc=andrea.cervesato@suse.de \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox