git: 5019af2e8743 - stable/13 - uma: Never pass cache zones to memguard

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Wed, 26 Oct 2022 00:36:24 UTC
The branch stable/13 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=5019af2e87438bb51c8d345e496418841b680e88

commit 5019af2e87438bb51c8d345e496418841b680e88
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2022-10-19 18:27:49 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2022-10-26 00:35:31 +0000

    uma: Never pass cache zones to memguard
    
    Items allocated from cache zones cannot usefully be protected by
    memguard.
    
    PR:             267151
    Reported and tested by: pho
    
    (cherry picked from commit 2dba2288aa364c36c756770ac77590816b15d954)
---
 sys/vm/uma_core.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c
index 39946849d9ec..e78142294ac9 100644
--- a/sys/vm/uma_core.c
+++ b/sys/vm/uma_core.c
@@ -3471,7 +3471,8 @@ uma_zalloc_debug(uma_zone_t zone, void **itemp, void *udata, int flags)
 #endif
 
 #ifdef DEBUG_MEMGUARD
-	if ((zone->uz_flags & UMA_ZONE_SMR) == 0 && memguard_cmp_zone(zone)) {
+	if ((zone->uz_flags & (UMA_ZONE_SMR | UMA_ZFLAG_CACHE)) == 0 &&
+	    memguard_cmp_zone(zone)) {
 		void *item;
 		item = memguard_alloc(zone->uz_size, flags);
 		if (item != NULL) {
@@ -3506,7 +3507,8 @@ uma_zfree_debug(uma_zone_t zone, void *item, void *udata)
 	    ("uma_zfree_debug: called with spinlock or critical section held"));
 
 #ifdef DEBUG_MEMGUARD
-	if ((zone->uz_flags & UMA_ZONE_SMR) == 0 && is_memguard_addr(item)) {
+	if ((zone->uz_flags & (UMA_ZONE_SMR | UMA_ZFLAG_CACHE)) == 0 &&
+	    is_memguard_addr(item)) {
 		if (zone->uz_dtor != NULL)
 			zone->uz_dtor(item, zone->uz_size, udata);
 		if (zone->uz_fini != NULL)