From patchwork Fri Aug 13 15:07:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 496574 Delivered-To: patch@linaro.org Received: by 2002:a02:cf8a:0:0:0:0:0 with SMTP id w10csp658167jar; Fri, 13 Aug 2021 08:15:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxk2sAYDaQIGocCzq/FLq3Nn5bLLwmb9UHS2lcnToff0xyLLRvUysZ0JkX6ookn2WT4tlVw X-Received: by 2002:a50:954c:: with SMTP id v12mr3717502eda.313.1628867707505; Fri, 13 Aug 2021 08:15:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628867707; cv=none; d=google.com; s=arc-20160816; b=SgbTvitrhN92sv6yL5wDTyTvfE1lIMkVpG5CmrRnw9f/SqXAGM85aPkhYHRei8vEx8 s6aGP9d5FM0kDLn4qHMzQ+MhiyrMjQ2/FEFjPBPmNqkfl0EDGhEIyN6YyQ5rCMBb6Hzx n+DV9g8GeJQ/BzaBwsITyma6XKqiRe2Uewju7Q8+FxkWCkbe92YoB5Ebfl+yP8RXyZqH e4YMVCl526IMJr6d4dG+pTUF0HgJyZf8dNmx2VKotu/pb9ADu17axFULBOPjQrnJYk0s IKaxRUihspHbWbwCJqrHmFMAA2Iz0YNguvA8gUXuL8Cd7pGoq7ZFl7OlgpZrz8Y7/jeN N/cw== 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=8cPHgTtecFN6eESz9StMfCVXEf/ttGuOq8VSDDkcxpM=; b=EcWR8auv4Y+5x7iDym07ifX0+LNxuRNV8SunzGl5aiz/zrrUqbmTLcV88mB55I1BNV 48ReGMxakDLZebtv2MIuDAwdP14TTcOz7bVTPYfnttypkBfTbVUkyWSTUjXvyuI7xFMB kIq/+q3+KJjrYhHlvqJ1HYWrHjqGLrVPiU+Fo/tES2nBBpZNKNGl4+bF591M//PfqW0H HQdTJ1L2uLYvecachBhDcRk2FC6bRRdVGqvKNRAD0pe30mncjX7STh2w0boTX8AEeb07 NCtZ355tWkAvp/nbnRtaGg3S+0YfTJUjjzz6sSklvSSct3vV4f7rUr4zw4wyp+VxFYEV BzNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2HBDBK4Z; 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 s4si1864522eji.269.2021.08.13.08.15.07; Fri, 13 Aug 2021 08:15:07 -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=2HBDBK4Z; 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 S241302AbhHMPP0 (ORCPT + 12 others); Fri, 13 Aug 2021 11:15:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:57690 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242486AbhHMPOU (ORCPT ); Fri, 13 Aug 2021 11:14:20 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A98FC6112D; Fri, 13 Aug 2021 15:13:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628867629; bh=Gc/SZpxnY9PK3il6g3SOaosaSRoUaCLDr5Cug2sQylg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2HBDBK4ZfUcvL1yMlVyRupmoA7/4PGu5InaIDN3oSoWtGsF4IIBB4aht19Z2rh4uz MSpeOs5agHk/0sbZr6AnbuJUmUmu3GGQHQzZnHUcA7WnechB9f5ViRxo4aDqaHpTQG MADbng50lbJY9rirklj9VvwGbntTSznO0BvUOwU8= 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.4 04/27] tracing: Reject string operand in the histogram expression Date: Fri, 13 Aug 2021 17:07:02 +0200 Message-Id: <20210813150523.509525049@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210813150523.364549385@linuxfoundation.org> References: <20210813150523.364549385@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 @@ -66,7 +66,8 @@ C(INVALID_SUBSYS_EVENT, "Invalid subsystem or event name"), \ C(INVALID_REF_KEY, "Using variable references in keys not supported"), \ C(VAR_NOT_FOUND, "Couldn't find variable"), \ - C(FIELD_NOT_FOUND, "Couldn't find field"), + C(FIELD_NOT_FOUND, "Couldn't find field"), \ + C(INVALID_STR_OPERAND, "String type can not be an operand in expression"), #undef C #define C(a, b) HIST_ERR_##a @@ -3038,6 +3039,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); @@ -3139,6 +3147,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; @@ -3148,6 +3161,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)