Date: Wed, 4 Dec 2019 18:21:29 +0000 (UTC) From: Ryan Libby <rlibby@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r355396 - head/sys/kern Message-ID: <201912041821.xB4ILTv2001696@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: rlibby Date: Wed Dec 4 18:21:29 2019 New Revision: 355396 URL: https://svnweb.freebsd.org/changeset/base/355396 Log: mbuf zones: take out the trash The mbuf zones were explicitly specifying the uma trash procedures on zcreate, conditionally on INVARIANTS, because that used to be necessary in order to get use-after-free checking for uma zones with non-empty constructors or destructors. After r355137 uma automatically invokes the trash constructor and destructor as long as no init and fini are specified. This now allows the mbuf zones to pass their constructors and destructors without needing to add on the uma trash procedures conditionally. Reviewed by: cem, jhb, markj Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D22583 Modified: head/sys/kern/kern_mbuf.c Modified: head/sys/kern/kern_mbuf.c ============================================================================== --- head/sys/kern/kern_mbuf.c Wed Dec 4 17:45:34 2019 (r355395) +++ head/sys/kern/kern_mbuf.c Wed Dec 4 18:21:29 2019 (r355396) @@ -322,12 +322,7 @@ mbuf_init(void *dummy) * Configure UMA zones for Mbufs, Clusters, and Packets. */ zone_mbuf = uma_zcreate(MBUF_MEM_NAME, MSIZE, - mb_ctor_mbuf, mb_dtor_mbuf, -#ifdef INVARIANTS - trash_init, trash_fini, -#else - NULL, NULL, -#endif + mb_ctor_mbuf, mb_dtor_mbuf, NULL, NULL, MSIZE - 1, UMA_ZONE_MAXBUCKET); if (nmbufs > 0) nmbufs = uma_zone_set_max(zone_mbuf, nmbufs); @@ -335,12 +330,7 @@ mbuf_init(void *dummy) uma_zone_set_maxaction(zone_mbuf, mb_reclaim); zone_clust = uma_zcreate(MBUF_CLUSTER_MEM_NAME, MCLBYTES, - mb_ctor_clust, -#ifdef INVARIANTS - trash_dtor, trash_init, trash_fini, -#else - NULL, NULL, NULL, -#endif + mb_ctor_clust, NULL, NULL, NULL, UMA_ALIGN_PTR, 0); if (nmbclusters > 0) nmbclusters = uma_zone_set_max(zone_clust, nmbclusters); @@ -352,12 +342,7 @@ mbuf_init(void *dummy) /* Make jumbo frame zone too. Page size, 9k and 16k. */ zone_jumbop = uma_zcreate(MBUF_JUMBOP_MEM_NAME, MJUMPAGESIZE, - mb_ctor_clust, -#ifdef INVARIANTS - trash_dtor, trash_init, trash_fini, -#else - NULL, NULL, NULL, -#endif + mb_ctor_clust, NULL, NULL, NULL, UMA_ALIGN_PTR, 0); if (nmbjumbop > 0) nmbjumbop = uma_zone_set_max(zone_jumbop, nmbjumbop); @@ -365,12 +350,7 @@ mbuf_init(void *dummy) uma_zone_set_maxaction(zone_jumbop, mb_reclaim); zone_jumbo9 = uma_zcreate(MBUF_JUMBO9_MEM_NAME, MJUM9BYTES, - mb_ctor_clust, -#ifdef INVARIANTS - trash_dtor, trash_init, trash_fini, -#else - NULL, NULL, NULL, -#endif + mb_ctor_clust, NULL, NULL, NULL, UMA_ALIGN_PTR, 0); uma_zone_set_allocf(zone_jumbo9, mbuf_jumbo_alloc); if (nmbjumbo9 > 0) @@ -379,12 +359,7 @@ mbuf_init(void *dummy) uma_zone_set_maxaction(zone_jumbo9, mb_reclaim); zone_jumbo16 = uma_zcreate(MBUF_JUMBO16_MEM_NAME, MJUM16BYTES, - mb_ctor_clust, -#ifdef INVARIANTS - trash_dtor, trash_init, trash_fini, -#else - NULL, NULL, NULL, -#endif + mb_ctor_clust, NULL, NULL, NULL, UMA_ALIGN_PTR, 0); uma_zone_set_allocf(zone_jumbo16, mbuf_jumbo_alloc); if (nmbjumbo16 > 0) @@ -394,11 +369,7 @@ mbuf_init(void *dummy) zone_extpgs = uma_zcreate(MBUF_EXTPGS_MEM_NAME, sizeof(struct mbuf_ext_pgs), -#ifdef INVARIANTS - trash_ctor, trash_dtor, trash_init, trash_fini, -#else NULL, NULL, NULL, NULL, -#endif UMA_ALIGN_CACHE, 0); /* @@ -618,22 +589,12 @@ debugnet_mbuf_reinit(int nmbuf, int nclust, int clsize dn_clsize = clsize; dn_zone_mbuf = uma_zcache_create("debugnet_" MBUF_MEM_NAME, - MSIZE, mb_ctor_mbuf, mb_dtor_mbuf, -#ifdef INVARIANTS - trash_init, trash_fini, -#else - NULL, NULL, -#endif + MSIZE, mb_ctor_mbuf, mb_dtor_mbuf, NULL, NULL, dn_buf_import, dn_buf_release, &dn_mbufq, UMA_ZONE_NOBUCKET); dn_zone_clust = uma_zcache_create("debugnet_" MBUF_CLUSTER_MEM_NAME, - clsize, mb_ctor_clust, -#ifdef INVARIANTS - trash_dtor, trash_init, trash_fini, -#else - NULL, NULL, NULL, -#endif + clsize, mb_ctor_clust, NULL, NULL, NULL, dn_buf_import, dn_buf_release, &dn_clustq, UMA_ZONE_NOBUCKET); @@ -687,9 +648,6 @@ mb_ctor_mbuf(void *mem, int size, void *arg, int how) int flags; short type; -#ifdef INVARIANTS - trash_ctor(mem, size, arg, how); -#endif args = (struct mb_args *)arg; type = args->type; @@ -724,9 +682,6 @@ mb_dtor_mbuf(void *mem, int size, void *arg) KASSERT((m->m_flags & M_NOFREE) == 0, ("%s: M_NOFREE set", __func__)); if (!(flags & MB_DTOR_SKIP) && (m->m_flags & M_PKTHDR) && !SLIST_EMPTY(&m->m_pkthdr.tags)) m_tag_delete_chain(m, NULL); -#ifdef INVARIANTS - trash_dtor(mem, size, arg); -#endif } /* @@ -777,9 +732,6 @@ mb_ctor_clust(void *mem, int size, void *arg, int how) { struct mbuf *m; -#ifdef INVARIANTS - trash_ctor(mem, size, arg, how); -#endif m = (struct mbuf *)arg; if (m != NULL) { m->m_ext.ext_buf = (char *)mem;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201912041821.xB4ILTv2001696>