Lines Matching +full:use +full:- +full:guard +full:- +full:pages
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
8 * Redistribution and use in source and binary forms, with or without
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 * which provides ElectricFence-style memory barrier protection on
34 * objects being allocated, and is used to detect tampering-after-free
90 if (error != 0 || req->newptr == NULL) in memguard_sysctl_desc()
132 &memguard_fail_pgs, 0, "MemGuard failures due to lack of pages");
141 "\t0x001 - add guard pages around each allocation\n"
142 "\t0x002 - always use MemGuard for allocations over a page\n"
143 "\t0x004 - guard uma(9) zones with UMA_ZONE_NOFREE flag");
172 parent_size = vm_map_max(parent_map) - vm_map_min(parent_map) + in memguard_fudge()
179 * Limit consumption of physical pages to in memguard_fudge()
183 * using up memory, since most malloc(9) calls are sub-page. in memguard_fudge()
188 * We want as much KVA as we can take safely. Use at most our in memguard_fudge()
191 * pagetable pages (size must be multiple of PAGE_SIZE). in memguard_fudge()
261 panic("MemGuard detected double-free of %p", (void *)va); in v2sizep()
263 KASSERT(vm_page_wired(p) && p->a.queue == PQ_NONE, in v2sizep()
265 return (&p->plinks.memguard.p); in v2sizep()
276 panic("MemGuard detected double-free of %p", (void *)va); in v2sizev()
278 KASSERT(vm_page_wired(p) && p->a.queue == PQ_NONE, in v2sizev()
280 return (&p->plinks.memguard.v); in v2sizev()
300 * request 2 extra pages of KVA. Save the value of memguard_options in memguard_alloc()
301 * so that we use a consistent value throughout this function. in memguard_alloc()
309 * When we pass our memory limit, reject sub-page allocations. in memguard_alloc()
310 * Page-size and larger allocations will use the same amount in memguard_alloc()
323 * the likelihood of catching a use-after-free. in memguard_alloc()
346 memguard_wasted += (PAGE_SIZE - req_size); in memguard_alloc()
354 addr += (PAGE_SIZE - req_size); in memguard_alloc()
388 * catching a double-free, but not necessarily a in memguard_free()
389 * tamper-after-free (the second thread freeing might not in memguard_free()
400 * above, it's not really any worse. We want to use the in memguard_free()
406 addr -= PAGE_SIZE; in memguard_free()
409 memguard_wasted -= (PAGE_SIZE - req_size); in memguard_free()
413 * Re-allocate an allocation that was originally guarded.
468 return (strcmp(mtp->ks_shortdesc, vm_memguard_desc) == 0); in memguard_cmp_mtp()
479 if (strcmp(mtp->ks_shortdesc, vm_memguard_desc) == 0) { in memguard_cmp_mtp()
492 zone->uz_flags & UMA_ZONE_NOFREE) in memguard_cmp_zone()
495 if (memguard_cmp(zone->uz_size)) in memguard_cmp_zone()
502 return (strcmp(zone->uz_name, vm_memguard_desc) == 0); in memguard_cmp_zone()