Received: by 10.192.165.156 with SMTP id m28csp2083711imm; Thu, 12 Apr 2018 08:20:35 -0700 (PDT) X-Google-Smtp-Source: AIpwx48cIW8E29Cx7sGuDVOqmvPdZytfBC/jLji26YVvM3D0BqbBEdrhae3KHFih/WMNPx32wtLD X-Received: by 2002:a17:902:e5:: with SMTP id a92-v6mr1509945pla.26.1523546435511; Thu, 12 Apr 2018 08:20:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523546435; cv=none; d=google.com; s=arc-20160816; b=ydRkexhXHTK6gz3Y4CZF8eZPQjxvWdJg812ylUs94BReQhXqtQ8CrKY+X02RgHSCj5 P/CRCJSl6h/Iyh2IsEZ2tytd8t6f8hgAC5WJh6AIVysjfEMUcnzKDf2a0F9Rm1R9drET yRao5URZ1V90yg9cfxUJ4jdkazca8m0YHKzKP78tDDKuiq7lBPcZOAIcimwkyXUM6ccY T/43k1NWUCLH+L981EPLm/e5apCsBNhAFhu6GsctwC2oPYr/YB04A6b+LThJHtwBm5RO wRfvvkSUrGd87PIwTuwMspKZGawDCY7HxtLJ1383oBat/StFcpmKT6MbumQjZKJWyofn CPGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Rke1QNRmeNuLMP55oE6H+HzJl017VoYyR/BB+v/g4rk=; b=IW6RPtyZSodt8Hif8KrWFr69pGl1TYskaYnWs71uNJeYEEtXKKKikw7Fpo5uyQwhXk DOtS5K0LXlD0/GN9ikIQaZz+SLvGgZCYVCpy5BUC4ZtMEVaUuY5Y4ZwX/NFE1XKrx/kp PHSEEB9pCg2AXOaHea+IAuUS5ekyIi2CnHaBVowpldvk8cbCfPEmjoyrdUCcDx6DtmoN iqO4bORcezftfWi+ZSFnwk17PvT0mUB/wQOerkjnFUzK8aVQLm1OqPOXHu6y9ZiBaDWo xirAlsx0N4eHgVKwLCxFU8JHT3TprKmhNxG0s9oPiG3EeWv5K7PIy7imUTc13FfZFcq+ rcKA== ARC-Authentication-Results: i=1; mx.google.com; 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 i3-v6si3325320pld.241.2018.04.12.08.19.58; Thu, 12 Apr 2018 08:20:35 -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; 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 S1753971AbeDLPPW (ORCPT + 99 others); Thu, 12 Apr 2018 11:15:22 -0400 Received: from mga09.intel.com ([134.134.136.24]:48714 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753051AbeDLPNq (ORCPT ); Thu, 12 Apr 2018 11:13:46 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Apr 2018 08:13:45 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,442,1517904000"; d="scan'208";a="41494310" Received: from cbeckton-mobl.amr.corp.intel.com (HELO localhost) ([10.255.230.227]) by FMSMGA003.fm.intel.com with ESMTP; 12 Apr 2018 08:13:43 -0700 From: Tom Zanussi To: rostedt@goodmis.org Cc: tglx@linutronix.de, mhiramat@kernel.org, namhyung@kernel.org, vedang.patel@intel.com, bigeasy@linutronix.de, joel.opensrc@gmail.com, joelaf@google.com, mathieu.desnoyers@efficios.com, baohong.liu@intel.com, rajvi.jingar@intel.com, julia@ni.com, fengguang.wu@intel.com, linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org, Tom Zanussi Subject: [PATCH 5/6] tracing: Add field parsing trace event errors for hist triggers Date: Thu, 12 Apr 2018 10:13:20 -0500 Message-Id: <6182020d231aa51485e7fc12441527d3709cad06.1523545519.git.tom.zanussi@linux.intel.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Log errors to the tracing/events/error_log for nonexistent fields and modifiers specified in hist triggers. Also screen out variable references, which shouldn't be looked up as fields. Signed-off-by: Tom Zanussi Reported-by: Masami Hiramatsu --- kernel/trace/trace_events_hist.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c index 08424ff..d223fd6 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -2461,6 +2461,7 @@ static struct hist_field *parse_var_ref(struct hist_trigger_data *hist_data, else if (strcmp(modifier, "usecs") == 0) *flags |= HIST_FIELD_FL_TIMESTAMP_USECS; else { + log_err("Invalid field modifier: %s", modifier); field = ERR_PTR(-EINVAL); goto out; } @@ -2476,6 +2477,7 @@ static struct hist_field *parse_var_ref(struct hist_trigger_data *hist_data, else { field = trace_find_event_field(file->event_call, field_name); if (!field || !field->size) { + log_err("Couldn't find field: %s", field_name); field = ERR_PTR(-EINVAL); goto out; } @@ -2553,6 +2555,11 @@ static struct hist_field *parse_atom(struct hist_trigger_data *hist_data, } else str = s; + if (is_var_ref(str)) { + ret = -EINVAL; + goto out; + } + field = parse_field(hist_data, file, str, flags); if (IS_ERR(field)) { ret = PTR_ERR(field); -- 1.9.3