gtp: allow -1 to be specified as file description from userspace
[ 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 <pespin@sysmocom.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Tested-by: Oliver Smith <osmith@sysmocom.de>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20241022144825.66740-1-pablo@netfilter.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
5f6907bf5c
commit
2bb69ce76e
1 changed files with 13 additions and 9 deletions
|
|
@ -848,20 +848,24 @@ static int gtp_encap_enable(struct gtp_dev *gtp, struct nlattr *data[])
|
||||||
unsigned int role = GTP_ROLE_GGSN;
|
unsigned int role = GTP_ROLE_GGSN;
|
||||||
|
|
||||||
if (data[IFLA_GTP_FD0]) {
|
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 (fd0 >= 0) {
|
||||||
if (IS_ERR(sk0))
|
sk0 = gtp_encap_enable_socket(fd0, UDP_ENCAP_GTP0, gtp);
|
||||||
return PTR_ERR(sk0);
|
if (IS_ERR(sk0))
|
||||||
|
return PTR_ERR(sk0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data[IFLA_GTP_FD1]) {
|
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 (fd1 >= 0) {
|
||||||
if (IS_ERR(sk1u)) {
|
sk1u = gtp_encap_enable_socket(fd1, UDP_ENCAP_GTP1U, gtp);
|
||||||
gtp_encap_disable_sock(sk0);
|
if (IS_ERR(sk1u)) {
|
||||||
return PTR_ERR(sk1u);
|
gtp_encap_disable_sock(sk0);
|
||||||
|
return PTR_ERR(sk1u);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue