From patchwork Tue Oct 27 13:50:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 289585 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=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, 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 27077C838B1 for ; Tue, 27 Oct 2020 15:47:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D108D2240C for ; Tue, 27 Oct 2020 15:47:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603813666; bh=C7nuvz4TG+LNYVNN2IN49Nn4dau9vcjWBJL1Ux15x9Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=hsCEdCtVAqajJkjqzcf46ylVYLHmk73Ty9yX4EnKv5O4mRxtDlCYW6sWoaWYlLooi jiLmwOO8q0/EAWWnolfrLWahzBpM6Xvn5JKfAsRHHID3xcKcN9cF1hyFdPp2OsjtcI +4WJ0ZiD8o56/YZsICm4g1P/qra6N6fJFNAhCxwI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1802135AbgJ0Ppo (ORCPT ); Tue, 27 Oct 2020 11:45:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:55764 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1800768AbgJ0Pgx (ORCPT ); Tue, 27 Oct 2020 11:36:53 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 48F602064B; Tue, 27 Oct 2020 15:36:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603813011; bh=C7nuvz4TG+LNYVNN2IN49Nn4dau9vcjWBJL1Ux15x9Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jXmrhD/CYfmuOIiFY1VoProoZPytFVcZNp79TgOIr7thYRVzcvUnXyi0/urClr4zE kd+BUq1yl4l2zYokZ28s6JG8wJ3mWXQOkn/p4UjK0n+Twh8Do6WR2WwCPmSc8npi9S Cc4a4FqLltP5CzqPK+P8xr8V9TkT2s4Lj0fIV440= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masami Hiramatsu , Axel Rasmussen , Tom Zanussi , "Steven Rostedt (VMware)" , Sasha Levin Subject: [PATCH 5.9 377/757] tracing: Fix parse_synth_field() error handling Date: Tue, 27 Oct 2020 14:50:27 +0100 Message-Id: <20201027135508.235308940@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135450.497324313@linuxfoundation.org> References: <20201027135450.497324313@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Tom Zanussi [ Upstream commit 8fbeb52a598c7ab5aa603d6bb083b8a8d16d607a ] synth_field_size() returns either a positive size or an error (zero or a negative value). However, the existing code assumes the only error value is 0. It doesn't handle negative error codes, as it assigns directly to field->size (a size_t; unsigned), thereby interpreting the error code as a valid size instead. Do the test before assignment to field->size. [ axelrasmussen@google.com: changelog addition, first paragraph above ] Link: https://lkml.kernel.org/r/9b6946d9776b2eeb43227678158196de1c3c6e1d.1601848695.git.zanussi@kernel.org Fixes: 4b147936fa50 (tracing: Add support for 'synthetic' events) Reviewed-by: Masami Hiramatsu Tested-by: Axel Rasmussen Signed-off-by: Tom Zanussi Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Sasha Levin --- kernel/trace/trace_events_synth.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/trace/trace_events_synth.c b/kernel/trace/trace_events_synth.c index c6cca0d1d5840..46a96686e93c6 100644 --- a/kernel/trace/trace_events_synth.c +++ b/kernel/trace/trace_events_synth.c @@ -465,6 +465,7 @@ static struct synth_field *parse_synth_field(int argc, const char **argv, struct synth_field *field; const char *prefix = NULL, *field_type = argv[0], *field_name, *array; int len, ret = 0; + ssize_t size; if (field_type[0] == ';') field_type++; @@ -520,11 +521,12 @@ static struct synth_field *parse_synth_field(int argc, const char **argv, field->type[len - 1] = '\0'; } - field->size = synth_field_size(field->type); - if (!field->size) { + size = synth_field_size(field->type); + if (size <= 0) { ret = -EINVAL; goto free; } + field->size = size; if (synth_field_is_string(field->type)) field->is_string = true;