Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3721604pxb; Mon, 24 Jan 2022 16:18:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJzv1abV9Y9C8yA1BCGIfgeY98sT3sTYmgTO3MBRtcmZLIXV4Sa87QYEmZ65ni8bzY9Dw0ja X-Received: by 2002:a17:903:2287:b0:14a:7280:cff5 with SMTP id b7-20020a170903228700b0014a7280cff5mr17021441plh.46.1643069928122; Mon, 24 Jan 2022 16:18:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643069928; cv=none; d=google.com; s=arc-20160816; b=q8PnQ5nP5dvHBggYFIaZOtf1B487aDe9vHu2dyb99kxm9w5JBV8c3YuH0BLmnWuhz0 o9zX4hwXirEt6pqGN+W8OR8vmZkJZfxb3ZTsoFb5l0FE+ZvG1qWhHf6vqiWRbs87qU/+ yft8OSDlO8FYBx/0VlwZ8s+bUWfR5u6WjAUYHBVWYXzRDskzfj9z10CEfBgP7tV5JqDM FmEPcf+4kjsSB0Eohsit8m0+zjECfaPiDgjPM7OgYRWu+2Jgbh8h7kP9DU0/7eaeLrnu Zm07yfMC0CEaFIDf1/x4/79iUEwApLfiaQgDU1WQg+7c3XewUlYaWV/yg6XawoA/BE6J HSnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vCRwDAV3O8wHxz2cZfeg5MEECZpHHAvBpdJeoH97vNo=; b=1JqX3U6xE5pBV8ArbMdL6zWDAvYDRMRM+8wln015G78GHL3NJ3w4NViSGDX/SxaBii I3kH8e25TKlZ/TdZcfXPvGPAGC6zz85FJhZuAN43qZZschktygHLkxxEayVKzHFJkSH0 N2ykVGOBcwYF7FYwwKhowpZhskMJq9jli/FiJiBGug+1OsUuP9Mnhcyyv/xbHyipHLhT 8ycmTed22JVCNbaKrv0vzI0MG3LMSFUe1MzCAEaMQ7TU4p23RpztbZHPBgtxHTpzRwbi syYEZOXxmEf71O0zAqRIM9LBILm67JZNGYLPmwQFD8aRFhVKw7ds0CjlDxvtq+6O7szd 0WPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HbgEWXaB; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r25si15428920pge.741.2022.01.24.16.18.36; Mon, 24 Jan 2022 16:18:48 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=HbgEWXaB; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2373165AbiAYANP (ORCPT + 99 others); Mon, 24 Jan 2022 19:13:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1850346AbiAXX3o (ORCPT ); Mon, 24 Jan 2022 18:29:44 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 244E4C0A887E; Mon, 24 Jan 2022 13:34:31 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D5036B812A5; Mon, 24 Jan 2022 21:34:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 070CBC36AE2; Mon, 24 Jan 2022 21:34:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643060068; bh=hE1OjF1rUYQ93f+jl9N9Z+d4/F4G4HcNLRNh4ttkmPQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HbgEWXaBinSdVQCi/jl1M6wII2/RDg+jyqz0/b0g9Qb9WB+pBf5R5vmr9G0lKkYyh F392H4l9K88tCtFldIAX8qsxsHSbeEcxRJJvh8ccCvHgWh9RqX1EIT08zoqiePQlAj +SXxPbpQ7MG4cPIdusXf8lAl+SAO9FW7hFaqdQMU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masami Hiramatsu , Xiaoke Wang , Steven Rostedt , Sasha Levin Subject: [PATCH 5.16 0827/1039] tracing/uprobes: Check the return value of kstrdup() for tu->filename Date: Mon, 24 Jan 2022 19:43:36 +0100 Message-Id: <20220124184153.088226680@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiaoke Wang [ Upstream commit 8c7224245557707c613f130431cafbaaa4889615 ] kstrdup() returns NULL when some internal memory errors happen, it is better to check the return value of it so to catch the memory error in time. Link: https://lkml.kernel.org/r/tencent_3C2E330722056D7891D2C83F29C802734B06@qq.com Acked-by: Masami Hiramatsu Fixes: 33ea4b24277b ("perf/core: Implement the 'perf_uprobe' PMU") Signed-off-by: Xiaoke Wang Signed-off-by: Steven Rostedt Signed-off-by: Sasha Levin --- kernel/trace/trace_uprobe.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c index f5f0039d31e5a..78ec1c16ccf4b 100644 --- a/kernel/trace/trace_uprobe.c +++ b/kernel/trace/trace_uprobe.c @@ -1619,6 +1619,11 @@ create_local_trace_uprobe(char *name, unsigned long offs, tu->path = path; tu->ref_ctr_offset = ref_ctr_offset; tu->filename = kstrdup(name, GFP_KERNEL); + if (!tu->filename) { + ret = -ENOMEM; + goto error; + } + init_trace_event_call(tu); ptype = is_ret_probe(tu) ? PROBE_PRINT_RETURN : PROBE_PRINT_NORMAL; -- 2.34.1