git: 3f1f6b6ef7f6 - main - tcp, udp: improve input validation in handling bind()
Michael Tuexen
tuexen at FreeBSD.org
Thu Aug 5 13:11:41 UTC 2021
The branch main has been updated by tuexen:
URL: https://cgit.FreeBSD.org/src/commit/?id=3f1f6b6ef7f6fea63583a4b6e917b3cc0f0d525e
commit 3f1f6b6ef7f6fea63583a4b6e917b3cc0f0d525e
Author: Michael Tuexen <tuexen at FreeBSD.org>
AuthorDate: 2021-08-05 11:42:30 +0000
Commit: Michael Tuexen <tuexen at FreeBSD.org>
CommitDate: 2021-08-05 11:48:44 +0000
tcp, udp: improve input validation in handling bind()
Reported by: syzbot+24fcfd8057e9bc339295 at syzkaller.appspotmail.com
Reported by: syzbot+6e90ceb5c89285b2655b at syzkaller.appspotmail.com
Reviewed by: markj, rscheff
MFC after: 3 days
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D31422
---
sys/netinet/tcp_usrreq.c | 1 +
sys/netinet/udp_usrreq.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c
index b1fc584f93b2..bcd7d18d9d62 100644
--- a/sys/netinet/tcp_usrreq.c
+++ b/sys/netinet/tcp_usrreq.c
@@ -326,6 +326,7 @@ tcp_usr_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
* Preserve compatibility with old programs.
*/
if (nam->sa_family != AF_UNSPEC ||
+ nam->sa_len < offsetof(struct sockaddr_in, sin_zero) ||
sinp->sin_addr.s_addr != INADDR_ANY)
return (EAFNOSUPPORT);
nam->sa_family = AF_INET;
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c
index 76ed063391eb..46d687690713 100644
--- a/sys/netinet/udp_usrreq.c
+++ b/sys/netinet/udp_usrreq.c
@@ -1635,6 +1635,7 @@ udp_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
* Preserve compatibility with old programs.
*/
if (nam->sa_family != AF_UNSPEC ||
+ nam->sa_len < offsetof(struct sockaddr_in, sin_zero) ||
sinp->sin_addr.s_addr != INADDR_ANY)
return (EAFNOSUPPORT);
nam->sa_family = AF_INET;
More information about the dev-commits-src-main
mailing list