From: Lucas De Marchi <lucas.demarchi@intel.com>
To: linux-modules@vger.kernel.org
Cc: James Minor <james.minor@ni.com>,
julia.cartwright@ni.com, zach.brown@ni.com, ken.sharp@ni.com
Subject: [PATCH 2/2] libkmod-config: fix parsing quoted kernel cmdline on params
Date: Thu, 16 Feb 2017 09:28:31 -0800 [thread overview]
Message-ID: <20170216172831.3019-2-lucas.demarchi@intel.com> (raw)
In-Reply-To: <20170216172831.3019-1-lucas.demarchi@intel.com>
We can only accept quoted values, not module names or parameter names.
---
libkmod/libkmod-config.c | 14 ++++++++++++++
.../test-modprobe/module-param-kcmdline5/proc/cmdline | 2 +-
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/libkmod/libkmod-config.c b/libkmod/libkmod-config.c
index 18f300a..aaac0a1 100644
--- a/libkmod/libkmod-config.c
+++ b/libkmod/libkmod-config.c
@@ -517,10 +517,24 @@ static int kmod_config_parse_kcmdline(struct kmod_config *config)
for (p = buf, modname = buf; *p != '\0' && *p != '\n'; p++) {
if (*p == '"') {
is_quoted = !is_quoted;
+
+ if (is_quoted) {
+ /* don't consider a module until closing quotes */
+ is_module = false;
+ } else if (param != NULL && value != NULL) {
+ /*
+ * If we are indeed expecting a value and
+ * closing quotes, then this can be considered
+ * a valid option for a module
+ */
+ is_module = true;
+ }
+
continue;
}
if (is_quoted)
continue;
+
switch (*p) {
case ' ':
*p = '\0';
diff --git a/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline5/proc/cmdline b/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline5/proc/cmdline
index 0c796b3..84e0168 100644
--- a/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline5/proc/cmdline
+++ b/testsuite/rootfs-pristine/test-modprobe/module-param-kcmdline5/proc/cmdline
@@ -1 +1 @@
-psmouse.foo psmouse.bar=1 psmouse.foobar="test 1" " notamodule" "noteamodule2 " notamodule3 " quiet rw
+psmouse.foo psmouse.bar=1 psmouse.foobar="test 1" psmouse."invalid option" " notamodule" "noteamodule2 " notamodule3 quiet rw
--
2.9.3
next prev parent reply other threads:[~2017-02-16 17:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-16 17:28 [PATCH 1/2] libkmod-config: replace 0/1 with bool Lucas De Marchi
2017-02-16 17:28 ` Lucas De Marchi [this message]
2017-02-23 22:14 ` [PATCH 2/2] libkmod-config: fix parsing quoted kernel cmdline on params 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=20170216172831.3019-2-lucas.demarchi@intel.com \
--to=lucas.demarchi@intel.com \
--cc=james.minor@ni.com \
--cc=julia.cartwright@ni.com \
--cc=ken.sharp@ni.com \
--cc=linux-modules@vger.kernel.org \
--cc=zach.brown@ni.com \
/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;
as well as URLs for NNTP newsgroup(s).