Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp532783pxk; Thu, 1 Oct 2020 08:17:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySKv7p6kVfNP1SOl7bMCf2KeuQW2tP7cMlc1Ia4G8tjFIXaxchY/F+sfqQ4t7yUBSGBOid X-Received: by 2002:a17:906:390d:: with SMTP id f13mr8465397eje.86.1601565471276; Thu, 01 Oct 2020 08:17:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601565471; cv=none; d=google.com; s=arc-20160816; b=Dwmhl0JgPd/X4KXNRcKRj6D8jgRft7/q1oaximdfHvvu14c9WmuY6TNpNU4weOBEKp FkqlddCetVO8Ucq3bQNpOQzGLFEqRongsFf2BmBUzet6YuRJ+sDfAMYEWdQPPfmV5mbu NpJiaS4dbaXI4b/XA959ylxor9KBDEXlCttzG8vVggSeY5zqUM6RsKzEID+cBf39SA2o MD/wnRGY24PPUwlUM8vbJ+BzFx40fAXammXg38H8ZTWoRNvVuF9FF83an09GdQY7MLIe csSq0FCqBHyr5PWCh8cqcz/tTTYn8hlH7GU43mh1ESbPY53Mc6vJNoiCP/teT+wvrwUh BA+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=vSvzOjKHi6OhFLIVrvBFAJP3o3tt3m1EmbLzsGJwxrc=; b=UaP8fR2UAt9fir/5iBGOWqO2ZFmqVy2Mfm/YiCL7Bm9HugzZO9PjEnKH4dhW6WPVjn o9KKwNo+sLQoG1bmspDJyvCLg7c1c+HeTxTCJZlhrLfxz46zB9X+zJYrIiDtajVYEiPW Ex+msKUrQU30860tqUkPuwhFKZgZL9ubIED4Y9VZjQmjjTy6gX0VDrTdadYCRWvt97jh ubMW3sE4yEOtW2rdWhnFOfJpuPAz8wxDG+hJQS/HtiNXnMr1Eu1u063EY67FUAkTFNkh hU8Y0GLqQIQSV18/FR0WqqsR/zVpjoMBDqqYZDGGB0SSVP9z7Qa8nXK2elljj9KSOlQZ CHGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ri2zKa4L; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gs18si4010436ejb.8.2020.10.01.08.17.23; Thu, 01 Oct 2020 08:17:51 -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=@kernel.org header.s=default header.b=Ri2zKa4L; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732590AbgJAPMu (ORCPT + 99 others); Thu, 1 Oct 2020 11:12:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:53026 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732384AbgJAPMt (ORCPT ); Thu, 1 Oct 2020 11:12:49 -0400 Received: from quaco.ghostprotocols.net (unknown [179.97.37.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 26001208B6; Thu, 1 Oct 2020 15:12:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601565169; bh=0tp/yT04bI9YEzGZ7JU9CrvtzZ2lCVTf/YhR8YSvl1w=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Ri2zKa4L3913Z+XrUkCW1KGdtyI7MxP7tlck2HW9hwIv0UX352si7rIbuiOS6hnLI fL4PO8r4qCePIcfTb3hcCvb86OHYbQ9AJGQu7kFCilpMLbmC9NCq9FN/JKtkaiDjsA o76d0ekIB4Wm4Bbq1dMQo5EMvZ+7+Kwup+k/tJiw= Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 467E8403AC; Thu, 1 Oct 2020 12:12:47 -0300 (-03) Date: Thu, 1 Oct 2020 12:12:47 -0300 From: Arnaldo Carvalho de Melo To: Jiri Olsa Cc: stable@vger.kernel.org, Hagen Paul Pfeifer , lkml , Peter Zijlstra , Ingo Molnar , Mark Rutland , Namhyung Kim , Alexander Shishkin , Michael Petlan Subject: Re: [PATCH] perf tools: Fix printable strings in python3 scripts Message-ID: <20201001151247.GC18693@kernel.org> References: <20200928201135.3633850-1-jolsa@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200928201135.3633850-1-jolsa@kernel.org> X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Mon, Sep 28, 2020 at 10:11:35PM +0200, Jiri Olsa escreveu: > Hagen reported broken strings in python3 tracepoint scripts: > > make PYTHON=python3 > ./perf record -e sched:sched_switch -a -- sleep 5 > ./perf script --gen-script py > ./perf script -s ./perf-script.py > > [..] > sched__sched_switch 7 563231.759525792 0 swapper \ > prev_comm=bytearray(b'swapper/7\x00\x00\x00\x00\x00\x00\x00'), \ > prev_pid=0, prev_prio=120, prev_state=, next_comm=bytearray(b'mutex-thread-co\x00'), > > The problem is in is_printable_array function that does not take > zero byte into account and claim such string as not printable, > so the code will create byte array instead of string. Thanks, tested and applied. - Arnaldo > Cc: stable@vger.kernel.org > Fixes: 249de6e07458 ("perf script python: Fix string vs byte array resolving") > Tested-by: Hagen Paul Pfeifer > Signed-off-by: Jiri Olsa > --- > tools/perf/util/print_binary.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/perf/util/print_binary.c b/tools/perf/util/print_binary.c > index 599a1543871d..13fdc51c61d9 100644 > --- a/tools/perf/util/print_binary.c > +++ b/tools/perf/util/print_binary.c > @@ -50,7 +50,7 @@ int is_printable_array(char *p, unsigned int len) > > len--; > > - for (i = 0; i < len; i++) { > + for (i = 0; i < len && p[i]; i++) { > if (!isprint(p[i]) && !isspace(p[i])) > return 0; > } > -- > 2.26.2 > -- - Arnaldo