Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3083110ybt; Mon, 29 Jun 2020 14:55:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxo/5oLg8IoJWfPhrC+jvpo25m4kpWYmU4uXQBVbTyA96ncX5LwFNYlPC8EDwkAMqLUjhOt X-Received: by 2002:a50:b941:: with SMTP id m59mr19467059ede.321.1593467703143; Mon, 29 Jun 2020 14:55:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593467703; cv=none; d=google.com; s=arc-20160816; b=yo5dRNysoY0ujFrwRve0WSZ35nwgJNrzVPdrIMoAONxmrigrKumlmKrqzEZxlbCKlZ AvfM82zcycmxIGNIgNJzbZUY8ypoquZJpziMnle+aT3Fy0ezKcCdAy8KSZEmD/pb1bPG xWT2QB5KuGmBSrao12DAa+TY54nnVSKIkiTF2HabXovq6Wt+hed0K6xLXU6oevKb2xot t6+K7HIA7n8sKHz9fTlki06KHj3dlyloFWLzwEs7gfCjQf3qXnZLNhrH6FqLvq4pi+gm iWJnOhR2bk1o8PVmDZpbeonRW0YCLSXCBBrcz4o1zQZdc0LQOdUXH1m57VpwVnbNJz6c 1bpw== 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=re6Q2Sr2Fw8L3AyFGBzt4OXeNE7MXDld13LDWgVW/FY=; b=C16yVKhfmTEIOAsxxYaoXYni/ghzqx8mXAx+naIkDRYi2LKrDKrjYagNb8rNGQUXBN +QTRpGjerz1C2rOuv0/kMJk27l0R8HS1anBxAPy2y3VimP8OoVtyyyVeGe6gzms3UPb0 UDi630JDTlHMMpcBPQy6KR9aJ7ca8WOjTdVNfNYTefH0xCpOu64A3Xtluu/QbKpIyryz UzB/rsO58n6EpOXgVsc7iZXDt92zWj7ciJCQJS3xMZsDfZmcqPS0f1W3mWjFQ4p6xauJ HuQbc1HFE6yvcRSbvXq581ZkxhmrGbHsQXyHZsPOaW9sjeVSPXombIwTTxMIqQnT7EWn WO7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XH8p8jSR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id g2si508364ejd.657.2020.06.29.14.54.40; Mon, 29 Jun 2020 14:55:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XH8p8jSR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S2391511AbgF2Vw1 (ORCPT + 99 others); Mon, 29 Jun 2020 17:52:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:56764 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726630AbgF2Sfj (ORCPT ); Mon, 29 Jun 2020 14:35:39 -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 3B9A4247CA; Mon, 29 Jun 2020 15:22:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593444135; bh=MouZSTVrUh0LDNHZw9RYHNyEcfZHloCjp7rQlYscy9Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XH8p8jSRkJ+jfTF/dRoMV6i2WLIPNkNjiW7oRa2V2DRgVBMcXyfGrNj2A7BG//0zF x+XA3PpESEFIp0IUfQq6R666UI6VQK0ikQ+UvNMNDAEQMIRlqcdkYhqIxllQO0chAu gliNhtui64tM8f3VIDp/IGindt7PfRMkuBM0dwAA= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Masami Hiramatsu , Tom Zanussi , Steven Rostedt , Greg Kroah-Hartman Subject: [PATCH 5.7 242/265] tracing: Fix event trigger to accept redundant spaces Date: Mon, 29 Jun 2020 11:17:55 -0400 Message-Id: <20200629151818.2493727-243-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200629151818.2493727-1-sashal@kernel.org> References: <20200629151818.2493727-1-sashal@kernel.org> MIME-Version: 1.0 X-KernelTest-Patch: http://kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.7.7-rc1.gz X-KernelTest-Tree: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git X-KernelTest-Branch: linux-5.7.y X-KernelTest-Patches: git://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git X-KernelTest-Version: 5.7.7-rc1 X-KernelTest-Deadline: 2020-07-01T15:14+00:00 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: Masami Hiramatsu commit 6784beada631800f2c5afd567e5628c843362cee upstream. Fix the event trigger to accept redundant spaces in the trigger input. For example, these return -EINVAL echo " traceon" > events/ftrace/print/trigger echo "traceon if common_pid == 0" > events/ftrace/print/trigger echo "disable_event:kmem:kmalloc " > events/ftrace/print/trigger But these are hard to find what is wrong. To fix this issue, use skip_spaces() to remove spaces in front of actual tokens, and set NULL if there is no token. Link: http://lkml.kernel.org/r/159262476352.185015.5261566783045364186.stgit@devnote2 Cc: Tom Zanussi Cc: stable@vger.kernel.org Fixes: 85f2b08268c0 ("tracing: Add basic event trigger framework") Reviewed-by: Tom Zanussi Signed-off-by: Masami Hiramatsu Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Greg Kroah-Hartman --- kernel/trace/trace_events_trigger.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/kernel/trace/trace_events_trigger.c b/kernel/trace/trace_events_trigger.c index 3a74736da363a..f725802160c0b 100644 --- a/kernel/trace/trace_events_trigger.c +++ b/kernel/trace/trace_events_trigger.c @@ -216,11 +216,17 @@ static int event_trigger_regex_open(struct inode *inode, struct file *file) int trigger_process_regex(struct trace_event_file *file, char *buff) { - char *command, *next = buff; + char *command, *next; struct event_command *p; int ret = -EINVAL; + next = buff = skip_spaces(buff); command = strsep(&next, ": \t"); + if (next) { + next = skip_spaces(next); + if (!*next) + next = NULL; + } command = (command[0] != '!') ? command : command + 1; mutex_lock(&trigger_cmd_mutex); @@ -630,8 +636,14 @@ event_trigger_callback(struct event_command *cmd_ops, int ret; /* separate the trigger from the filter (t:n [if filter]) */ - if (param && isdigit(param[0])) + if (param && isdigit(param[0])) { trigger = strsep(¶m, " \t"); + if (param) { + param = skip_spaces(param); + if (!*param) + param = NULL; + } + } trigger_ops = cmd_ops->get_trigger_ops(cmd, trigger); @@ -1368,6 +1380,11 @@ int event_enable_trigger_func(struct event_command *cmd_ops, trigger = strsep(¶m, " \t"); if (!trigger) return -EINVAL; + if (param) { + param = skip_spaces(param); + if (!*param) + param = NULL; + } system = strsep(&trigger, ":"); if (!trigger) -- 2.25.1