linux-modules.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lucas De Marchi <lucas.demarchi@intel.com>
To: linux-modules@vger.kernel.org
Cc: joao.moreira@intel.com, leandro.maciel.dorileo@intel.com,
	Lucas De Marchi <lucas.demarchi@intel.com>
Subject: [PATCH 2/2] testsuite: check for ill-formed kcmdline
Date: Tue, 10 Mar 2020 01:23:08 -0700	[thread overview]
Message-ID: <20200310082308.14318-2-lucas.demarchi@intel.com> (raw)
In-Reply-To: <20200310082308.14318-1-lucas.demarchi@intel.com>

Commit ca3bf5d47cec ("iommu/amd: Introduces ivrs_acpihid kernel parameter")
in the kernel introduced an ill-formed kernel parameter, ivrs_acpihid.
The problem is that it may have a dot on the key side:
"ivrs_acpihid[00:14.5]=AMD0020:0". This could potentially trip our
parser of module options, but right now it's working as intended: the
only thing that happens is that after deciding "ivrs_acpihid[00:14" is a
module name, it will fail the underscores() routine and the option will
be ignored from the kmod pov (not kernel's pov since that driver parsers
the kernel command line by itself).
---
 .../module-param-kcmdline6/correct.txt        |  6 +++++
 .../module-param-kcmdline6/proc/cmdline       |  1 +
 testsuite/test-modprobe.c                     | 25 +++++++++++++++++++
 3 files changed, 32 insertions(+)
 create mode 100644 testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline6/correct.txt
 create mode 100644 testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline6/proc/cmdline

diff --git a/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline6/correct.txt b/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline6/correct.txt
new file mode 100644
index 0000000..7a087ef
--- /dev/null
+++ b/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline6/correct.txt
@@ -0,0 +1,6 @@
+options psmouse foo=2
+options psmouse bar=1
+options psmouse zinga=test
+
+# End of configuration files. Dumping indexes now:
+
diff --git a/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline6/proc/cmdline b/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline6/proc/cmdline
new file mode 100644
index 0000000..14bbd2e
--- /dev/null
+++ b/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline6/proc/cmdline
@@ -0,0 +1 @@
+psmouse.foo=2 ivrs_acpihid[14:00.5]=AMD0020:00 psmouse.bar=1 psmouse.zinga=test
diff --git a/testsuite/test-modprobe.c b/testsuite/test-modprobe.c
index 1cace82..f908d56 100644
--- a/testsuite/test-modprobe.c
+++ b/testsuite/test-modprobe.c
@@ -328,6 +328,31 @@ DEFINE_TEST(modprobe_param_kcmdline5,
 	);
 
 
+static noreturn int modprobe_param_kcmdline6(const struct test *t)
+{
+	const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe";
+	const char *const args[] = {
+		progname,
+		"-c",
+		NULL,
+	};
+
+	test_spawn_prog(progname, args);
+	exit(EXIT_FAILURE);
+}
+DEFINE_TEST(modprobe_param_kcmdline6,
+	.description = "check if dots on other parts of kcmdline don't confuse our parser",
+	.config = {
+		[TC_UNAME_R] = "4.4.4",
+		[TC_ROOTFS] = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline6",
+	},
+	.output = {
+		.out = TESTSUITE_ROOTFS "test-modprobe/module-param-kcmdline6/correct.txt",
+	},
+	.modules_loaded = "",
+	);
+
+
 static noreturn int modprobe_force(const struct test *t)
 {
 	const char *progname = ABS_TOP_BUILDDIR "/tools/modprobe";
-- 
2.25.1


  reply	other threads:[~2020-03-10  8:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-10  8:23 [PATCH 1/2] libkmod: ignore kcmdline option if we fail to parse modname Lucas De Marchi
2020-03-10  8:23 ` Lucas De Marchi [this message]
2020-03-23 19:29 ` Lucas De Marchi

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=20200310082308.14318-2-lucas.demarchi@intel.com \
    --to=lucas.demarchi@intel.com \
    --cc=joao.moreira@intel.com \
    --cc=leandro.maciel.dorileo@intel.com \
    --cc=linux-modules@vger.kernel.org \
    --subject='Re: [PATCH 2/2] testsuite: check for ill-formed kcmdline' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).