From owner-freebsd-current@FreeBSD.ORG Thu Mar 26 19:44:35 2015 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1C288773 for ; Thu, 26 Mar 2015 19:44:35 +0000 (UTC) Received: from forward5l.mail.yandex.net (forward5l.mail.yandex.net [IPv6:2a02:6b8:0:1819::5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "forwards.mail.yandex.net", Issuer "Certum Level IV CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A0EBCE70 for ; Thu, 26 Mar 2015 19:44:34 +0000 (UTC) Received: from smtp13.mail.yandex.net (smtp13.mail.yandex.net [95.108.130.68]) by forward5l.mail.yandex.net (Yandex) with ESMTP id 2D3A4C41224; Thu, 26 Mar 2015 22:44:22 +0300 (MSK) Received: from smtp13.mail.yandex.net (localhost [127.0.0.1]) by smtp13.mail.yandex.net (Yandex) with ESMTP id AFE52E402A7; Thu, 26 Mar 2015 22:44:21 +0300 (MSK) Received: from unknown (unknown [2a02:6b8:0:4::a]) by smtp13.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id HB130bnazH-iLKilNe8; Thu, 26 Mar 2015 22:44:21 +0300 (using TLSv1.2 with cipher AES128-SHA (128/128 bits)) (Client certificate not present) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1427399061; bh=hthE3VcY6jOv6Aw9vIqghUm64zXZo8lIy/IRwDKvNsU=; h=Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: References:In-Reply-To:Content-Type; b=PSkgXplbE/meSji0kne09R2GUHksMdKvfbqr/hZ5EK8BSwCvIf5gifAaisp3u/K1n EXEuzV/BYiKXoN6JqtMVir7JO6Sr88iNrP6lJ2qlKOxPAK2SSH5GPBv+g/BrLldChK fBVhn2h+Rn5/h/YoK3jYo2Eg5GT2rXqq4dV+idGo= Authentication-Results: smtp13.mail.yandex.net; dkim=pass header.i=@yandex.ru Message-ID: <55146124.2070501@yandex.ru> Date: Thu, 26 Mar 2015 22:42:28 +0300 From: "Andrey V. Elsukov" User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: Alexandre Martins , freebsd-current@freebsd.org Subject: Re: Mbuf leak in if_lagg.c References: <1708955.mQ2X6OUmTD@pc-alex> In-Reply-To: <1708955.mQ2X6OUmTD@pc-alex> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="PEb6dpqKn9b34TnExeL9HcsEBCnfSiNiT" X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Mar 2015 19:44:35 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --PEb6dpqKn9b34TnExeL9HcsEBCnfSiNiT Content-Type: multipart/mixed; boundary="------------090404090706090106050304" This is a multi-part message in MIME format. --------------090404090706090106050304 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 19.03.2015 19:31, Alexandre Martins wrote: > Hi ! >=20 > I found a leak of mbuf in the lagg driver : >=20 > https://svnweb.freebsd.org/base/head/sys/net/if_lagg.c?view=3Dannotate#= l1672 >=20 > -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- > m =3D (lp->lp_detaching =3D=3D 0) ? lagg_proto_input(sc, lp, m) : NULL;= > -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- >=20 > If lp_detaching is non 0, the mbuf pointer is set to NULL without m_fre= em it. >=20 > Can you look at this ? Hi, what you thing about this patch? lp_detaching can be non zero in case of parent interface departure. So I don't see the reason to call ETHER_BPF_MTAP() in this case. --=20 WBR, Andrey V. Elsukov --------------090404090706090106050304 Content-Type: text/x-patch; name="if_lagg.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="if_lagg.diff" Index: if_lagg.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- if_lagg.c (revision 280234) +++ if_lagg.c (working copy) @@ -1661,7 +1661,8 @@ lagg_input(struct ifnet *ifp, struct mbuf *m) LAGG_RLOCK(sc, &tracker); if ((scifp->if_drv_flags & IFF_DRV_RUNNING) =3D=3D 0 || (lp->lp_flags & LAGG_PORT_DISABLED) || - sc->sc_proto =3D=3D LAGG_PROTO_NONE) { + sc->sc_proto =3D=3D LAGG_PROTO_NONE || + lp->lp_detaching !=3D 0) { LAGG_RUNLOCK(sc, &tracker); m_freem(m); return (NULL); @@ -1668,9 +1669,7 @@ lagg_input(struct ifnet *ifp, struct mbuf *m) } =20 ETHER_BPF_MTAP(scifp, m); - - m =3D (lp->lp_detaching =3D=3D 0) ? lagg_proto_input(sc, lp, m) : NULL;= - + m =3D lagg_proto_input(sc, lp, m); if (m !=3D NULL) { if (scifp->if_flags & IFF_MONITOR) { m_freem(m); --------------090404090706090106050304-- --PEb6dpqKn9b34TnExeL9HcsEBCnfSiNiT Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJVFGEpAAoJEAHF6gQQyKF6dCkH/jG8RGDPU3ZyUEEbHQvsyfd/ g4SuE6hLm3QRWtg86fgkCDUlGWsAcirMafXcSnk0mGvJXcVjMuLKoRNT/2MNFOFd 56fh9aAWpreuLY/C2aCZf8POf/JK31nx/uAClnegRMvP+pTLsbSF0fQBzGtZVwor 7nsZ8d+sdKMQZlMXWNGXN22gAMXj2yZtltTqn5s6adLKSC1bGwuDWmeH0X+n4Y4b 0sJz6eBGndYddY/IZur76ytmif84D0SdcWd2Uv8Dsp8x8gMNG/CNU+lKL/XeLQVr ifZas6WtcQcSTyegYdimleWnlvwvQ+WIkZ0tmdzLLwP730z418ozMI0Pi+1XgMw= =himj -----END PGP SIGNATURE----- --PEb6dpqKn9b34TnExeL9HcsEBCnfSiNiT--