From patchwork Fri Aug 13 15:07:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 496572 Delivered-To: patch@linaro.org Received: by 2002:a02:cf8a:0:0:0:0:0 with SMTP id w10csp656871jar; Fri, 13 Aug 2021 08:13:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycj+21jBjgd1c3GLl09AAF4X5ik3BsYxlbpddYt7pBFgdMrGvxxG1zgUWWbukp9dyoWm9z X-Received: by 2002:a17:906:7302:: with SMTP id di2mr2874956ejc.409.1628867619826; Fri, 13 Aug 2021 08:13:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628867619; cv=none; d=google.com; s=arc-20160816; b=gqu0/UKlodT9T0DEZ54QmecVNAZkMRMaW3S5JMz8D33icgl/XahvhO67H2dPfaMzQW zPfaqkQyNkdGRIwv4CFk5/XXsaODRmRV13fH/ncp/QrlyjW5vxMNgHFxOq+cUyjhN5bF dBAlgb+sOX0fj/YyC5vhSyh8RgY1G78tll5ENd7CaMowbA9dbXX+TJHa+ihn4CyVFn7u WRxcw5oM3L/PRr97wVzUqRi0VhmnzKTpwBJ7tGfZwsGaSTpUeuxZdUu70i15Vb7YRtS2 hBKy15wu1ZszMrt63kcCyPQKsZ5CZ5z6ZDcoHAHjdaudwIw7+WSW20McR4yZOIdkHrma wnoA== 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=VYud6tlDOGtl7zJeUQeTouibkUiCCyKjC4wxnU7HPB4=; b=URR5ko2oWHe8h313qBIUaSL1glUqko0P3KATagi6WWMni+O+pX8TbBTUt0nEay0hfF FtSRWKT01UcjtkWShRiBYcm7/QaJSybMgORYk21kzndgQf89ueY5DE7M+gkx8d6DWuXD m5zps8NI1PA9YeNOrApxEhX4smjMt37bu3cca1olczn95LIgrNRZ4+S2EOOgFj3jWvjO rgQL9Vix67m42TL+MQqxblCDGh91Xn4DGglHsmfD9qVFylK3dCANaD4upIi/GfeQcvN/ q3EhLTY4DRRmkpyoveXRWje3oqF1ecDeOtKEjG880qnm2E69dONflESBTUUvlH+1JyB3 cYLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="zd/q27fg"; 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 y19si1901783ejp.323.2021.08.13.08.13.39; Fri, 13 Aug 2021 08:13:39 -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="zd/q27fg"; 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 S242329AbhHMPOD (ORCPT + 12 others); Fri, 13 Aug 2021 11:14:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:56080 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241552AbhHMPM6 (ORCPT ); Fri, 13 Aug 2021 11:12:58 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B396C6109D; Fri, 13 Aug 2021 15:12:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628867550; bh=Od52IXyvexugMwGfpdEaOiKHyUAvu2kaZiXPFGgZKIA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zd/q27fgANW/okYHqz0sjurhqdqpYkhAAHC73iMUwOQsbbOOMiEUoSvhgUG508Ftl J0GmDhTKix7dSZ+QAP2vy3heLlvJlJLg+XhybewphXIbkh/tuGwLDXmWYRxn0j5Hjf SNekIev4wgur+LOmlOWEVEBEvt54rmC6U77aZEvU= 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 4.19 02/11] tracing: Reject string operand in the histogram expression Date: Fri, 13 Aug 2021 17:07:09 +0200 Message-Id: <20210813150520.153341889@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210813150520.072304554@linuxfoundation.org> References: <20210813150520.072304554@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 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -2790,6 +2790,12 @@ 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. */ + destroy_hist_field(operand1, 0); + ret = -EINVAL; + goto free; + } expr->flags |= operand1->flags & (HIST_FIELD_FL_TIMESTAMP | HIST_FIELD_FL_TIMESTAMP_USECS); @@ -2890,6 +2896,10 @@ static struct hist_field *parse_expr(str operand1 = NULL; goto free; } + if (operand1->flags & HIST_FIELD_FL_STRING) { + ret = -EINVAL; + goto free; + } /* rest of string could be another expression e.g. b+c in a+b+c */ operand_flags = 0; @@ -2899,6 +2909,10 @@ static struct hist_field *parse_expr(str operand2 = NULL; goto free; } + if (operand2->flags & HIST_FIELD_FL_STRING) { + ret = -EINVAL; + goto free; + } ret = check_expr_operands(operand1, operand2); if (ret)