Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp956794lqo; Wed, 8 May 2024 23:43:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXW4oCZnvXMd5qjtIbYoQKn8k10uN/7GF6ZkZOuRIKWUitC5hosy+ShlOn6z6TXYzLs/sfPJhlYbiUasMWhhKllim7iMWEtAC9LgFHRjQ== X-Google-Smtp-Source: AGHT+IFFyY88clwGRXPgjJLKErPFFDsDlDLMrH9HrQQqZhTRqymeC0QLVmmXPu2x67oaNOOdF/Qg X-Received: by 2002:a17:90a:2e17:b0:2b4:fcfd:7560 with SMTP id 98e67ed59e1d1-2b616be237emr4167262a91.45.1715237017284; Wed, 08 May 2024 23:43:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715237017; cv=pass; d=google.com; s=arc-20160816; b=vflaRDp0K7YfB6kmaHFPFzHXjPruF92/3vrzgJd9dVUM68KHQ8jUhxL6L+0LG5Ivvk 47R2J3EtHL3pn7Z26BVXE8A4GqWED2BLMtcbnDEhw0eBcSfdq+5ez4ipVQyVycwGQJCX BpdjDi6q9lo3c6Yj8illCh4MFU795JEdHbUQOSKDxoFGcGRp3OqTFM1d3h6JJRVY57t4 JL9Vt157yBOsdLAElTNtPUuDXT2IK3i/ZF06hjoBu0UQHPK1b37z4ZZv67x/Dxxm7YdW F85rvmlIMhlEqv9GvavNNPZotL2/+58MnZv1DDzQEfXhFjC4V6MhGnmFk63UntOR5C6y HSjA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=Sfpm2g40k/3k+p/MIEAhjjOe3D3qfwBHw4FyzeD3fNs=; fh=8djuNldCHxgolaYjfsThih/3uEJvSYRmGCP5OZnEWD4=; b=uUdqwd4+st8agmzQ7gMMqb1+D00UNVA/OPCwNieXB1luId/wLRtOE153Aqi/YgKSN6 tT+zIo3CmSmQv8faFKBfCkzmnYya+LRgS5FjmYWQhN1qI/jYWPi8rolJjMt0J8d3iPDm 9qASCYShdhFYSnaUDoFV9BSw3YDVZL73TFGs/RayQdApCxxtVKvBuLFgN689wdEldLeq /mUO1VWLxHKHN7zonE7BzeuspZYluk2QCZ4SuhnU0BLMVNe/r6dW0Tw/XYakHN60XHoN r4yna+QsBrAZMfIkfKlqqiMg6Q19m8bLa7G9xjLEKIegmPwhJ2Txr9wbDLb+CSv/f+M1 NTag==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=W5vao0v+; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-174205-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174205-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2b671471cdcsi863011a91.111.2024.05.08.23.43.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 23:43:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-174205-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=@google.com header.s=20230601 header.b=W5vao0v+; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-174205-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174205-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 C97CC284750 for ; Thu, 9 May 2024 06:43:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5563D8664D; Thu, 9 May 2024 06:43:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="W5vao0v+" Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B44AA7C0AB for ; Thu, 9 May 2024 06:43:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715237010; cv=none; b=BSYJoCz5ZIKk0CpLNPALaukEwfcViosoeS8B8tEZx96gycEPpTNyWWBg9+6LekVnigF2kj3VbQJ8LUDQEH+iC9RMcsQx4NfU0bkv1lYTdS1kwXU+aT6qLfuDii8yugEXRY/ea+E/RrmDJXHrc/qDsrq3Q924sY5wRENqlWbzP2s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715237010; c=relaxed/simple; bh=/g14F37mirIOBKpZB7OIDBv6ttQWhutX0fPcpDZNFYE=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=UDcjqDUcvkRLRitVXJ7I/FRPDjnHzVvLOOewMI8qVyCNO+TIIpCcBE/D3kt6edne/X3TkCX0uJ4GqVni1RAYimBmCE22xKEaiT96PzOc4fE/YdOV3t0NS9osWQsYgF5KHgpnVeIwC/cYly0rtP60dEVuATFGRIT3qEwZxZLx/aQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=W5vao0v+; arc=none smtp.client-ip=209.85.160.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-qt1-f176.google.com with SMTP id d75a77b69052e-439b1c72676so232341cf.1 for ; Wed, 08 May 2024 23:43:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715237007; x=1715841807; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Sfpm2g40k/3k+p/MIEAhjjOe3D3qfwBHw4FyzeD3fNs=; b=W5vao0v+PFFJIUhTvJbBFx2EBc114KA9sro3DSmWhKwvg7TKnrPHz+f1TWESQrygpz lKRZmkBdb8us/lDCihFMbxKdIFLRGyt0A7LfmERc3fwxn14PDYDxhK5dZqQBjUSMjk0B BxGNZwnRtxJE1NVMeTTvyQvFlQejbLM4WEAexDS2kypl7sDQK5qpqXvz9WmV7+8khMGj Q1MTwuzffnQIRC5iUNPiY0jHUjnf8pBQf44kgdjT/3xTUez8pHjldEedH6bYtG+aheZa fyxlXtZpldc/HAlkdfH02YBYDWbxV0f9hwTDhDTJPUY1UQTwX9PWe+BJ6O0v5gcEjJ+7 VFGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715237007; x=1715841807; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Sfpm2g40k/3k+p/MIEAhjjOe3D3qfwBHw4FyzeD3fNs=; b=U9KeF3Jkk0FkjbTe8y/tF2VfyBseI7gQFA82X4iXoiCxbHnH5tJhZ5MtK5f9Ft1egI LHBYDpp8JdUSkaunjuf8jUApf0KuXTmaxZek/hVKmy8FhWGNSrZK+IL7wRuLnkC4xwqZ qnMoW4A7ug8FjGzoYallrohi2MkgF5RjO4sJP3/ZzpaN8sXtV7NdrMUDZ5DHpU2Qfr3j 3BowIWHUgn4bHXacvkiRDZ96ou5ogOTX3CXuyhSjmtzbHpecwXknthQCOPw3T5FH5JiN j7NrjeUyP9ddk/pHqleOKJsr56VhjenKSMFYCdp0/X28uQdBHJNvLerg8etessJAfwWf 4aEg== X-Forwarded-Encrypted: i=1; AJvYcCWhr0ojpLaCBQssQaJVsTtVmoe4oq4q3TKAEtPN5dHR5ZtGf3PNf73GO1J6KJriTnZyL1hH/K1hhbaNzriASjwlfCfbPem2w7VjJ++e X-Gm-Message-State: AOJu0Yza4SN42yfgsalscF7ZKK+zZ6Fwz+krMszMLPmeuc/jwYyIGio/ yYPGafJgNXCxCW/FqVssBBOAhl33wCihZTR/tf++57Ri9i17MshyFc/3WoYc18AXyk5DBjDcRWV D9A14NBNVlNLTA2mh5QjVEeThZUIx9VdzTLXy X-Received: by 2002:ac8:6f1b:0:b0:43d:e001:69bc with SMTP id d75a77b69052e-43df44f9033mr1699781cf.17.1715237006642; Wed, 08 May 2024 23:43:26 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: In-Reply-To: From: Ian Rogers Date: Wed, 8 May 2024 23:43:15 -0700 Message-ID: Subject: Re: [PATCH 1/1] perf probe: Use zfree() to avoid possibly accessing dangling pointers To: Arnaldo Carvalho de Melo Cc: Adrian Hunter , Jiri Olsa , Kan Liang , Namhyung Kim , Linux Kernel Mailing List , linux-perf-users@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, May 7, 2024 at 7:58=E2=80=AFAM Arnaldo Carvalho de Melo wrote: > > When freeing a->b it is good practice to set a->b to NULL using > zfree(&a->b) so that when we have a bug where a reference to a freed 'a' > pointer is kept somewhere, we can more quickly cause a segfault if some > code tries to use a->b. > > Convert one such case in the 'perf probe' codebase. > > Cc: Adrian Hunter > Cc: Ian Rogers > Cc: Jiri Olsa > Cc: Kan Liang > Cc: Namhyung Kim > Signed-off-by: Arnaldo Carvalho de Melo > --- > tools/perf/builtin-probe.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c > index 019fef8da6a8e60f..003a3bcebfdfc2d1 100644 > --- a/tools/perf/builtin-probe.c > +++ b/tools/perf/builtin-probe.c > @@ -325,7 +325,7 @@ static void cleanup_params(void) > for (i =3D 0; i < params->nevents; i++) > clear_perf_probe_event(params->events + i); > line_range__clear(¶ms->line_range); > - free(params->target); > + zfree(¶ms->target); > strfilter__delete(params->filter); > nsinfo__put(params->nsi); > zfree(¶ms); The change is fine but params is freed here, so the potential to read "->target" is small. Reviewed-by: Ian Rogers Thanks, Ian > -- > 2.44.0 >