Date: Wed, 23 Jun 2021 13:35:17 -0700 From: Gleb Smirnoff <glebius@freebsd.org> To: Warner Losh <imp@freebsd.org>, kp@freebsd.org Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: f13da24715a7 - main - net/bpf: Fix writing of buffer bigger than PAGESIZE Message-ID: <YNObBaVrqLmoS2Ci@FreeBSD.org> In-Reply-To: <202106231641.15NGf1xH083695@gitrepo.freebsd.org> References: <202106231641.15NGf1xH083695@gitrepo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Warner, Kristof, On Wed, Jun 23, 2021 at 04:41:01PM +0000, Warner Losh wrote: W> net/bpf: Fix writing of buffer bigger than PAGESIZE W> W> When allocating the mbuf we used m_get2 which fails W> if len is superior to MJUMPAGESIZE, if its the case, W> use m_getjcl instead. W> W> Reviewed by: kp@ W> PR: 205164 W> Pull Request: https://github.com/freebsd/freebsd-src/pull/131 m_get2() used to provide jumbo mbufs in the past, see 3112ae76449ae0931d207603f14b083627bd731d. IMHO, makes sense to create m_get3() and use it in bpf. What do you think? W> @@ -641,7 +641,15 @@ bpf_movein(struct uio *uio, int linktype, struct ifnet *ifp, struct mbuf **mp, W> if (len < hlen || len - hlen > ifp->if_mtu) W> return (EMSGSIZE); W> W> - m = m_get2(len, M_WAITOK, MT_DATA, M_PKTHDR); W> + /* Allocate a mbuf for our write, since m_get2 fails if len >= to MJUMPAGESIZE, use m_getjcl for bigger buffers */ W> + if (len < MJUMPAGESIZE) W> + m = m_get2(len, M_WAITOK, MT_DATA, M_PKTHDR); W> + else if (len <= MJUM9BYTES) W> + m = m_getjcl(M_WAITOK, MT_DATA, M_PKTHDR, MJUM9BYTES); W> + else if (len <= MJUM16BYTES) W> + m = m_getjcl(M_WAITOK, MT_DATA, M_PKTHDR, MJUM16BYTES); W> + else W> + m = NULL; W> if (m == NULL) W> return (EIO); W> m->m_pkthdr.len = m->m_len = len; -- Gleb Smirnoff
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?YNObBaVrqLmoS2Ci>