From patchwork Fri Jan 20 23:15:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Minor X-Patchwork-Id: 9529707 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 5EE90601AE for ; Fri, 20 Jan 2017 23:16:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 68BE6286C1 for ; Fri, 20 Jan 2017 23:16:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A5B5286F0; Fri, 20 Jan 2017 23:16:15 +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 E300F286C1 for ; Fri, 20 Jan 2017 23:16:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752292AbdATXQO (ORCPT ); Fri, 20 Jan 2017 18:16:14 -0500 Received: from skprod3.natinst.com ([130.164.80.24]:55558 "EHLO ni.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751201AbdATXQN (ORCPT ); Fri, 20 Jan 2017 18:16:13 -0500 Received: from us-aus-exhub2.ni.corp.natinst.com (us-aus-exhub2.ni.corp.natinst.com [130.164.68.32]) by us-aus-skprod3.natinst.com (8.15.0.59/8.15.0.59) with ESMTPS id v0KNG7k6027483 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Fri, 20 Jan 2017 17:16:07 -0600 Received: from us-aus-exhub2.ni.corp.natinst.com (130.164.68.32) by us-aus-exhub2.ni.corp.natinst.com (130.164.68.32) with Microsoft SMTP Server (TLS) id 15.0.1156.6; Fri, 20 Jan 2017 17:16:07 -0600 Received: from kal9064.amer.corp.natinst.com (130.164.49.7) by us-aus-exhub2.ni.corp.natinst.com (130.164.68.32) with Microsoft SMTP Server id 15.0.1156.6 via Frontend Transport; Fri, 20 Jan 2017 17:16:07 -0600 From: James Minor To: CC: , , , James Minor Subject: [RFC v1] libkmod: Fix handling of quotes in kernel command line Date: Fri, 20 Jan 2017 17:15:50 -0600 Message-ID: <1484954150-12831-1-git-send-email-james.minor@ni.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-01-20_14:, , signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1701200297 Sender: owner-linux-modules@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP If a module parameter on the command line contains quotes, any spaces inside those quotes should be included as part of the parameter. Signed-off-by: James Minor --- libkmod/libkmod-config.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libkmod/libkmod-config.c b/libkmod/libkmod-config.c index 19f56a7..0596025 100644 --- a/libkmod/libkmod-config.c +++ b/libkmod/libkmod-config.c @@ -497,6 +497,7 @@ static int kmod_config_parse_kcmdline(struct kmod_config *config) char buf[KCMD_LINE_SIZE]; int fd, err; char *p, *modname, *param = NULL, *value = NULL, is_module = 1; + bool is_quoted = false; fd = open("/proc/cmdline", O_RDONLY|O_CLOEXEC); if (fd < 0) { @@ -514,6 +515,12 @@ 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; + continue; + } + if (is_quoted) + continue; switch (*p) { case ' ': *p = '\0';