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 _______________________________________________ dev-commits-src-main@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-main To unsubscribe, send any mail to "dev-commits-src-main-unsubscr...@freebsd.org"