Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1567430lqt; Wed, 20 Mar 2024 07:50:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXPq3Y5GdjHmplPVoDwXq7nLeBGxpdZ3UIKioWjleXblC2Pt7yg+eO14OeyPcpQW2sFQdd3+JjX1DOxRXvvUPPcA3rGNYko6pQHyMFKrA== X-Google-Smtp-Source: AGHT+IFXMpgXpBwBH+qSBWzksM7qwWQ7gltIB4bOdZerTgMo+iM6kNP4gLJeVMsg3z0kGjyt5L5C X-Received: by 2002:a17:902:f688:b0:1de:f7cf:469 with SMTP id l8-20020a170902f68800b001def7cf0469mr16949476plg.16.1710946209534; Wed, 20 Mar 2024 07:50:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710946209; cv=pass; d=google.com; s=arc-20160816; b=D6Kz4nNp+hJBgXBn5FRKSUUk6URq1ovWDfZzJ6I4h/nH3f3q1g38RlR6bjIy0bFlZ3 7XoPisj7Axx+UF7NRxD100mGBKyoGPYqemevUJM2FQNYkSwQhx8bOeGiJRvbjpbZ0VVq hIVaAIKSrW5M8TRDPE5tK+KyGHKNQ7bFsZtMS+RZZ/ttH+86vZ3UYY/wtlBMhNikqub9 70PDjqXyQCflvfpAe05bDgXcI927w9W1gZnd11ZGGYoiJqU8tyNnx0kQdgaGSdf+t7m7 e5fjmN+jvZWFN2JbUP39r1nDqw1EbkoAo1cI3xC9HnTguaLNGq61Gs+WE68In+CVHec8 zAdQ== 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=liSJb+tJ4V0b/j4AyQgk8dL9uRZRneeiRKw6Rq7fRvM=; fh=zyQ9WxNMlR5o/k8gpFDiFr3z/wkMtrY0AoIFoEuAvFA=; b=kFoiKxh92DYne73V86Pmej3dAznpChU0f5Yq7Py3h9TYu3MRpCS0dSlgjP9VhXA5lE ObmSZ6MvlOfoyJDyEBKs8XKCGOcHt5h6yRhTMQlG1Mfq/kNWW1y45HYiPz0OpZhukRgw EPU3+Rqkmt8tTBBEBC36GF4OehJcKNAmtlrU8wnbRsMmaB4/raP8kKIMfBgkWNRy3rO3 DS5UkdmKjDyEggeuBXnbfTe7iT++o+9jV1LIfgKvCCAX/qpnXt+hujk+lcSf5OfxkkV5 yMrf2BC0YBFOuRty77tosdV/FY1j9l3MsXEbgCzoY0k4a2MdVyNEqjh0u8E/t0Uuax+U LmWQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NeG2+rZf; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-109030-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109030-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. [139.178.88.99]) by mx.google.com with ESMTPS id d12-20020a170902cecc00b001dd924050a9si13860292plg.3.2024.03.20.07.50.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 07:50:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-109030-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NeG2+rZf; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-109030-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109030-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 380EE283A08 for ; Wed, 20 Mar 2024 14:50:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 15FD34AEC3; Wed, 20 Mar 2024 14:50:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NeG2+rZf" 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 2FAE447F6A; Wed, 20 Mar 2024 14:49:58 +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=1710946199; cv=none; b=QBnuuq/ee86YtG13nrqrFo+AXv4E8TlkaMbG+rPIHEJN4AmB3rWCSapROkCh5frsnJmPxkbm+Qmdt77JiRdnvKsdUmpn20nn5V3ZqW30fUlBoGaBGuLfsXThNaXieFwWT9kJhknn3D8wXUmijVuePGyI4sdOc3nmuCqQPnSbvJw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710946199; c=relaxed/simple; bh=G0BQvQe3h5OzdSrH8qTN0I1MWrHBWh89p4W0eSgt05g=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=KxMp8itL7UWVXMXE5IeVzKsYu+7HqE4hRKSocbI1xPtVhaPPKbilM/DUiUAjN6e7jBryeZC9o1uPWqhwOxSXq3OhRIaYAIPQVM4Sy3VzJzfSJq4egtgMqHkDgx5CZiAnBBKgZgdUv6zYUdBgQ0R/23zhrKvXbdGdugjoR+n6TyA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NeG2+rZf; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28C67C433F1; Wed, 20 Mar 2024 14:49:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710946198; bh=G0BQvQe3h5OzdSrH8qTN0I1MWrHBWh89p4W0eSgt05g=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=NeG2+rZfwbCuOUPnN/X/okwbf8NPK2JkmGOnzFn8vCOCmIOfhGTyJeTQzZOXQM5Us 57mbOrvVO31RfJwlRD9fF3SaoVFs6Ai+vR/Fc+D/P57rT2EmOm1ajrPBSjkiR4oNQk X4bpDfnyyu0RUd8qTK03y2CuIG3txVlglE31EFISmSbuqbHYYylWIc8NxHnaPKhsXI ZHInvzbFdkQUey36X1TtGNTM5G7w/NHcjiUqgz9ZrNMKqDdWj+Auo3p2Z/Z2o0eLQ/ aAHVoOp1CFNUfBWKkST9Mm+RqzGVmtZhypei0mEIZ1ngDZES24koRwzMxCL8TYA6K2 U7zA/jh61XqAQ== Date: Wed, 20 Mar 2024 11:49:55 -0300 From: Arnaldo Carvalho de Melo To: Ian Rogers Cc: Peter Zijlstra , Ingo Molnar , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Adrian Hunter , Christian Brauner , James Clark , Kan Liang , Tim Chen , Athira Rajeev , Yicong Yang , Kajol Jain , Disha Goel , K Prateek Nayak , Song Liu , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: Re: [PATCH v1 1/4] perf record: Delete session after stopping sideband thread Message-ID: References: <20240301074639.2260708-1-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, Mar 19, 2024 at 09:42:26PM -0700, Ian Rogers wrote: > On Thu, Feb 29, 2024 at 11:50 PM Ian Rogers wrote: > > > > On Thu, Feb 29, 2024 at 11:47 PM Ian Rogers wrote: > > > > > > The session has a header in it which contains a perf env with > > > bpf_progs. The bpf_progs are accessed by the sideband thread and so > > > the sideband thread must be stopped before the session is deleted, to > > > avoid a use after free. This error was detected by AddressSanitizer > > > in the following: > > > > > > ``` > > > ==2054673==ERROR: AddressSanitizer: heap-use-after-free on address 0x61d000161e00 at pc 0x55769289de54 bp 0x7f9df36d4ab0 sp 0x7f9df36d4aa8 > > > READ of size 8 at 0x61d000161e00 thread T1 > > > #0 0x55769289de53 in __perf_env__insert_bpf_prog_info util/env.c:42 > > > #1 0x55769289dbb1 in perf_env__insert_bpf_prog_info util/env.c:29 > > > #2 0x557692bbae29 in perf_env__add_bpf_info util/bpf-event.c:483 > > > #3 0x557692bbb01a in bpf_event__sb_cb util/bpf-event.c:512 > > > #4 0x5576928b75f4 in perf_evlist__poll_thread util/sideband_evlist.c:68 > > > #5 0x7f9df96a63eb in start_thread nptl/pthread_create.c:444 > > > #6 0x7f9df9726a4b in clone3 ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81 > > > > > > 0x61d000161e00 is located 384 bytes inside of 2136-byte region [0x61d000161c80,0x61d0001624d8) > > > freed by thread T0 here: > > > #0 0x7f9dfa6d7288 in __interceptor_free libsanitizer/asan/asan_malloc_linux.cpp:52 > > > #1 0x557692978d50 in perf_session__delete util/session.c:319 > > > #2 0x557692673959 in __cmd_record tools/perf/builtin-record.c:2884 > > > #3 0x55769267a9f0 in cmd_record tools/perf/builtin-record.c:4259 > > > #4 0x55769286710c in run_builtin tools/perf/perf.c:349 > > > #5 0x557692867678 in handle_internal_command tools/perf/perf.c:402 > > > #6 0x557692867a40 in run_argv tools/perf/perf.c:446 > > > #7 0x557692867fae in main tools/perf/perf.c:562 > > > #8 0x7f9df96456c9 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 > > > ``` > > > > > > Fixes: 657ee5531903 ("perf evlist: Introduce side band thread") > > > Signed-off-by: Ian Rogers > > > > Note, after this series I'm seeing parallel perf testing being as > > reliable as serial but parallel testing is nearly 3 times faster. I > > think after these changes land we can make parallel execution the > > default. > > Ping. Thanks, applied to perf-tools-next, - Arnaldo