Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp116066lqo; Tue, 7 May 2024 14:07:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXJqAe3oNqOpCvAr/WjGQ8rP+IikGEJtLwuEnxxHIr6RzWgM6caXJ09f/4DmUbTOqwR+3Cetyi5Kv5LfQe0bREl4q0oZVxzl5xphUnV7A== X-Google-Smtp-Source: AGHT+IFjHk0ysWn6jGxTJR+fTgsXQSjApco1e7u1DAaJEWVDdXPuUEZyY0x5OeMrdsYIr4+YOcEd X-Received: by 2002:a17:90a:bf10:b0:2b4:329e:a0ca with SMTP id 98e67ed59e1d1-2b6165c40bdmr799420a91.26.1715116058798; Tue, 07 May 2024 14:07:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715116058; cv=pass; d=google.com; s=arc-20160816; b=WpdcdZK/N8X5UTsEI+mXkpUmPCXiLEI03ZQhSbQf+l08ASmvToN49h1eiDmv11OVIx BRSExexviSt3NZu+toqqRX3TQ4dQdaI3iEoxwHTdpdqnYd6HeQCbtkWQAYDBKXTbmwj8 MaSuvEbu5q5hGlUd+nsAO1+W5CFlyDBl/pBnsna17bAGE3o4Jgrr6h7dOPdkutcfyeKv 7KX1zNt4oJ3UgU9vfAouBS/rdW1plqVvC1YWueJ+sTVWtMiy+GPodwg/CSXwSjGYTYLo uROkHW4hENoGtg0dgj+esd68hzaJJV33c0Pe+diLvKFJ7KM20tdiJoUx4Tc4AZtym65t ApHg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=aFodcPLIyQhLhzfnKGuQyvt+5zco5X1nBUB5MbAf76A=; fh=YvR0+rgjGlqqFjlZ5QPM77BW06x/W8UL2iScm9rsdi0=; b=cD/FGScUoPGyWRDxsoOAngRTMYttigpaFdF92vN5L5KcME9bfvjSacftjyOTQmkzzQ W7/w92ES1huFiDZ7ZD5OCLNdf/T0FcQI6nOcn+BtSBMraveNgALoN2twdBU6MMn++j6e ongHVTlI+LfM6pf7mcbmIU7MjIY0HUyQDggkDk/AQKlwQPlPVY+iEwfm0xJVCPkZvdqQ G/k8ezpb1okc+6MoVcEh/ZP3kGJbJaY+Ee+NvyPB2O2i03ms7nkHdfpydJSl0xEssa1E nIMmHUoeLS2s6iLchhE1VvCz3o34NYm1aRuYDIBuE6C76r5CzAIYVWu5W/PFJPEcDpO1 s7Mw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="JRar/O50"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-172189-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172189-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 7-20020a17090a08c700b002b624afdaebsi34151pjn.36.2024.05.07.14.07.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 14:07:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-172189-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="JRar/O50"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-172189-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172189-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 54CFE282543 for ; Tue, 7 May 2024 21:07:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F1C6D73194; Tue, 7 May 2024 21:07:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JRar/O50" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 230E46EB65; Tue, 7 May 2024 21:07:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715116052; cv=none; b=iv6u9bdlNTN/SZCknEHf0Ivb3r6ROlxMAr62LybmJxbIztUGhJmbx8hPWiLq3yEZCmnDecH89L3qToe7ISzhPrnN8M9gSdJd2hpkGmcBz/iWxYI1vHjzRP5A6qc3TKc0WEcRjB7EsufaRL7+t7yRrL/fl5OIb5lv9iqOuUc36yk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715116052; c=relaxed/simple; bh=IruPKvmHK22rd3Atyzt9f//OhnIvVhMuPrqqtt9DPSA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=bGzEPq/PiZgj3Sv60NPYL1o2a4VRHCeIs8woOlWCsZZJShqUOZ6WQ9jB864XAdG01ZIb3DbkReu0szKebOq5sqV4XKkB/6bAl3sfQtoWJEbEsCtn1YPLIqhSrkVEGRFzh0faEfwOpvFCEMdZeAhuA9XkEnj2lXuTOP85Pb58g0w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JRar/O50; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13A36C2BBFC; Tue, 7 May 2024 21:07:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715116050; bh=IruPKvmHK22rd3Atyzt9f//OhnIvVhMuPrqqtt9DPSA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JRar/O50ZvQKN+7xk/G/FDvHxyqaReRGL5ZpbC7aLsA36ByRqjQtnamcnNiR7/03U do6YQFagyR+x3Y+Sw0spCnqH2O/z/Ys0q+9J8Dr86991ivYuoZNgESUtNstMJYI/Hj z+ea713knJ+yIw0fkiXkFLHQcY+rzHC8o04ew8Xqsk+gUP0Qr2emt1XZdiggJoq85v h95cP/YanIE9j4eQwPntPjoan/WzBDfyx6XX1a9QAmsk7nZu1mR1P7SX8aR/rAOwca Wx9javJMlil7LRIJwFAgSuWkwVzsUXT0yfsSzXPJh+UpuaV8cE8vonzh8aQs6CNU/3 e7LdQuEoqDgTQ== Date: Tue, 7 May 2024 18:07:27 -0300 From: Arnaldo Carvalho de Melo To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Kan Liang , Oliver Upton , James Clark , Tim Chen , Yicong Yang , K Prateek Nayak , Yanteng Si , Sun Haiyong , Kajol Jain , Ravi Bangoria , Li Dong , Paran Lee , Ben Gainey , Andi Kleen , Athira Rajeev , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org Subject: Re: [PATCH v1 1/8] perf ui browser: Don't save pointer to stack memory Message-ID: References: <20240507183545.1236093-1-irogers@google.com> <20240507183545.1236093-2-irogers@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Tue, May 07, 2024 at 06:04:43PM -0300, Arnaldo Carvalho de Melo wrote: > On Tue, May 07, 2024 at 01:48:28PM -0700, Ian Rogers wrote: > > On Tue, May 7, 2024 at 1:22 PM Arnaldo Carvalho de Melo wrote: > > > > > > On Tue, May 07, 2024 at 05:20:59PM -0300, Arnaldo Carvalho de Melo wrote: > > > > On Tue, May 07, 2024 at 11:35:38AM -0700, Ian Rogers wrote: > > > > > ui_browser__show is capturing the input title that is stack allocated > > > > > memory in hist_browser__run. Avoid a use after return by strdup-ing > > > > > the string. > > > > > > > > But everything happens in that context, i.e. hist_brower__run() will > > > > call ui_browser__ methods and then exit. > > > > > > > > We end up having browser->title pointing to returned stack memory > > > > (invalid) but there will be no references to it, no? > > > > > > > > If we return to hist_browser__run() we then call ui_browser__show > > > > passing a new title, for "live" stack memory, rinse repeat. Or have you > > > > noticed an actual use-after-"free"? > > > > > > And I'll take the patch, I'm just trying to figure it out if it fixed a > > > real bug or if it just makes the code more future proof, i.e. to avoid > > > us adding code that actually uses invalid stack memory. > > > > My command line using tui is: > > $ sudo bash -c 'rm /tmp/asan.log*; export > > ASAN_OPTIONS="log_path=/tmp/asan.log"; /tmp/perf/perf mem record -a > > sleep 1; /tmp/perf/perf mem report' > > I then go to the perf annotate view and quit. This triggers the asan > > error (from the log file): > > ``` > > Thanks, it is indeed a bug, I'll keep that Fixes tag, people interested > in the full details can hopefully find this message going from the Link: > tag. Nah, I added your explanation to the cset log message. Thanks, - Arnaldo