Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3757657pxt; Tue, 10 Aug 2021 10:36:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5o0LVOve0ryExlIdTroKUrEHpcthsVcEcgNQplngVgLkmMD2NctHXanH7SDZZ2oZxlqL0 X-Received: by 2002:aa7:d40e:: with SMTP id z14mr1073497edq.250.1628617007862; Tue, 10 Aug 2021 10:36:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628617007; cv=none; d=google.com; s=arc-20160816; b=VSQuVmaMYl8V0xggUpfFWtlSFnPXiy1VtoH3IcnNzpacj+9tnHPy7qRhSCbsxLKMSp 7TdR+ulnjZoS5kNZuSSbN4/xGGagH4ce8UU/tYdunWW7I9JUcVK2b80e1Acl3I1gDo6f XURcE+eBhHJUr+cFgF7a62REof4KTweIYhC3+cOCK4lGyFcxSUNwDB6xWRlO47ckDxG4 byCh4XK3W9zJ586dLBiwFSc7lAglTMC/IbFMKUbn4IciZCH9yoePlBF9M8rpVg+7E7+j YNJ9oCliiEj3iL3zMnxQnRVJiGF2GbmKA8iFlCkVJADG8GkQME/m3GgldhSPUQqFPULC cO5w== 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=Q1YS/55NFNkAMbMEE7ed+Q09xOwXe183p1IESxvBBEc=; b=SmooDIrWB5TaifsQHHZYaeCLr7RRapt1SyaTfjNaXEs66Y5E8Oz6Cmm9hGnQ/VKNku 439sJwh97bbBUre8P9PRhayjS2aCIqgr2rh0a4ENA6RhLisFGoCKPwaUazRZvZiraMTw yxQY9k+0rmOsZFSLHC+1fXUG2wTGzk8SQklFWRx3amokOE3b0cJunXQo/WNNWdLnnbEx 1iqOVHWc2Jz3itLwycCQPVBF9o0/lsGj09Ie+ArdCHrlN/lLB2sxYf4fSO7wGIKDHhgY D68Q2CMptO3nRcbTkv4BC3kbExOcfoB1SjOwC14tBk0bc7aYkAlXLCQ0Bxw4FzaUaLNs v9Ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ID6eL2gj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 oz19si19358102ejc.277.2021.08.10.10.36.23; Tue, 10 Aug 2021 10:36:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=ID6eL2gj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S232085AbhHJRdX (ORCPT + 99 others); Tue, 10 Aug 2021 13:33:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:33340 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232070AbhHJRc7 (ORCPT ); Tue, 10 Aug 2021 13:32:59 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3B25D60F41; Tue, 10 Aug 2021 17:32:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628616757; bh=xaZu6tkYFf24mjrTiqt+gPN7MxQWXWLAQ0yVEU1hgRg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ID6eL2gjU45l7Agt31DJbU7ZmUG6op8Ylhfz9OKthppig74QLVRJNGD0zFqOJG5gR k06r+vwpXikH0gQnnXMY3AEKdjo3Oj92FjzPhJXHfZPBBi58MBpbyA9yx8swflK6Oy 0cL2CiLsNNfgUbldMiIOnU73MqC2m/Uq+ELNOYZk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tom Zanussi , Masami Hiramatsu , Namhyung Kim , Ingo Molnar , Andrew Morton , "Steven Rostedt (VMware)" Subject: [PATCH 4.19 33/54] tracing / histogram: Give calculation hist_fields a size Date: Tue, 10 Aug 2021 19:30:27 +0200 Message-Id: <20210810172945.272938083@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210810172944.179901509@linuxfoundation.org> References: <20210810172944.179901509@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Steven Rostedt (VMware) commit 2c05caa7ba8803209769b9e4fe02c38d77ae88d0 upstream. When working on my user space applications, I found a bug in the synthetic event code where the automated synthetic event field was not matching the event field calculation it was attached to. Looking deeper into it, it was because the calculation hist_field was not given a size. The synthetic event fields are matched to their hist_fields either by having the field have an identical string type, or if that does not match, then the size and signed values are used to match the fields. The problem arose when I tried to match a calculation where the fields were "unsigned int". My tool created a synthetic event of type "u32". But it failed to match. The string was: diff=field1-field2:onmatch(event).trace(synth,$diff) Adding debugging into the kernel, I found that the size of "diff" was 0. And since it was given "unsigned int" as a type, the histogram fallback code used size and signed. The signed matched, but the size of u32 (4) did not match zero, and the event failed to be created. This can be worse if the field you want to match is not one of the acceptable fields for a synthetic event. As event fields can have any type that is supported in Linux, this can cause an issue. For example, if a type is an enum. Then there's no way to use that with any calculations. Have the calculation field simply take on the size of what it is calculating. Link: https://lkml.kernel.org/r/20210730171951.59c7743f@oasis.local.home Cc: Tom Zanussi Cc: Masami Hiramatsu Cc: Namhyung Kim Cc: Ingo Molnar Cc: Andrew Morton Cc: stable@vger.kernel.org Fixes: 100719dcef447 ("tracing: Add simple expression support to hist triggers") Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Greg Kroah-Hartman --- kernel/trace/trace_events_hist.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -2911,6 +2911,10 @@ static struct hist_field *parse_expr(str expr->operands[0] = operand1; expr->operands[1] = operand2; + + /* The operand sizes should be the same, so just pick one */ + expr->size = operand1->size; + expr->operator = field_op; expr->name = expr_str(expr, 0); expr->type = kstrdup(operand1->type, GFP_KERNEL);