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 B5BC9646; Wed, 6 Nov 2024 13:21:17 +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=1730899277; cv=none; b=teL1r/sJABP0Us0xwYCmcWEsdbmHR0dl0owRdqOjxqmpRoalVxyFjiXcy3lxB8RH6fNX2BJRwDpfbaaQU8Y4LslNFc4/+jxV2mYuMNsL1IAg8vhpagEzkgLah6cGJvH1l0k3ZGpi4YN0A6rvUBZ9KTAjq72sdwP6kQy2D4S7YnE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730899277; c=relaxed/simple; bh=/IvEvjuSs9xvmPNqiDfXF5u7Oee48etCPmdsgHEuwaI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o8CM/8CzQNMWHw7YyoVgJzw6IIYnQydAAe8Vo7+Fj7Fmy5aOcOKDNrRXO5C2HR1gxdYo6YV8fgH9Wj6Hg9Og+kkUM7jMMdAS7iTlEIz2kNXc6eMilWXKJLg847EkpX80UfcRBBOur7vrWZQQFav8lZzGat32readFhWqADx9UHo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=XS3fGFov; 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="XS3fGFov" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 127A0C4CECD; Wed, 6 Nov 2024 13:21:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1730899277; bh=/IvEvjuSs9xvmPNqiDfXF5u7Oee48etCPmdsgHEuwaI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XS3fGFovARXlIELBoD9cpinS3zIqOle0nJ+N/6dfowPGNrYmqBAJONptxm4YuP2Ld 0aVTzuTyBOML3I7w7slwzEiPn4JS9b0JsH1aFroOAuIduLy/A0Nx78Yw7plwerCkSZ iksQqDuR6K0r5fjjmIVOptUgF1LEqtW5We6maDY8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Pau Espin Pedrol , Pablo Neira Ayuso , Oliver Smith , Simon Horman , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.15 21/73] gtp: allow -1 to be specified as file description from userspace Date: Wed, 6 Nov 2024 13:05:25 +0100 Message-ID: <20241106120300.594651299@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241106120259.955073160@linuxfoundation.org> References: <20241106120259.955073160@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Pablo Neira Ayuso [ Upstream commit 7515e37bce5c428a56a9b04ea7e96b3f53f17150 ] Existing user space applications maintained by the Osmocom project are breaking since a recent fix that addresses incorrect error checking. Restore operation for user space programs that specify -1 as file descriptor to skip GTPv0 or GTPv1 only sockets. Fixes: defd8b3c37b0 ("gtp: fix a potential NULL pointer dereference") Reported-by: Pau Espin Pedrol Signed-off-by: Pablo Neira Ayuso Tested-by: Oliver Smith Reviewed-by: Simon Horman Link: https://patch.msgid.link/20241022144825.66740-1-pablo@netfilter.org Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/gtp.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c index 40c94df382e54..2509d7bccb2b3 100644 --- a/drivers/net/gtp.c +++ b/drivers/net/gtp.c @@ -858,20 +858,24 @@ static int gtp_encap_enable(struct gtp_dev *gtp, struct nlattr *data[]) unsigned int role = GTP_ROLE_GGSN; if (data[IFLA_GTP_FD0]) { - u32 fd0 = nla_get_u32(data[IFLA_GTP_FD0]); + int fd0 = nla_get_u32(data[IFLA_GTP_FD0]); - sk0 = gtp_encap_enable_socket(fd0, UDP_ENCAP_GTP0, gtp); - if (IS_ERR(sk0)) - return PTR_ERR(sk0); + if (fd0 >= 0) { + sk0 = gtp_encap_enable_socket(fd0, UDP_ENCAP_GTP0, gtp); + if (IS_ERR(sk0)) + return PTR_ERR(sk0); + } } if (data[IFLA_GTP_FD1]) { - u32 fd1 = nla_get_u32(data[IFLA_GTP_FD1]); + int fd1 = nla_get_u32(data[IFLA_GTP_FD1]); - sk1u = gtp_encap_enable_socket(fd1, UDP_ENCAP_GTP1U, gtp); - if (IS_ERR(sk1u)) { - gtp_encap_disable_sock(sk0); - return PTR_ERR(sk1u); + if (fd1 >= 0) { + sk1u = gtp_encap_enable_socket(fd1, UDP_ENCAP_GTP1U, gtp); + if (IS_ERR(sk1u)) { + gtp_encap_disable_sock(sk0); + return PTR_ERR(sk1u); + } } } -- 2.43.0