From mboxrd@z Thu Jan 1 00:00:00 1970 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 9FC1A183CD8; Sun, 1 Sep 2024 16:44:21 +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=1725209061; cv=none; b=d/dhl7TqO8rcAC2tEpspxwjyG5slzZK0IBlvIaIlTk/J4XGagyvDJY6V5kUMXKu7LR80gn8bRAX3kOqDTUKmgAZErKkeOkInzfjI3DMN59vxIjaVOEw+D6i4RuoorRzvHZHslNom4I3mk4QyWbjFXlYj+hEO2Api0PeK+Bd/Ano= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725209061; c=relaxed/simple; bh=0SY4URKGNlxbQots0TvNFh5nz5YSdXt3LkeAqXHeAv4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EmDijzHcXwbe12e1XxDQwZoGSIdKJxw9qcLySwCEsT5Zc/HyhUsQWPd2en1j0szmxOtlG9DIaKVQTz+JGcjqa0pryAt3i3hh0x+mXcOQ4iZHtEtHofJNZZDJN/J8IQCzyvgA4DjB8SenpFCqiV7KPyPQSdLy+Qjh5sAUMdKR3Rs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=S8raSop4; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="S8raSop4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0DBAEC4CEC4; Sun, 1 Sep 2024 16:44:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1725209061; bh=0SY4URKGNlxbQots0TvNFh5nz5YSdXt3LkeAqXHeAv4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S8raSop4IaGLExl3kdAV0RiaTlX+e7lvdF5cpkKMsmpqsmPzdfkK4FWo9sV9Zyf4X QEojuVQHVvAu5hssmr0iJbCvsxfTX38V3XNgaUQJQJTibW3FWgdz6Wkxr6Lc0Isz2T lpaQ/B89kJKAA/swiukq2dw819HvHPbWqKdmrEeY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Andreas Schultz , Harald Welte , Cong Wang , Simon Horman , Pablo Neira Ayuso , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.4 120/134] gtp: fix a potential NULL pointer dereference Date: Sun, 1 Sep 2024 18:17:46 +0200 Message-ID: <20240901160814.597857382@linuxfoundation.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240901160809.752718937@linuxfoundation.org> References: <20240901160809.752718937@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Cong Wang [ Upstream commit defd8b3c37b0f9cb3e0f60f47d3d78d459d57fda ] When sockfd_lookup() fails, gtp_encap_enable_socket() returns a NULL pointer, but its callers only check for error pointers thus miss the NULL pointer case. Fix it by returning an error pointer with the error code carried from sockfd_lookup(). (I found this bug during code inspection.) Fixes: 1e3a3abd8b28 ("gtp: make GTP sockets in gtp_newlink optional") Cc: Andreas Schultz Cc: Harald Welte Signed-off-by: Cong Wang Reviewed-by: Simon Horman Reviewed-by: Pablo Neira Ayuso Link: https://patch.msgid.link/20240825191638.146748-1-xiyou.wangcong@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/gtp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c index ce61c2b9ada8d..c868f4ffa240f 100644 --- a/drivers/net/gtp.c +++ b/drivers/net/gtp.c @@ -807,7 +807,7 @@ static struct sock *gtp_encap_enable_socket(int fd, int type, sock = sockfd_lookup(fd, &err); if (!sock) { pr_debug("gtp socket fd=%d not found\n", fd); - return NULL; + return ERR_PTR(err); } sk = sock->sk; -- 2.43.0