Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3769272pxt; Tue, 10 Aug 2021 10:54:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyR2hkXnybkovVVNQPhZov1iGOKpjkQEffJEOUIkrhn7G9VRLsFGCZJg7LAjICip2Tpnn7x X-Received: by 2002:aa7:c2d4:: with SMTP id m20mr6430405edp.368.1628618055891; Tue, 10 Aug 2021 10:54:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628618055; cv=none; d=google.com; s=arc-20160816; b=Nib9oJDqPFiey68by2XChnHlylaqiFohjdaMNX6c/HuYLFhf5N4w3zmcTZWG7lD2DO TQlAAyeei8IhifY4LFW4+ujT803iA3dBZ0kljvZn1UML5LkPNJfLZ5us9t3NfRgRTl/9 LTNAb0Jktr+KlXIhVIoP0Pn7Kd6Pn0lS3vLsbSRKTagq4U3kO91LTvSCs8H5FDVhAFkv pP9O1WE1rXA5vLEVt41kdvmJHPqQZZ5GU6NW2OCg95X15amIWx+JYUtVrjqp7M0TgUeo Ja6NzNbk9Q4Tr0tZHdfWShujqOgxt7dOMKZ5nHY0gfGbknXHVsq3UVFmNlrsQdYARraZ 8MRQ== 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=5rM+voKR7xZDrj/bScofRO9KIjzV9zGEXLbTIWlDry0=; b=vbR7xBqjGw2md5TJIrwC1130frOuJmEl6wFMWF4uGjP+0JDjW/Lz1PW8NNxeSAvTR6 uiL0HPxzVTA4awV5id84gk6jXC7dGRDVPAuDMqK4yqA5pUJTYqNJa6gls/8Ex0MohatZ 0MgebKzjMVaqqm6ck+MA68uVFKGTll/bkae2pFws29hHt2SXPTVt37Sv+6GqdnuyVvrI GkJcNKRQxV/1ydTH7gWLFOO9zIJ5bdw/FDLVyzM7J0OnLMp2kUnt9/MePTA3R0GT47ut XbVbp2gsaJPLILLrsA6afKtVkT1aCM7bA6uiGzv7FnnlQMCAbJmS8lqZGK6ZfoYtezTX ZH2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EvXIcRKD; 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 hr12si24079701ejc.464.2021.08.10.10.53.41; Tue, 10 Aug 2021 10:54:15 -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=EvXIcRKD; 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 S232918AbhHJRuO (ORCPT + 99 others); Tue, 10 Aug 2021 13:50:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:51962 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236536AbhHJRqs (ORCPT ); Tue, 10 Aug 2021 13:46:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9065261250; Tue, 10 Aug 2021 17:40:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628617243; bh=wYNRb5K+W5Sb+ruNgoPPWVVHC9OHvcJNXq68vjnx3aM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EvXIcRKDCcDkHoyiBByEsd/br77q0Y9mHST/z8LMPH0yvS6BvJHe6MsMxgXhHPn58 yircaPOVBQkeF46AlZZTxZYdxF6bMy/ndXAeI6YgRHit9FPwIALm620EjWJI6ZEeaH 46DusGHi79e63GaOCZzmZXb3UOG/fvF+0aoi0y+g= 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 5.10 075/135] tracing / histogram: Give calculation hist_fields a size Date: Tue, 10 Aug 2021 19:30:09 +0200 Message-Id: <20210810172958.273678036@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210810172955.660225700@linuxfoundation.org> References: <20210810172955.660225700@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 @@ -2271,6 +2271,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);