From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8ED0EC433DF for ; Mon, 12 Oct 2020 20:18:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5A020216C4 for ; Mon, 12 Oct 2020 20:18:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602533903; bh=/0aBTneVkZoEaETwwf8RMvyDjIipKWOw+WYbAv0Uig8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To: References:List-ID:From; b=ntgzuauuZ0/W1IiWmHmOIv1SA9Dkc0tmzAdgVjPGzrSddfEKJGWjrVNA4caAIuJdd EmyG+jK5OwhKhor8Uxhhg1Qd48syimPo/o/5+5JtxGdbDvKlT6EXWEo9ltOEtRQsm6 DREd7TBsqk6pJyQT1zMeKDTxrLv89cxMVUGhKb/I= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387766AbgJLUSW (ORCPT ); Mon, 12 Oct 2020 16:18:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:55174 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728155AbgJLUSS (ORCPT ); Mon, 12 Oct 2020 16:18:18 -0400 Received: from localhost.localdomain (c-73-209-127-30.hsd1.il.comcast.net [73.209.127.30]) (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 CCC64208D5; Mon, 12 Oct 2020 20:18:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602533898; bh=/0aBTneVkZoEaETwwf8RMvyDjIipKWOw+WYbAv0Uig8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=BQqP6OhqHvC9fRrWH9VR7Uk4T+U2QNPxPnxCPYDX6P9f3DihJI8ZpG+yzUxKfvWr8 KrTzGmpYCiYgecXj2czZrugUqthNPTqroEDIg5EcOe6Q8qfdgMRCAfv9OKFbDTT/LZ f0WaD9Pi3z0bOOCM7OZCvKjOFsO6EOiK3BdH8zdg= From: Tom Zanussi To: rostedt@goodmis.org, axelrasmussen@google.com Cc: mhiramat@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/7] tracing: Check that the synthetic event and field names are legal Date: Mon, 12 Oct 2020 15:18:05 -0500 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: In-Reply-To: References: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Call the is_good_name() function used by probe events to make sure synthetic event and field names don't contain illegal characters and cause unexpected parsing of synthetic event commands. Fixes: 4b147936fa50 (tracing: Add support for 'synthetic' events) Reported-by: Masami Hiramatsu Reviewed-by: Masami Hiramatsu Tested-by: Masami Hiramatsu Signed-off-by: Tom Zanussi --- kernel/trace/trace_events_synth.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/kernel/trace/trace_events_synth.c b/kernel/trace/trace_events_synth.c index b19e2f4159ab..8c9d6e464da0 100644 --- a/kernel/trace/trace_events_synth.c +++ b/kernel/trace/trace_events_synth.c @@ -572,6 +572,10 @@ static struct synth_field *parse_synth_field(int argc, const char **argv, ret = -ENOMEM; goto free; } + if (!is_good_name(field->name)) { + ret = -EINVAL; + goto free; + } if (field_type[0] == ';') field_type++; @@ -1112,6 +1116,11 @@ static int __create_synth_event(int argc, const char *name, const char **argv) mutex_lock(&event_mutex); + if (!is_good_name(name)) { + ret = -EINVAL; + goto out; + } + event = find_synth_event(name); if (event) { ret = -EEXIST; -- 2.17.1