From nobody Tue Dec 07 23:13:17 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 8293318D0280; Tue, 7 Dec 2021 23:13:26 +0000 (UTC) (envelope-from glebius@freebsd.org) Received: from cell.glebi.us (glebi.us [162.251.186.162]) (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 (2048 bits) client-digest SHA256) (Client CN "cell.glebi.us", Issuer "cell.glebi.us" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4J7x1L0mn6z4QxW; Tue, 7 Dec 2021 23:13:26 +0000 (UTC) (envelope-from glebius@freebsd.org) Received: from cell.glebi.us (localhost [127.0.0.1]) by cell.glebi.us (8.16.1/8.16.1) with ESMTPS id 1B7NDHX5028914 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Tue, 7 Dec 2021 15:13:17 -0800 (PST) (envelope-from glebius@freebsd.org) Received: (from glebius@localhost) by cell.glebi.us (8.16.1/8.16.1/Submit) id 1B7NDHda028913; Tue, 7 Dec 2021 15:13:17 -0800 (PST) (envelope-from glebius@freebsd.org) X-Authentication-Warning: cell.glebi.us: glebius set sender to glebius@freebsd.org using -f Date: Tue, 7 Dec 2021 15:13:17 -0800 From: Gleb Smirnoff To: Hans Petter Selasky Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: e3044071dec1 - main - in6p_set_multicast_if(): fix malloc(M_WAITOK) with epoch Message-ID: References: <202112062236.1B6Ma4e0073785@gitrepo.freebsd.org> 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=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 4J7x1L0mn6z4QxW X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N On Tue, Dec 07, 2021 at 08:36:58AM +0100, Hans Petter Selasky wrote: H> > --- a/sys/netinet6/in6_mcast.c H> > +++ b/sys/netinet6/in6_mcast.c H> > @@ -2454,9 +2454,9 @@ in6p_set_multicast_if(struct inpcb *inp, struct sockopt *sopt) H> > return (EADDRNOTAVAIL); H> > } H> > } H> > + NET_EPOCH_EXIT(et); /* XXXGL: unsafe ifp */ H> > imo = in6p_findmoptions(inp); H> > - imo->im6o_multicast_ifp = ifp; /* XXXGL: reference?! */ H> > - NET_EPOCH_EXIT(et); H> > + imo->im6o_multicast_ifp = ifp; H> > INP_WUNLOCK(inp); H> > H> > return (0); H> > H> H> You can ref the ifp before the EPOCH exit? Sure. The code should use ifnet_byindex_ref(). Note that d74b7baeb0d4 was a sweep commit to "cover" all unsafe uses of ifnet_byindex(). It was not my intent to fix all of them, but rather mark them with a comment and put NET_EPOCH_ASSERT() inside ifnet_byindex() to prevent future unsafe calls. -- Gleb Smirnoff