From nobody Thu Dec 16 14:20:46 2021 X-Original-To: dev-commits-src-all@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 B774118F8227; Thu, 16 Dec 2021 14:20:46 +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 4JFDmZ3B4qz55LB; Thu, 16 Dec 2021 14:20:46 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 4E8301748; Thu, 16 Dec 2021 14:20:46 +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 1BGEKk5l073043; Thu, 16 Dec 2021 14:20:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BGEKk9q073042; Thu, 16 Dec 2021 14:20:46 GMT (envelope-from git) Date: Thu, 16 Dec 2021 14:20:46 GMT Message-Id: <202112161420.1BGEKk9q073042@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 014f98b11992 - main - udp: Fix a use-after-free in udp_multi_input() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 014f98b119920d70db774b6c288d1f68a70cc5e0 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639664446; 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=PRpjnswnszK/M1OS0kpovkm7YFO6SPWzoZtl+DL8tjI=; b=GkYJGSK8yBDhyejsGvOheOv8uVGlhnQVwXxTJs+jKoWlRrZS8Mf9Cl5e9tB0IX+qMR1YVs NYcBqlMGnrJMC74a/CPJkqc6FGy+NnDSY6oOKu3yrEkiaSXzjAgDSGfUCbV+jyuLgPicjl 3utPkEUvZ5i4Qu+zcF+zn1o5dcPeP6p02AvWu4mas/lEsDMCoQwbaVFcLOSCwJcNazmnIM 1MiAig9rl50ZHOxwozGiBzFK2ZqvldV9Ip+m+Wqti8Zd+G1/UQwHzhhKpppogIqlAbydkh JOPcYgOqHoxld8fKmpOEqZ6kyS+LoTyIOaA7eDVCKdMe/NKGzAUwEDexazRNsg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639664446; a=rsa-sha256; cv=none; b=Bp4TvHtYP1CJUGYc5dQRWA+/piTlo7FXMlIUlBK3symwiAkXiS4DabF/C7NOHPWBemAal2 pLtzlc52VxPRbAboIxoTNg53akSykfEfcEjXbEx83uM9I0B/7ivA2AaRFEk70AbP/Hb64Q F5mSNW83NLoxHTm4be2Edl4+Z8csCKtspVc9p+yCm8Gg8FfIwzFlGDFz9A3da5L6FYf8G9 C5p5HhK8Kq95HetZirhsQyN9+ksEcvAR+gsGGHF2eoeNEXlxWbrEfNGXM/8p0IeoW8Ttl2 8k/X+18oQ3eDX0TYilM2k/CtoqBM3sFR1Uhd6ZMNLJpQF2N1GMDhqUEmPB21bg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=014f98b119920d70db774b6c288d1f68a70cc5e0 commit 014f98b119920d70db774b6c288d1f68a70cc5e0 Author: Mark Johnston AuthorDate: 2021-12-16 14:08:47 +0000 Commit: Mark Johnston CommitDate: 2021-12-16 14:17:05 +0000 udp: Fix a use-after-free in udp_multi_input() "ip" is a pointer into the input mbuf chain, so we shouldn't access it after the chain is freed. Fix style at the call site while here. Reported by: syzbot+7c8258509722af1b6145@syzkaller.appspotmail.com Reviewed by: tuexen, glebius Fixes: de2d47842e88 ("SMR protection for inpcbs") Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D33473 --- sys/netinet/udp_usrreq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index fe5327b3bd3c..554a042c612e 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -491,7 +491,6 @@ udp_multi_input(struct mbuf *m, int proto, struct sockaddr_in *udp_in) break; } } - m_freem(m); if (appends == 0) { /* @@ -505,6 +504,7 @@ udp_multi_input(struct mbuf *m, int proto, struct sockaddr_in *udp_in) else UDPSTAT_INC(udps_noportbcast); } + m_freem(m); return (IPPROTO_DONE); } @@ -637,7 +637,7 @@ udp_input(struct mbuf **mp, int *offp, int proto) if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) || in_broadcast(ip->ip_dst, ifp)) - return (udp_multi_input(m, proto, udp_in)); + return (udp_multi_input(m, proto, udp_in)); pcbinfo = udp_get_inpcbinfo(proto);