Skip to content

Commit 7515e37

Browse files
ummakyneskuba-moo
authored andcommitted
gtp: allow -1 to be specified as file description from userspace
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: defd8b3 ("gtp: fix a potential NULL pointer dereference") Reported-by: Pau Espin Pedrol <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]> Tested-by: Oliver Smith <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 01e2159 commit 7515e37

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

drivers/net/gtp.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,20 +1702,24 @@ static int gtp_encap_enable(struct gtp_dev *gtp, struct nlattr *data[])
17021702
return -EINVAL;
17031703

17041704
if (data[IFLA_GTP_FD0]) {
1705-
u32 fd0 = nla_get_u32(data[IFLA_GTP_FD0]);
1705+
int fd0 = nla_get_u32(data[IFLA_GTP_FD0]);
17061706

1707-
sk0 = gtp_encap_enable_socket(fd0, UDP_ENCAP_GTP0, gtp);
1708-
if (IS_ERR(sk0))
1709-
return PTR_ERR(sk0);
1707+
if (fd0 >= 0) {
1708+
sk0 = gtp_encap_enable_socket(fd0, UDP_ENCAP_GTP0, gtp);
1709+
if (IS_ERR(sk0))
1710+
return PTR_ERR(sk0);
1711+
}
17101712
}
17111713

17121714
if (data[IFLA_GTP_FD1]) {
1713-
u32 fd1 = nla_get_u32(data[IFLA_GTP_FD1]);
1715+
int fd1 = nla_get_u32(data[IFLA_GTP_FD1]);
17141716

1715-
sk1u = gtp_encap_enable_socket(fd1, UDP_ENCAP_GTP1U, gtp);
1716-
if (IS_ERR(sk1u)) {
1717-
gtp_encap_disable_sock(sk0);
1718-
return PTR_ERR(sk1u);
1717+
if (fd1 >= 0) {
1718+
sk1u = gtp_encap_enable_socket(fd1, UDP_ENCAP_GTP1U, gtp);
1719+
if (IS_ERR(sk1u)) {
1720+
gtp_encap_disable_sock(sk0);
1721+
return PTR_ERR(sk1u);
1722+
}
17191723
}
17201724
}
17211725

0 commit comments

Comments
 (0)