From owner-dev-commits-src-all@freebsd.org Wed Jun 23 20:35:19 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 735F1656E3A; Wed, 23 Jun 2021 20:35:19 +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 4G9FPz1hfxz3qZv; Wed, 23 Jun 2021 20:35:18 +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 15NKZHUt020728 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 23 Jun 2021 13:35:17 -0700 (PDT) (envelope-from glebius@freebsd.org) Received: (from glebius@localhost) by cell.glebi.us (8.16.1/8.16.1/Submit) id 15NKZHRC020727; Wed, 23 Jun 2021 13:35:17 -0700 (PDT) (envelope-from glebius@freebsd.org) X-Authentication-Warning: cell.glebi.us: glebius set sender to glebius@freebsd.org using -f Date: Wed, 23 Jun 2021 13:35:17 -0700 From: Gleb Smirnoff To: Warner Losh , 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: References: <202106231641.15NGf1xH083695@gitrepo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202106231641.15NGf1xH083695@gitrepo.freebsd.org> X-Rspamd-Queue-Id: 4G9FPz1hfxz3qZv X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Jun 2021 20:35:19 -0000 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