From: Simon Horman <horms@kernel.org>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org,
pabeni@redhat.com, edumazet@google.com, fw@strlen.de,
pespin@sysmocom.de, laforge@gnumonks.org,
osmocom-net-gprs@lists.osmocom.org,
Cong Wang <cong.wang@bytedance.com>,
Andrew Lunn <andrew+netdev@lunn.ch>
Subject: Re: [PATCH net] gtp: allow -1 to be specified as file description from userspace
Date: Thu, 24 Oct 2024 13:30:51 +0100 [thread overview]
Message-ID: <20241024123051.GL1202098@kernel.org> (raw)
In-Reply-To: <20241022144825.66740-1-pablo@netfilter.org>
+ Cong and Andrew
On Tue, Oct 22, 2024 at 04:48:25PM +0200, Pablo Neira Ayuso wrote:
> 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 <pespin@sysmocom.de>
> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Reviewed-by: Simon Horman <horms@kernel.org>
> ---
> 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 a60bfb1abb7f..70f981887518 100644
> --- a/drivers/net/gtp.c
> +++ b/drivers/net/gtp.c
> @@ -1702,20 +1702,24 @@ static int gtp_encap_enable(struct gtp_dev *gtp, struct nlattr *data[])
> return -EINVAL;
>
> 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.30.2
>
>
next prev parent reply other threads:[~2024-10-24 12:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-22 14:48 [PATCH net] gtp: allow -1 to be specified as file description from userspace Pablo Neira Ayuso
2024-10-23 9:26 ` Oliver Smith
2024-10-24 12:30 ` Simon Horman [this message]
2024-10-29 18:30 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241024123051.GL1202098@kernel.org \
--to=horms@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=cong.wang@bytedance.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=kuba@kernel.org \
--cc=laforge@gnumonks.org \
--cc=netdev@vger.kernel.org \
--cc=osmocom-net-gprs@lists.osmocom.org \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
--cc=pespin@sysmocom.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).