Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4790853pxk; Wed, 30 Sep 2020 11:45:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6sbu+A5MxPpEvZQnCguiWVu2H11yJ46VwQ8oFhjfD+QkhKLPX+p48g2GAQh+MkuS6dCI2 X-Received: by 2002:aa7:dad8:: with SMTP id x24mr4403643eds.259.1601491509801; Wed, 30 Sep 2020 11:45:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601491509; cv=none; d=google.com; s=arc-20160816; b=LT3O26lAd84Wl6RCF574Nc4AWL2yjygZfPTV5XVdq7hielTWa0pKesM3CagCn8ctRb noVGne5lWvVcMfYj8fHM351jdLiLy5Lvg3ndEXIpmoeFD4MBCFnuxAVbWwRnI2vZQV4E PvzgMTpQYsSQB/kHwAvCqiwFE8Ltrj/cZuRLEkmWufufedRb77nHswAQFldQsDdHTeUa mdhks4NGEPHK4/e6s9ApqB/5Dr9bwRDQh/vMkqtaTIz8f6GBS9eRqsT4bw8DlQRyMdRj IJ/cglUnGRqT4E8dLRbVkIx0wN0KqtY2Pkj3OZf6gS6o/B8jyxoADiCbzT255XLWCQoE c8nA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=rsLJ0WzXNdtQRZFvEJBFtYfUJflO+jzSnIWP8RAdfAk=; b=VLI+BujkbKKgNJ/4/rVrFG54/Ii2req6uVaH26CL6atd22BGLiksbL2hA/9IjnVroo fqcWPnFfJFR7zRKSa4YwEL9TjPHOMmpS8Ww9H2agQLIFKDfyNBVBxNdGBWqZlqQo8bJL gAyHdFwXbY590wZFT5C21/lDwEwzVwpu2aPZvkMy+65XC7psWa9YRXLg+Itz01+oMeH6 nuDfxEm/vrdXCOD6zudv/tUhWv0jkTqYTbrP8xMgfGhPNSAYq3jcog29Cm+2yqzZ024b h5rNAWhTE+2WDFbWtqt5LjSJH1t4arAiTBGK+vrx3/6CHOnSy/PdyYMZYUIg8T3e7wno HTSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XFlKWBXH; 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 h12si2023314ejx.608.2020.09.30.11.44.46; Wed, 30 Sep 2020 11:45:09 -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=XFlKWBXH; 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 S1729954AbgI3SlC (ORCPT + 99 others); Wed, 30 Sep 2020 14:41:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:53234 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729905AbgI3Sk7 (ORCPT ); Wed, 30 Sep 2020 14:40:59 -0400 Received: from localhost.localdomain (c-98-220-232-140.hsd1.il.comcast.net [98.220.232.140]) (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 AB4D62084C; Wed, 30 Sep 2020 18:40:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601491259; bh=R7XcLTABR3RPd0xjQRsJsPFqlytRfHg58eu8nKQza/k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=XFlKWBXHg4Y35VhgjXJibKAwFPlbRq0tXzaEnlY7HQIFyx5C+HD2e/fkfcSJ9cP69 C6IeWW5T+nUTVkSi8Y430FCv/XX0fQqvIMEmM9AcJJ3EYEUAP5yILPK9GuOt6QO8MD yqIbILoIotX21w4lK7hGYvqu2BGSaOfawgIc2ZD8= From: Tom Zanussi To: rostedt@goodmis.org, axelrasmussen@google.com Cc: mhiramat@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/3] tracing: Fix parse_synth_field() error handling Date: Wed, 30 Sep 2020 13:40:51 -0500 Message-Id: <15b1808e1466f378fcf206e61b57c802423f8319.1601490263.git.zanussi@kernel.org> 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 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 ] Signed-off-by: Tom Zanussi --- 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 a9cd7793f7ea..fa8a99828f41 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.17.1