From patchwork Wed Aug 11 07:39:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Masami Hiramatsu \(Google\)" X-Patchwork-Id: 495150 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp4716478jap; Wed, 11 Aug 2021 00:39:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9fieqdYKR26QJ6heNTnrbScNRkJEH0Zgn/uCLJeMfmaOhWgXRVEfbL2cAx+Fd+dpcqtO7 X-Received: by 2002:a05:6e02:1561:: with SMTP id k1mr71767ilu.25.1628667590608; Wed, 11 Aug 2021 00:39:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628667590; cv=none; d=google.com; s=arc-20160816; b=Y4RYKp7VfAgBwDCAbReE5Gb7JT1OHtdxvx10LmnnmwyQ5a2bm+TW6iphOjNkt6jnD9 Lyd8++QYw0SphuLkZxTpzFwflYehOaz+j8/r3hdup+gyUIVeAC+jVs+ygrkqZwmOBWtJ zISdawQ8uWhYohTkEs1nBUOp0xWt6pD39sph2cT8HeSQWQQPd+7zDN848HlKrhiFbyS+ CGTzPtLD/mSMcxppXXILYqpsFr9VrE7TgM5JQzr+nJzhIKv8yJwmJZbuNpsSIWlxdtAu E+aZP1m92bIqR+FVZXzle30ymivfA+3kSHCAP8z4p6TPf8FW8gOjqkEWL4XswHcv4AVi UkYg== 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=Q+uMRUoNirz+BocHnik+tG40HXsESM7Q9RTDCfaNhZw=; b=WMZS7Ty+CFHF0kyszXo7mKI5in2Q5D0tly79+8fH1KlBgtmcULGVL7hU2fu6M3hVZp X/bcJr1cDGhB2HZ0zug9ILuJcClaegjqAxEvYBsQzMcxHteDNmCVG8jJ4IOc+NSF1IvI Mmu528sIHG2IuHrCejAODW1AgORuLJ/dBOayx2i0YFwX49BUp01NgjvO4PIIvsvFvzZe /ysQy4/fgRWpUBQWa3b8Nhb4KInMk14XZ0VLg69QA4qVXjI066JalLU7U65p7Vo5OjI3 8octoMrjDFH2PJI2afHirF0nTqpKpvAjVcmbi9b7bwl72AsPmoKqb4UWpO6qI6uuU/tO yHMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UysuxZin; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q7si26992695ilu.111.2021.08.11.00.39.50; Wed, 11 Aug 2021 00:39:50 -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=@kernel.org header.s=k20201202 header.b=UysuxZin; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235687AbhHKHkM (ORCPT + 12 others); Wed, 11 Aug 2021 03:40:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:53828 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235491AbhHKHkL (ORCPT ); Wed, 11 Aug 2021 03:40:11 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8C9086056B; Wed, 11 Aug 2021 07:39:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1628667588; bh=xEewjdDdfE0mxlx8ul99HQBHj3kH3dks4WnvkOwjcEk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UysuxZinq96f0aDMySjvO+TQYL7grnpKjqaJel6DntTYNC+Ur2NybP5WLoDHgwqj4 ZB4H0+lEhb4jAfTXdmHE6wc5/hqHb917bGTjACcm12QoemP6IVdS6Hmmj5CUhyNJz2 zaaVchMwEJxAdtRgMjVLjOBegi1EebNA4GHLBbHyH621LTfV6LN/crmiMgcr5h1+c3 XNkevUVj9samnOCEBHoU5Ha2FCbi/PRdkBf46DqxbdVN0y//lGHLXDMTy3PUTG9p+Z jBXK6gKcSt4YEXIHIk2BlhOytkqCjztL3LlG+4FWyBMALevFqmuGroDB5wbvYMv3/5 UZjYlobHH76Rg== From: Masami Hiramatsu To: stable@vger.kernel.org Cc: mhiramat@kernel.org, rostedt@goodmis.org Subject: [PATCH 4.19.y] tracing: Reject string operand in the histogram expression Date: Wed, 11 Aug 2021 16:39:46 +0900 Message-Id: <162866758593.360697.15659863374890557625.stgit@devnote2> X-Mailer: git-send-email 2.25.1 In-Reply-To: <162850048982205@kroah.com> References: <162850048982205@kroah.com> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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) --- - Since there is no hist_err() APIs in 4.19, this just check the flag and return an error without any error messages. --- kernel/trace/trace_events_hist.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c index 28e4ff45cb4c..e9106c976a48 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -2781,6 +2781,12 @@ static struct hist_field *parse_unary(struct hist_trigger_data *hist_data, 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); @@ -2881,6 +2887,10 @@ static struct hist_field *parse_expr(struct hist_trigger_data *hist_data, 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; @@ -2890,6 +2900,10 @@ static struct hist_field *parse_expr(struct hist_trigger_data *hist_data, operand2 = NULL; goto free; } + if (operand2->flags & HIST_FIELD_FL_STRING) { + ret = -EINVAL; + goto free; + } ret = check_expr_operands(operand1, operand2); if (ret)