From patchwork Tue Aug 10 17:30:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 494371 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp4196424jap; Tue, 10 Aug 2021 11:02:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTwjdXaxQVxjTwfJNhKqRpXa716/prfL9Ta+nlJ35Jvz4MslusizONVQK9NkD7ATY9CUJP X-Received: by 2002:a5d:9681:: with SMTP id m1mr1191100ion.113.1628618578305; Tue, 10 Aug 2021 11:02:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628618578; cv=none; d=google.com; s=arc-20160816; b=ZLGBzwGwgKtqPoUohT0Y5muLpND2usf4vJnVPz/dYl7jFCWue6zpD9I1Z49wmKKvoP 5c85qjQ2aN2Wu/qPGdOoGJCtp3EFd5j4AkeNU7/bPAKjM8msbP/Mydzce0Pf3MtjPviT iaY8ghk+Wc+vxY9SMPwrnooA0M756LYCqLtjbiQPil7NHlZJrY8QnmBSRH38jScCQ3ux uOSi7RJ2OAsCtIxJel0aFow7ehb+fXw5FAJF1dIRVoACZ3KNkUOKq0/ocaLbxpXkNtPb UYMK8Qm1aWVO9IPJFAsIV1dR76uLJjWkQUE4MYgUk5C7yrGOZk0cI+ztDzQf/91a9dtj 5cbA== 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=vHGX5J5Z3E4uYZ8snyxL1pP/LuVMou1RE2pEquaz+s8=; b=kIEqS0rZAwvJosXrLIu3Lmg4DSejspuXTJLcbvoOxU5WKWP/jfTp/Lv78B58WuSYtq 2tl/c7Z+10MpF0xlxMlBy+8ZZmHmzM/wqmSIXcEXaSE7bP53QvSAnAmYTpAxr+7/8JOv KpOhMsKKjQHxpQQO5+d9epqqePVzIosw+p4MFQOlvWIPtqTsNyUth/3IBTKNQARz9leq tGeNHFkGMO6XRJb7YVL/aWiGVkNC5h1UPaQSQPSvoY4BKILqlawcc6A7ApueldC9wX7Z +aZjQfbxDnPqLzAGURmpH5nvpeBDf77PtDT2wmeY6+a13C4uPgr19tXJxL2HHWMD7L70 NLwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=T40XNhdk; 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 ay1si7069988iob.49.2021.08.10.11.02.58; Tue, 10 Aug 2021 11:02:58 -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=T40XNhdk; 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 S235320AbhHJSDO (ORCPT + 12 others); Tue, 10 Aug 2021 14:03:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:33870 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236342AbhHJSBN (ORCPT ); Tue, 10 Aug 2021 14:01:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 84241613A6; Tue, 10 Aug 2021 17:46:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628617617; bh=KBmQ3bn4sgLwrPrWnfZSzIrd/x4pj4uOkNu0Gabd6FA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T40XNhdkbu4BRX2CHLeHAfrprIYZHw/Zmu5J7wpyIseAZkHMYvFRq3tF2MOz2xc2X 21yZ/NfErfCCgdUb1V1aDaWzDEXAwErofu+mcWOAd1vwqWWsxOySkIM0SI1FislXGo Gs2FY0qIJKDYGRZQnRk1Q39j00VmQAwNRPdwDzVU= 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.13 103/175] tracing: Reject string operand in the histogram expression Date: Tue, 10 Aug 2021 19:30:11 +0200 Message-Id: <20210810173004.353520047@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210810173000.928681411@linuxfoundation.org> References: <20210810173000.928681411@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 @@ -2156,6 +2157,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); @@ -2257,6 +2265,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; @@ -2266,6 +2279,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)