Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp893131ybe; Wed, 4 Sep 2019 09:15:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqzVghU4IEeLLzEBD3G8K5doqRGr3cCJAl9ck7w22SSiW5S2/E1HRDhYbrbH+oh40hQ903Q4 X-Received: by 2002:a62:7684:: with SMTP id r126mr15312157pfc.26.1567613744903; Wed, 04 Sep 2019 09:15:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567613744; cv=none; d=google.com; s=arc-20160816; b=An7agtOk6trACvET/hW66ArMS3XaCRvbVR0RW9Qi+MxKeuxzkhh+Ll6Xj6Rx0Bk1Vn W6WFqJvlBNsG/ahJJTGIabceNzVZIgn3wA/oN3JRwt2VHOMldkqt0Ntr+49e0E/8D5M3 rWrZLGgxtT+4g8JI/IYxycfYHlqRgfFwUtbMCbnpQArw7ezcjuAekrgcVRmc5a2iCjYc aqWqF+0W2hCnorVOcad8iBuQ6EfTtbGClFTXUMxUkFrPmLX+QpbxsflXUjU1Tj8LXMm4 KN0lL1KDhpEB+ZIwZdR49OxAJMx0CcZEpkrAYp6HHbQHdyZbNwifXy1U5r6dfOOPxehk I/Tw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZR0XDsEkODQWqg/UInVJzISIowkDIVbCl/ZUktnmuqY=; b=neCcO+kh4+au0JiNxnBYeS0IMZPxq5lUvpFKnjUGl3TMSIYTHqrj8R9GMXItd8Riaz aT5uKALKwV7VAJB+5hlksRbyilMXFgkfxHqfC7YCGj71z5JLw0bZ3HYiTR1Y7SxQ5FyN JFn3hY65+IsUhMmT5rXlJzFgF/C1VVzUqkHY2OcFW52+KCAIF0lmubEbjYxm6laexqnm PWDBr/5t5l4CjaxOzA7n+M4GOFMBYh21nZexQU3b135UVQxluCyNSVAnDG9DgTaygQuK pYlKVzmB9Pxqg60zjkkT/N3QEbrr/jfPKL9x/kfZ15vkJVls0Nwd1iqjL7m2MPFyKeIR jQBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=X7ZHcs1L; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x126si17925060pgx.356.2019.09.04.09.15.28; Wed, 04 Sep 2019 09:15:44 -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=X7ZHcs1L; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387552AbfIDQOg (ORCPT + 99 others); Wed, 4 Sep 2019 12:14:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:34318 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732449AbfIDP7q (ORCPT ); Wed, 4 Sep 2019 11:59:46 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C1B5F2070C; Wed, 4 Sep 2019 15:59:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567612785; bh=iqudMozqhnICU8g0jgukQ+85UGagEzqQzHuZp5btJuM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X7ZHcs1L8E+k3SmfO8/lb7RjSD8rL15GsuxRA+n16VN5WyxOp2VChAAHIS4ls6AhH iu9vOzAJTf2eXyX/2gY5b78SZVJG7WJi4ssIfBuDfJ8EZM7R7Skaq+SKFor8bXpt8X BnFU6/9h+YsKoZEY8vPtF6CrGW+FBouoBa3H2Zks= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: "Zephaniah E. Loss-Cutler-Hull" , Len Brown , Sasha Levin Subject: [PATCH AUTOSEL 5.2 80/94] tools/power x86_energy_perf_policy: Fix argument parsing Date: Wed, 4 Sep 2019 11:57:25 -0400 Message-Id: <20190904155739.2816-80-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190904155739.2816-1-sashal@kernel.org> References: <20190904155739.2816-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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 7663abef51e96..3fe1eed900d41 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 @@ -545,7 +545,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