Module Name:    src
Committed By:   ad
Date:           Sun Dec 22 15:15:20 UTC 2019

Modified Files:
        src/sys/arch/x86/x86: pmap.c

Log Message:
pmap_get_ptp(): the uvm_pagefree() call in the failure case can block too.
Pacify the assertion in pmap_unmap_ptes().

XXX Revisit and solve this chicken-and-egg problem in a more elegant way.

Reported-by: syzbot+24967905b8d173445...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.347 -r1.348 src/sys/arch/x86/x86/pmap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/x86/x86/pmap.c
diff -u src/sys/arch/x86/x86/pmap.c:1.347 src/sys/arch/x86/x86/pmap.c:1.348
--- src/sys/arch/x86/x86/pmap.c:1.347	Sat Dec 21 13:00:24 2019
+++ src/sys/arch/x86/x86/pmap.c	Sun Dec 22 15:15:20 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.347 2019/12/21 13:00:24 ad Exp $	*/
+/*	$NetBSD: pmap.c,v 1.348 2019/12/22 15:15:20 ad Exp $	*/
 
 /*
  * Copyright (c) 2008, 2010, 2016, 2017, 2019 The NetBSD Foundation, Inc.
@@ -130,7 +130,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.347 2019/12/21 13:00:24 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.348 2019/12/22 15:15:20 ad Exp $");
 
 #include "opt_user_ldt.h"
 #include "opt_lockdebug.h"
@@ -2120,8 +2120,6 @@ pmap_get_ptp(struct pmap *pmap, vaddr_t 
 			pt[i].new = true;
 			if (__predict_false(ncsw != lwp_pctr())) {
 				/* uvm_pagealloc can block. */
-				/* XXX silence assertion in pmap_unmap_ptes */
-				pmap->pm_ncsw = lwp_pctr();
 				error = EAGAIN;
 				goto fail;
 			}
@@ -2195,9 +2193,10 @@ fail:
 		if (!pt[i].new) {
 			continue;
 		}
-		obj = &pmap->pm_obj[i - 2];
 		uvm_pagefree(pt[i].pg);
 	}
+	/* XXX silence assertion in pmap_unmap_ptes */
+	pmap->pm_ncsw = lwp_pctr();
 	return error;
 }
 

Reply via email to