DragonFlyBSD Kernel Audit
DF-2877 / fix.diff
← back to finding ↓ download raw
--- a/sys/kern/kern_dmsg.c	2026-09-02 18:33:18.862281095 +0000
+++ b/sys/kern/kern_dmsg.c	2026-09-02 18:33:36.234063474 +0000
@@ -136,11 +136,28 @@
 	/*
 	 * Destroy the current connection
 	 */
+	int retries;
+
+	/*
+	 * Destroy the current connection
+	 */
 	lockmgr(&iocom->msglk, LK_EXCLUSIVE);
 	atomic_set_int(&iocom->msg_ctl, KDMSG_CLUSTERCTL_KILLRX);
+	retries = 10;
 	while (iocom->msgrd_td || iocom->msgwr_td) {
 		wakeup(&iocom->msg_ctl);
 		lksleep(iocom, &iocom->msglk, 0, "clstrkl", hz);
+		/*
+		 * DF-2877: the old reader can be parked in fp_read() on a
+		 * non-cooperating peer socket forever.  Force EOF after
+		 * 10 seconds just like kdmsg_iocom_uninit() does, so this
+		 * ioctl eventually returns instead of deadlocking the
+		 * caller in an unkillable state.
+		 */
+		if (--retries == 0 && iocom->msg_fp) {
+			fp_shutdown(iocom->msg_fp, SHUT_RDWR);
+			/* retries allowed to go negative, keep looping */
+		}
 	}
 
 	/*