From patchwork Tue Aug 10 17:30:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 494363 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp4185030jap; Tue, 10 Aug 2021 10:48:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwaNxJfTx9y5nEhAN5sb9uRKzelYeISXNCqStXAI1zdJEQ++6NNH3n4rnh2moJ1+PRHCnM0 X-Received: by 2002:a05:6e02:1a8b:: with SMTP id k11mr58276ilv.136.1628617714391; Tue, 10 Aug 2021 10:48:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628617714; cv=none; d=google.com; s=arc-20160816; b=lDg8LwL1zR/BSyouHObzLsuh4+s78pYlTpYDfsw+TuWwaDHr9kmvzOvFFljOAErwKr K01lC6oW8J5J3Lk0zi2xhENr3kmgmYmyisbdgwME9zy7BQGY/djOMtvRs/S/vrJs2HFv NwxBnYTzUZWObVMSZMqe/1rHvbgk0fLPZHc8hIOiOixXAwnP4kEZeGYKc21Txg1UuM+Y Igw2JRfPRvKkmxJzDX9C8XSrHVqMvXJPcIpiEtpfhg7YTUCWewU07apB4jyAMCBBLdvF u/CoQ6NhSV2XVde/uWYJL+zh64AZCbEoppSK1w1eUw40TROWhnYQaHD/bZ5rWa1Q7wta ZB3g== 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=7R0L4mrkWIQLowkgpfvqw0/ABc4KoL4CwayB0awqq0c=; b=TVydejVDnsfHag/YHr2/HYI48Zr4vSERC4Qj7TzXDK+IYD0ZF/+hu9fEueWq5AIrJm CzJPci9cRYiCvnp5l6RPHKufDREdYDGalsimdBSP0YfFjJsjIc3l5yjDayny4vRVXoxp 6Hol8qPqWCitPfjHzjAGLZoPmPAv1vR/RHUbFxhO3xi0W85VGcaLiYt0p72mbb9gwMoI jDz5FTTFcF2/BZ2GXVlnvaM3eFp4oh53QjAG29VtMwo3CbPBXJZ2s65l7IIHxJ1mcvaq 7mpfreLsi8p6j+CCvnjIld3vKTRqRmELZ8PZsu+Ja3aw5l1gEUzLPW2GLvXPhqbQJZBq qXew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Bnrf95Qb; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (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 u15si25082735iot.89.2021.08.10.10.48.33; Tue, 10 Aug 2021 10:48:34 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-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=@linuxfoundation.org header.s=korg header.b=Bnrf95Qb; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230366AbhHJRsy (ORCPT + 12 others); Tue, 10 Aug 2021 13:48:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:53276 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236221AbhHJRq6 (ORCPT ); Tue, 10 Aug 2021 13:46:58 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CB18F61244; Tue, 10 Aug 2021 17:40:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628617245; bh=yGcgg81hQyuFSu2gycDmdWaDhQk87dsk40QNIF5z+fw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bnrf95Qb1Xc19M5hN7csOvl549jdTUJviMve8xZQyqJFEaYF53AjOs887BzNMKziD 0CBIUCy5RvUwSysxwpP4hQdvsyUch43zzlu3ZcqoKOpH526AcpApMdozVYfKGi7I0Z WPTjDm6c7kgXdSRaS2bb6g3g/oMBWVeYqbegJRsw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masami Hiramatsu , "Steven Rostedt (VMware)" Subject: [PATCH 5.10 076/135] tracing: Reject string operand in the histogram expression Date: Tue, 10 Aug 2021 19:30:10 +0200 Message-Id: <20210810172958.310402555@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210810172955.660225700@linuxfoundation.org> References: <20210810172955.660225700@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Masami Hiramatsu commit a9d10ca4986571bffc19778742d508cc8dd13e02 upstream. Since the string type can not be the target of the addition / subtraction operation, it must be rejected. Without this fix, the string type silently converted to digits. Link: https://lkml.kernel.org/r/162742654278.290973.1523000673366456634.stgit@devnote2 Cc: stable@vger.kernel.org Fixes: 100719dcef447 ("tracing: Add simple expression support to hist triggers") Signed-off-by: Masami Hiramatsu Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Greg Kroah-Hartman --- kernel/trace/trace_events_hist.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -65,7 +65,8 @@ C(INVALID_SORT_MODIFIER,"Invalid sort modifier"), \ C(EMPTY_SORT_FIELD, "Empty sort field"), \ C(TOO_MANY_SORT_FIELDS, "Too many sort fields (Max = 2)"), \ - C(INVALID_SORT_FIELD, "Sort field must be a key or a val"), + C(INVALID_SORT_FIELD, "Sort field must be a key or a val"), \ + C(INVALID_STR_OPERAND, "String type can not be an operand in expression"), #undef C #define C(a, b) HIST_ERR_##a @@ -2140,6 +2141,13 @@ static struct hist_field *parse_unary(st ret = PTR_ERR(operand1); goto free; } + if (operand1->flags & HIST_FIELD_FL_STRING) { + /* String type can not be the operand of unary operator. */ + hist_err(file->tr, HIST_ERR_INVALID_STR_OPERAND, errpos(str)); + destroy_hist_field(operand1, 0); + ret = -EINVAL; + goto free; + } expr->flags |= operand1->flags & (HIST_FIELD_FL_TIMESTAMP | HIST_FIELD_FL_TIMESTAMP_USECS); @@ -2241,6 +2249,11 @@ static struct hist_field *parse_expr(str operand1 = NULL; goto free; } + if (operand1->flags & HIST_FIELD_FL_STRING) { + hist_err(file->tr, HIST_ERR_INVALID_STR_OPERAND, errpos(operand1_str)); + ret = -EINVAL; + goto free; + } /* rest of string could be another expression e.g. b+c in a+b+c */ operand_flags = 0; @@ -2250,6 +2263,11 @@ static struct hist_field *parse_expr(str operand2 = NULL; goto free; } + if (operand2->flags & HIST_FIELD_FL_STRING) { + hist_err(file->tr, HIST_ERR_INVALID_STR_OPERAND, errpos(str)); + ret = -EINVAL; + goto free; + } ret = check_expr_operands(file->tr, operand1, operand2); if (ret)