Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp358554ybj; Thu, 19 Sep 2019 15:41:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqyXuvENsw5y1B9g+5gOVOKlMjLR2ILERG1Y3Fz2wtJtfqUYEbbJgmLyUmIt7VcxL4JdKQgI X-Received: by 2002:a05:6402:1251:: with SMTP id l17mr10256127edw.270.1568932908721; Thu, 19 Sep 2019 15:41:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568932908; cv=none; d=google.com; s=arc-20160816; b=MaSPBIK+r8QWDZgTxwAp4V5e8cEZxph7J+azuumEDqrbiF3PiCuwHkEG3BVXTu2AKb Y7VrAnlIYK0cgW/WfI4DNctL7k2sjEmHzm7Tav/7AuCYPmqvt57NYhUth5uzS2LCUZ3W YBM4zAuMvS/SDYIbVXJNiFIvkV1l32daele7mfcYCPFOxsk9KnuwafRQMy1cjD1ZT90r wsUPq1q8AjqkH64Nx7CZ1jDDsCp7WCc//gf43FEg0S7IhN4VRWcyC+uXjPmEwjGh5Zp/ 6CQARAU5IMzb2xd/idOFEpVj+J9ljocvVZKmBdnh/wA3TWI3mIwZkk4x8QrmR/IIKKBB yGWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=hNZQ1F8UYlPLZtNfBEGH0X1sRQFvavr4EGiE8gU8+mY=; b=niAhE37dka1GpuKRvsOxh3y8nk/5aM30Dp6R3SbeXu27HKtnVzxxSMO4/8JWbQ3Zxj nfN/OaspT7GWpwtrEjo/IU/pV1+waqC8VNQ5X8KNOFJkVorz7+u2KQ6y4yrpi9q+GUC+ TSV8SMeWypERF6p+iZCPs1+/pcmS8yhIef9aaR8bwmjHo446mUmGf2HmSuCDVxBDsBKh 6DTGBF5KW/E3ZBvqXcvTmvqKphwpN4FRhVR0uQoi6XFCJsXW0AMOfGal4zuaVV39WA6r UWgtHIJdrssgm3wG8uvzht2vzuzZ7lEhb4C7yj61fZtomeJHX6ojpjlWbITXYpfMxTTe c9lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=utZ62Fcf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j12si1121901ejx.282.2019.09.19.15.41.25; Thu, 19 Sep 2019 15:41:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=utZ62Fcf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2393757AbfISWO2 (ORCPT + 99 others); Thu, 19 Sep 2019 18:14:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:53970 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392247AbfISWO0 (ORCPT ); Thu, 19 Sep 2019 18:14:26 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2F8FB21924; Thu, 19 Sep 2019 22:14:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568931265; bh=Lj7bkb2BiDO38UOg4KwiSGvkPNkyrZAhGxld/8od+KE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=utZ62FcfYjyAVYR5jd/b83l+r7O/NN9KzpC/rutd2nSVV5/OTcS3oK1lPAtjYerHE NybsexMMJ0rMjZbxUlZHgSAwQ8cXyhsOX/A5d2z2OiAIQZUnnVFrusgdP8kOmyVP/k PIKX1Ebk8UoBa+dY4YnCt6wjQyeGLa/FZuGO+K4o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Zephaniah E. Loss-Cutler-Hull" , Len Brown , Sasha Levin Subject: [PATCH 4.19 63/79] tools/power x86_energy_perf_policy: Fix argument parsing Date: Fri, 20 Sep 2019 00:03:48 +0200 Message-Id: <20190919214813.219467702@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190919214807.612593061@linuxfoundation.org> References: <20190919214807.612593061@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zephaniah E. Loss-Cutler-Hull [ Upstream commit 03531482402a2bc4ab93cf6dde46833775e035e9 ] The -w argument in x86_energy_perf_policy currently triggers an unconditional segfault. This is because the argument string reads: "+a:c:dD:E:e:f:m:M:rt:u:vw" and yet the argument handler expects an argument. When parse_optarg_string is called with a null argument, we then proceed to crash in strncmp, not horribly friendly. The man page describes -w as taking an argument, the long form (--hwp-window) is correctly marked as taking a required argument, and the code expects it. As such, this patch simply marks the short form (-w) as requiring an argument. Signed-off-by: Zephaniah E. Loss-Cutler-Hull Signed-off-by: Len Brown Signed-off-by: Sasha Levin --- tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c b/tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c index bbef8bcf44d6d..2aba622d1c5aa 100644 --- a/tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c +++ b/tools/power/x86/x86_energy_perf_policy/x86_energy_perf_policy.c @@ -546,7 +546,7 @@ void cmdline(int argc, char **argv) progname = argv[0]; - while ((opt = getopt_long_only(argc, argv, "+a:c:dD:E:e:f:m:M:rt:u:vw", + while ((opt = getopt_long_only(argc, argv, "+a:c:dD:E:e:f:m:M:rt:u:vw:", long_options, &option_index)) != -1) { switch (opt) { case 'a': -- 2.20.1