From nobody Tue Feb 22 22:28:08 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id B882619DE5B8; Tue, 22 Feb 2022 22:28:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4K3DMX4nqxz3G3N; Tue, 22 Feb 2022 22:28:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645568888; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CX3YFCOU/xPBnz5VRbYvG2MjKZDJYUzsQi0dRM/FvSM=; b=gXP8FaN7FzEDYQiDgyK961jeoViDSFZOptdgbzldSFXvZcRgQ+0Wu6FWKJFjN5MMNrVjh+ THP55e/GrZ8BIrvY64gzAPTg2kKe6t8piUCPwDicpk6zkJyy9qtqlQbm8vZme0Ja46toy7 omSETZACLbE3NT3w7KITeG/r1KPVpyarkPMSKD9q7SCFXfQXZc0t3x0u3WKHEZ6AsAvOPt YxI0aPFmbNKN9Jqh1rituaWyjva27MypYNAuHRNLFljN7msocAu4skrttLOEswk8J4RzkJ zoEkcPL+ul1Lc9dIOCgCKh8A5P7ocoiYMfB0myTVw26+YLB75dYN/CGdWTelYg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8514F4934; Tue, 22 Feb 2022 22:28:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 21MMS8rO027542; Tue, 22 Feb 2022 22:28:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21MMS8wt027541; Tue, 22 Feb 2022 22:28:08 GMT (envelope-from git) Date: Tue, 22 Feb 2022 22:28:08 GMT Message-Id: <202202222228.21MMS8wt027541@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Michael Tuexen Subject: git: db8fc0ef23d1 - stable/13 - tcp, udp: improve input validation in handling bind() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: db8fc0ef23d14cd281e019ee3a15b1a15931237d Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1645568888; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=CX3YFCOU/xPBnz5VRbYvG2MjKZDJYUzsQi0dRM/FvSM=; b=R+qBcuDGwX/ZKDbomshEwGrbrw0Au2co0xo3u6y/5owsTZiw9Uh1FRxvbpae9y8BxlOVvJ ZtpCPfu44sVZK/1wb8p3507SYsIAomWogryeJKUXPlyPPeqxogjT3n0hLgnpPMe6xJ9d7A zG7+asB8Jmw3vzHoVkkf6z/Ew5S/hNl3NFkSMTGiLDDlfadwUGdeCP0t6H1G2inpDPJ+X5 kC9OBmEG44zAs5rsMKaA5H5n0u7GHuhntvaHRZ1iawsywGmUpvFVpDmXOaiasgcdHjJEHw x4hcHFWvAg6uf2Yrgcw3jAl10VB2PEnYdhgAIwjMWibcDycENTiWdAvHnTzuLQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1645568888; a=rsa-sha256; cv=none; b=PZNDN5uZCA8KSiEA/4Pp16QXK0X7pffz2jtker/iB8D6b/JIWsfg5xJEuKMe0GgLPIHzSI UrEGjJxOjp8sdNqLPSgHnp1MEZofiisyTWfaSg+kb8GykcEceJDh8abno9XIUOovSZ3Z00 0GU+aZObvH0FQ54gYB9e0CIcciO06MhCDsiWpFsItBvEaMazVSWoqG7+fWbIse9zjnXv0p Ng7t3LfPcjnTO3ntWTtRc+e9/l1uIjGap54a2nH2T/OpLh2q7EGFBTK93wsDIXFiTh4xFE 6Op8li/PEf9Wc6c5l50ETXEHXwLz5ZP4RwLPXly5+m7FBIX/csZrltK0fS7oUA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=db8fc0ef23d14cd281e019ee3a15b1a15931237d commit db8fc0ef23d14cd281e019ee3a15b1a15931237d Author: Michael Tuexen AuthorDate: 2021-08-05 11:42:30 +0000 Commit: Michael Tuexen CommitDate: 2022-02-22 22:27:01 +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 Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D31422 (cherry picked from commit 3f1f6b6ef7f6fea63583a4b6e917b3cc0f0d525e) --- 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 cf62eeeb18d5..d48a09533f5f 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;