From patchwork Thu Feb 16 17:28:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lucas De Marchi X-Patchwork-Id: 9577785 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8C86660209 for ; Thu, 16 Feb 2017 17:28:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7F62B28628 for ; Thu, 16 Feb 2017 17:28:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 741392864F; Thu, 16 Feb 2017 17:28:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2724428628 for ; Thu, 16 Feb 2017 17:28:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754770AbdBPR2s (ORCPT ); Thu, 16 Feb 2017 12:28:48 -0500 Received: from mga06.intel.com ([134.134.136.31]:32024 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932793AbdBPR2d (ORCPT ); Thu, 16 Feb 2017 12:28:33 -0500 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP; 16 Feb 2017 09:28:31 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,169,1484035200"; d="scan'208";a="1128476530" Received: from ldmartin-desk.jf.intel.com ([10.24.10.235]) by fmsmga002.fm.intel.com with ESMTP; 16 Feb 2017 09:28:31 -0800 From: Lucas De Marchi To: linux-modules@vger.kernel.org Cc: James Minor , 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 Message-Id: <20170216172831.3019-2-lucas.demarchi@intel.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170216172831.3019-1-lucas.demarchi@intel.com> References: <20170216172831.3019-1-lucas.demarchi@intel.com> Sender: owner-linux-modules@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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