⬢ DragonFlyBSD Kernel Audit
DF-5793 / fix.diff
← back to finding ↓ download raw
--- a/sys/kern/kern_descrip.c	2026-10-12 19:18:27.811658751 +0000
+++ b/sys/kern/kern_descrip.c	2026-10-12 19:18:27.823658594 +0000
@@ -114,6 +114,7 @@
 static MALLOC_DEFINE(M_SIGIO, "sigio", "sigio structures");
 
 static struct krate krate_uidinfo = { .freq = 1 };
+static struct krate krate_dupres = { .freq = 1 };
 
 static	 d_open_t  fdopen;
 #define NUMFDESC 64
@@ -1143,10 +1144,20 @@
 		if (fdp->fd_files[new].reserved) {
 			spin_unlock(&fdp->fd_spin);
 			fdrop(fp);
-			kprintf("Warning: dup(): target descriptor %d is "
+			krateprintf(&krate_dupres,
+				"Warning: dup(): target descriptor %d is "
 				"reserved, waiting for it to be resolved\n",
 				new);
-			tsleep(fdp, 0, "fdres", hz);
+			/*
+			 * PCATCH: an unbounded uninterruptible retry loop
+			 * makes the caller unkillable while the peer
+			 * thread holds the reservation (e.g. pipe()
+			 * between its two falloc()/fsetfd() pairs, or a
+			 * kmalloc-blocked allocator under memory
+			 * pressure).  Let signals abort the wait.
+			 */
+			if (tsleep(fdp, PCATCH, "fdres", hz) != 0)
+				return (EINTR);
 			goto retry;
 		}