Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3326608rwa; Tue, 23 Aug 2022 02:55:15 -0700 (PDT) X-Google-Smtp-Source: AA6agR7lwRQOW/cBS5qg4/W4JCBNuXWIbN3OsUqipd3fAVrwaKmVm4oEPZ/mr00tOgxXNa9SzYGa X-Received: by 2002:a17:907:2e01:b0:730:9ecc:cd28 with SMTP id ig1-20020a1709072e0100b007309ecccd28mr15683183ejc.360.1661248515296; Tue, 23 Aug 2022 02:55:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661248515; cv=none; d=google.com; s=arc-20160816; b=lmTbYBzqZMIUUdZJKy5zJGiW4BnCPVtWzo+3mjKUT0VrHDU9Jz013plxpwXnJBJCci +6M9ZsDlfDVbQYgpD7QnlP7ZlLzz7KA7weaC0yvM7SICWLOsz9wBeay+pca5aX5WZcae l/L2ancKMD60Sypc4ZorhoFggMPLYzl8/YGSJmuzmCO2TDdR56pPet3PdBvT47JbczMv 6dlTqeWL6h5ZPrIQmOnXx2tR7caDRuSJ/VFn3IGJ1kSYz2cYhFSflbkvStfvktPBd27Z OK9RoEI6BT1UtLPU7L8CHGgPF5tQaxlAmbk+XXVidGlVulR/DATti+ZLnz6UJ7a2RSlj qZDw== 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=7LX2tTsHGeH8+sDCXDfjHw2BpiXcWByTjl19EzSZnwo=; b=IGEACVxPOeUkyIP6dTqarydbWmN58LvwTX72CbLZpGznZch5QVymT8xvNoa+QP8No/ rI7iDok3mL0SB9P3+nNZBV1NvNxXAEZU5YciQRmJlMPkCInfydaN4rPW9QnNpeEkOhi9 BNRHV63Yy9kfCayVBApiEgYpCDDmjsxDGUgXTa8LTrmovHsdtCL/jLBLzRnTMqL4u9Oo RLgLgMCAyMt5UJWx693WTc2W/cpFQnmuK7kRxSBro7WnQx6gp7bZc0s+VpcB54vNgJWU /TWfW+aCr4HX5xoz+uhup25aXKABj+9La/oyZ82Bk9jWH3cDZjhIbPjvB3LtXu08u8A7 jNuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LY9v1zzF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ne32-20020a1709077ba000b0073d72dbfdf8si6817090ejc.220.2022.08.23.02.54.49; Tue, 23 Aug 2022 02:55:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LY9v1zzF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S242276AbiHWINh (ORCPT + 99 others); Tue, 23 Aug 2022 04:13:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242009AbiHWIK1 (ORCPT ); Tue, 23 Aug 2022 04:10:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC7EF2BC9; Tue, 23 Aug 2022 01:06:56 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0EB97611DD; Tue, 23 Aug 2022 08:06:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1BE64C433D6; Tue, 23 Aug 2022 08:06:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661242015; bh=fPU2t9eLDqNauoToSdAkjI0cyo4HWW1yisfgWfJvenU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LY9v1zzFtJvu3vtxLyrRUbsil8+7Ur0uGrORLpoFoqNBZ/X6uF5vY8G+u8TEx2yuD V2p/4LdXezI7aZLwdy6HprA/Xfu4aqkC3TsraXd9QT7DUFd7+emfRgslHRh1uM5jYM 9bu83t2Ge2w8QHr8BCDefJn2VHW2FJFSZTmIfnfY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ingo Molnar , Andrew Morton , Tzvetomir Stoyanov , Tom Zanussi , "Masami Hiramatsu (Google)" , "Steven Rostedt (Google)" Subject: [PATCH 5.19 033/365] tracing/eprobes: Fix reading of string fields Date: Tue, 23 Aug 2022 09:58:54 +0200 Message-Id: <20220823080119.596808360@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080118.128342613@linuxfoundation.org> References: <20220823080118.128342613@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Steven Rostedt (Google) commit f04dec93466a0481763f3b56cdadf8076e28bfbf upstream. Currently when an event probe (eprobe) hooks to a string field, it does not display it as a string, but instead as a number. This makes the field rather useless. Handle the different kinds of strings, dynamic, static, relational/dynamic etc. Now when a string field is used, the ":string" type can be used to display it: echo "e:sw sched/sched_switch comm=$next_comm:string" > dynamic_events Link: https://lkml.kernel.org/r/20220820134400.959640191@goodmis.org Cc: stable@vger.kernel.org Cc: Ingo Molnar Cc: Andrew Morton Cc: Tzvetomir Stoyanov Cc: Tom Zanussi Fixes: 7491e2c44278 ("tracing: Add a probe that attaches to trace events") Acked-by: Masami Hiramatsu (Google) Signed-off-by: Steven Rostedt (Google) Signed-off-by: Greg Kroah-Hartman --- kernel/trace/trace_eprobe.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) --- a/kernel/trace/trace_eprobe.c +++ b/kernel/trace/trace_eprobe.c @@ -310,6 +310,27 @@ static unsigned long get_event_field(str addr = rec + field->offset; + if (is_string_field(field)) { + switch (field->filter_type) { + case FILTER_DYN_STRING: + val = (unsigned long)(rec + (*(unsigned int *)addr & 0xffff)); + break; + case FILTER_RDYN_STRING: + val = (unsigned long)(addr + (*(unsigned int *)addr & 0xffff)); + break; + case FILTER_STATIC_STRING: + val = (unsigned long)addr; + break; + case FILTER_PTR_STRING: + val = (unsigned long)(*(char *)addr); + break; + default: + WARN_ON_ONCE(1); + return 0; + } + return val; + } + switch (field->size) { case 1: if (field->is_signed)