Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 5 Aug 2021 13:11:41 GMT
From:      Michael Tuexen <tuexen@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 3f1f6b6ef7f6 - main - tcp, udp: improve input validation in handling bind()
Message-ID:  <202108051311.175DBfVF013543@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by tuexen:

URL: https://cgit.FreeBSD.org/src/commit/?id=3f1f6b6ef7f6fea63583a4b6e917b3cc0f0d525e

commit 3f1f6b6ef7f6fea63583a4b6e917b3cc0f0d525e
Author:     Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2021-08-05 11:42:30 +0000
Commit:     Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2021-08-05 11:48:44 +0000

    tcp, udp: improve input validation in handling bind()
    
    Reported by:            syzbot+24fcfd8057e9bc339295@syzkaller.appspotmail.com
    Reported by:            syzbot+6e90ceb5c89285b2655b@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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202108051311.175DBfVF013543>