Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp264765pxx; Wed, 28 Oct 2020 04:29:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyBj9BNu2WfH7HpttfOPeyuJ4H1uQoC10ZVM33lctsMqiFFbl4qcqj+Fa0KiTjMlNCKh1FC X-Received: by 2002:a17:906:314d:: with SMTP id e13mr7228270eje.412.1603884556517; Wed, 28 Oct 2020 04:29:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603884556; cv=none; d=google.com; s=arc-20160816; b=MEI3o327vsx20FHphKvKv/I5aPW3Db37pHnvUNs9OnpeANv4zrk9UAXSSwcHumIQcX 1EpVXTb/ryQPRlTejCXEOCGKLBLRHwHM+MjnAP1+I31fQEy3l/bVPzdXvwsLTQ8h7+TD Be/svuKvq0RsKFWpX4Xhk/PiSOkg2olnEbELTRf5Vg+TVT39976rGjOsAdAK+uDMxOt2 ehPFN5jJqXmbulBoxh+sdU4zqdDoSqXRqHRZXVa1L0unJOLDxkb/r8BVQxlpZDPyMUS0 pbvkCN11LfL4rSzlwzHVzuESeo0jIjgcmUkYxB3MB4guhhOYcEYnH8xf1ypgGO6QJd0o 0xOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ALVkh6TSdMGL8Vi/usScWn3OulLf62ky0qbOgDJYZ+E=; b=PjA5xcx0Cej0/QGzyDW0190wwIzLehrHvgx9i9Ai9xBH9kwiBSwza7uCaakuHgjpKt 33ndM+SXwxoBY9slH8E3dnke1Tz6NJXXp+FHk/qmpT62Ixb/NVbq82H2ZgKersPvHY28 hzniCFBaIGeoeQTxYfEsEMqZBVf718SqxKb3mwtMY6cfCY0+Ga7OBh+RsijWqWXm6G6g u7qa5i23ni3befBD4bJ6exIbc8RWtY2xUKOlfr1gQv24dPHR8txQGShB7X2z5z43CIYS Xc8SqBtc+DBAxV+VhQIj/mt1AcrwQ3yyLgTQiV2CZ8qoAqRqcdWXbL9lXY5JxruGxE3K 2fYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EmCgKomS; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bs17si3022913ejb.543.2020.10.28.04.28.54; Wed, 28 Oct 2020 04:29:16 -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=EmCgKomS; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1793559AbgJ0PHH (ORCPT + 99 others); Tue, 27 Oct 2020 11:07:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:36046 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1789372AbgJ0PCD (ORCPT ); Tue, 27 Oct 2020 11:02:03 -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 5367022284; Tue, 27 Oct 2020 15:01:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603810920; bh=C7nuvz4TG+LNYVNN2IN49Nn4dau9vcjWBJL1Ux15x9Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EmCgKomSHZeBS8+fxYSejpnteoQwFIv9IYr4zJHso15PQeY0x9RiWFUpxsjq1J/0D 6bYNu4F/rArKTdo4mQ/sRV0AreDG7D1L72hnoh/l06vCHO0hnw/40QykKhBlPsH9+0 jYC+8hdp/qGERqFuC9VyF7/e6ww4zknQQxvbhCE4= 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.8 308/633] tracing: Fix parse_synth_field() error handling Date: Tue, 27 Oct 2020 14:50:51 +0100 Message-Id: <20201027135537.125990296@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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; -- 2.25.1