Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1379397lqa; Mon, 29 Apr 2024 07:05:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXIIBwxTpcMbJO7dkkVC7tA8PhJfA8Zm5cIELEx1jckahkPRkDgpivIitB1j2zokkiN5JZaTDNCM6JqjB2CgHK7fG5vuevLDqboqDOdtQ== X-Google-Smtp-Source: AGHT+IHrFPFQj2eBcT+Kg3Bi9xmWMZjUj4xif0MtWRFdjlD7VGfLcIBZk4kPDh6nt+RKDeWz74LF X-Received: by 2002:a17:90b:297:b0:2a5:7188:9590 with SMTP id az23-20020a17090b029700b002a571889590mr10145966pjb.22.1714399519381; Mon, 29 Apr 2024 07:05:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714399519; cv=pass; d=google.com; s=arc-20160816; b=Vy4Is1RviBE/vYDM8g0AY3enWcQgHCBnOJtSe5nSTHnDuACE3zV/reIigqhov4orsB VWbSrl/mh02qjLdJ7IQHscoZ/Gw3Kvt8Xl+u+3Si58jwzNLSswPELg5Mt77dcDpuBIAS LaOqGtqAhmy6zXzhqJz5zrUJgDtDoK2HanQu86BrT5fzpzj6ZGdCSAnM4Zp5f2+OHq+I qjY3DvKNb3XrlNp5F1tbaoD2DJiRQGQvmpvY8FKWXdWEylVAKDruioBUrMKIoDwtGdX8 BwpOBMQNSouo/t1h9dwpaBzHXpX4LmaUsTn9kZlYzMwl2T1UuHVzzvJ7hUf2dQ4P/uLG dj1w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=93736WusibpjKrqzH2X48w7JaU++N/Btv961FXIQYbo=; fh=8YGvS3FXGfgUnLkctaSfl60nrqC46Xaw7cRyY8lzNAU=; b=xx6xVUiy7FZ3HPsHQs+MNIhypV163YPQpCWqkAZmR5vnUy0cqfwVKA2wpQPuNzX3qi 90GU8CtcfqdYpDE4UDoVEF+vUGKsqx8lchOsSUUtYYsYQC22KEjBz7nGYwg6f3yFkryg MwUeWxkc0vG06tRi4XRFgufoRbN/vSVVWpX5r7Y0XV5JiLbvm8MD8BzY+Znq0/34w/lE NHavgg0uisJthWSQwQVhSK/l6FPPaVo7t5xjGtndvtU8vrDoA48dVAc91C/tcKzqgNqQ uTFYBl6DuSw5KE4z8RgeElAwoK8mQWJSWsFPUFrQCjhBQ5kZ5huEgXQo2ZAEGmXPjL4Y vhUQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="q/zq4hR/"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-162371-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162371-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id i6-20020a17090ad34600b002a2a70f148bsi21232176pjx.69.2024.04.29.07.05.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 07:05:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-162371-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="q/zq4hR/"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-162371-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162371-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 099AAB25406 for ; Mon, 29 Apr 2024 13:29:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 464296E5EF; Mon, 29 Apr 2024 13:29:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="q/zq4hR/" 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 6EDD042055; Mon, 29 Apr 2024 13:29:46 +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=1714397386; cv=none; b=nvOlUoutiYpeGmU1L+DdLjMAiYv0hBJhDpiZj/SwMgMgyAS8wUYh9aIhl26sxm3toZGoN28zj8+pv+4GeSjBvLV/9GvR6q/tOK4RdMkpg0SdE24cRL2n0lhyl8Jo+BqDjLpsrvNw/ff4k9H3PJieS3DyiO6SQ7FiW4kyk2OnoYw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714397386; c=relaxed/simple; bh=Kxu1E0Bn8QjLXrlB4tLuOInXoVo+nyGtr9YUAaoPRWI=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=UMpu2jxYe+U+9DQQw1VfH6A0pchiqTg7uCQyBcvOaeECYFI6bg+cfIfba0i8e76y7t3kiswNmMNALd2cg3JtqX/djl5kIH4SJF2tUM1NKZep40VHI7AY2wl3/XSM2FrL8xpewWMETeCaN6Sk/dyIViX9GwWvnFvszXV8UJW9zGA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=q/zq4hR/; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4207CC113CD; Mon, 29 Apr 2024 13:29:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714397386; bh=Kxu1E0Bn8QjLXrlB4tLuOInXoVo+nyGtr9YUAaoPRWI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=q/zq4hR/PmLGNo3ogSS4jdb5W08EpP8k/4gOgG4dcpMii/LyCbFTTTHgxTaVfi1k7 tKb80RaPN4OcfK/as678HZsXCxEihhSksMHGW5GypsRBMdF7/Q0NxwEKRLWdSaiwf+ d7hLvtK+UpZfPiQtO6ZC3FpgClRFrW6BaFytK5ugODAGwe+WmT5NE7XclugrmBoP+G qj41DcspcamTtJe3nvwHRdC9Swb6UisT/l6JG2Jri8lgtu25gjcH5r5zlFvD0TpW2c ajPJxyYbgs9JkhxGROdZN/t7m8y0+maiczNhp/yijdU3mfhqJoNkd0T8cgUkARiexr 1sneGmDpJiI9w== Date: Mon, 29 Apr 2024 22:29:41 +0900 From: Masami Hiramatsu (Google) To: lumingyindetect@126.com Cc: linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org, rostedt@goodmis.org, mhiramat@kernel.org, mathieu.desnoyers@efficios.com Subject: Re: [PATCH v3] tracing/probes: Fix memory leak in traceprobe_parse_probe_arg_body() Message-Id: <20240429222941.12d3b774bebef484e605d095@kernel.org> In-Reply-To: <20240427072347.1421053-1-lumingyindetect@126.com> References: <20240427072347.1421053-1-lumingyindetect@126.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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=US-ASCII Content-Transfer-Encoding: 7bit Hi LuMing, On Sat, 27 Apr 2024 08:23:47 +0100 lumingyindetect@126.com wrote: > From: LuMingYin > > If traceprobe_parse_probe_arg_body() failed to allocate 'parg->fmt', > it jumps to the label 'out' instead of 'fail' by mistake.In the result, > the buffer 'tmp' is not freed in this case and leaks its memory. > > Thus jump to the label 'fail' in that error case. > Looks good to me. Acked-by: Masami Hiramatsu (Google) Thank you! > Fixes: 032330abd08b ("tracing/probes: Cleanup probe argument parser") > Signed-off-by: LuMingYin > --- > kernel/trace/trace_probe.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c > index c09fa6fc636e..81c319b92038 100644 > --- a/kernel/trace/trace_probe.c > +++ b/kernel/trace/trace_probe.c > @@ -1466,7 +1466,7 @@ static int traceprobe_parse_probe_arg_body(const char *argv, ssize_t *size, > parg->fmt = kmalloc(len, GFP_KERNEL); > if (!parg->fmt) { > ret = -ENOMEM; > - goto out; > + goto fail; > } > snprintf(parg->fmt, len, "%s[%d]", parg->type->fmttype, > parg->count); > -- > 2.25.1 > > -- Masami Hiramatsu (Google)