From owner-svn-src-all@freebsd.org Mon Nov 26 11:51:45 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 71C2D115678A; Mon, 26 Nov 2018 11:51:45 +0000 (UTC) (envelope-from eugen@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 16AAF6F43B; Mon, 26 Nov 2018 11:51:45 +0000 (UTC) (envelope-from eugen@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EBD733407; Mon, 26 Nov 2018 11:51:44 +0000 (UTC) (envelope-from eugen@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id wAQBpi0A041073; Mon, 26 Nov 2018 11:51:44 GMT (envelope-from eugen@FreeBSD.org) Received: (from eugen@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id wAQBpi3v041072; Mon, 26 Nov 2018 11:51:44 GMT (envelope-from eugen@FreeBSD.org) Message-Id: <201811261151.wAQBpi3v041072@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eugen set sender to eugen@FreeBSD.org using -f From: Eugene Grosbein Date: Mon, 26 Nov 2018 11:51:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r340957 - stable/10/sys/netinet X-SVN-Group: stable-10 X-SVN-Commit-Author: eugen X-SVN-Commit-Paths: stable/10/sys/netinet X-SVN-Commit-Revision: 340957 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 16AAF6F43B X-Spamd-Result: default: False [1.11 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_SHORT(-0.07)[-0.068,0]; NEURAL_SPAM_LONG(0.61)[0.611,0]; NEURAL_SPAM_MEDIUM(0.56)[0.562,0] X-Rspamd-Server: mx1.freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Nov 2018 11:51:45 -0000 Author: eugen Date: Mon Nov 26 11:51:44 2018 New Revision: 340957 URL: https://svnweb.freebsd.org/changeset/base/340957 Log: Prevent multicast code from panicing due to unprotected access to INADDR_HASH. This is direct commit to stable/10 instead of MFC r339807 due to significant difference in code base. PR: 220078 Tested-by: Cassiano Peixoto and others Modified: stable/10/sys/netinet/in_mcast.c Modified: stable/10/sys/netinet/in_mcast.c ============================================================================== --- stable/10/sys/netinet/in_mcast.c Mon Nov 26 11:32:22 2018 (r340956) +++ stable/10/sys/netinet/in_mcast.c Mon Nov 26 11:51:44 2018 (r340957) @@ -1339,9 +1339,11 @@ inp_block_unblock_source(struct inpcb *inp, struct soc ssa->sin.sin_len = sizeof(struct sockaddr_in); ssa->sin.sin_addr = mreqs.imr_sourceaddr; - if (!in_nullhost(mreqs.imr_interface)) + if (!in_nullhost(mreqs.imr_interface)) { + IN_IFADDR_RLOCK(); INADDR_TO_IFP(mreqs.imr_interface, ifp); - + IN_IFADDR_RUNLOCK(); + } if (sopt->sopt_name == IP_BLOCK_SOURCE) doblock = 1; @@ -1836,7 +1838,6 @@ inp_getmoptions(struct inpcb *inp, struct sockopt *sop * * Returns NULL if no ifp could be found. * - * SMPng: TODO: Acquire the appropriate locks for INADDR_TO_IFP. * FUTURE: Implement IPv4 source-address selection. */ static struct ifnet * @@ -1851,7 +1852,9 @@ inp_lookup_mcast_ifp(const struct inpcb *inp, ifp = NULL; if (!in_nullhost(ina)) { + IN_IFADDR_RLOCK(); INADDR_TO_IFP(ina, ifp); + IN_IFADDR_RUNLOCK(); } else { struct route ro; @@ -2247,9 +2250,11 @@ inp_leave_group(struct inpcb *inp, struct sockopt *sop * XXX NOTE WELL: The RFC 3678 API is preferred because * using an IPv4 address as a key is racy. */ - if (!in_nullhost(mreqs.imr_interface)) + if (!in_nullhost(mreqs.imr_interface)) { + IN_IFADDR_RLOCK(); INADDR_TO_IFP(mreqs.imr_interface, ifp); - + IN_IFADDR_RUNLOCK(); + } CTR3(KTR_IGMPV3, "%s: imr_interface = %s, ifp = %p", __func__, inet_ntoa(mreqs.imr_interface), ifp); @@ -2447,7 +2452,9 @@ inp_set_multicast_if(struct inpcb *inp, struct sockopt if (in_nullhost(addr)) { ifp = NULL; } else { + IN_IFADDR_RLOCK(); INADDR_TO_IFP(addr, ifp); + IN_IFADDR_RUNLOCK(); if (ifp == NULL) return (EADDRNOTAVAIL); }