svn commit: r361274 - head/sys/dev/xen/evtchn

Roger Pau Monné royger at FreeBSD.org
Wed May 20 11:01:10 UTC 2020


Author: royger
Date: Wed May 20 11:01:10 2020
New Revision: 361274
URL: https://svnweb.freebsd.org/changeset/base/361274

Log:
  dev/xenstore: fix return with locks held
  
  Fix returning from xenstore device with locks held, which triggers the
  following panic:
  
  # cat /dev/xen/xenstore
  ^C
  userret: returning with the following locks held:
  exclusive sx evtchn_ringc_sx (evtchn_ringc_sx) r = 0 (0xfffff8000650be40) locked @ /usr/src/sys/dev/xen/evtchn/evtchn_dev.c:262
  
  Note this is not a security issue since access to the device is
  limited to root by default.
  
  Sponsored by:	Citrix Systems R&D
  MFC after:	1 week

Modified:
  head/sys/dev/xen/evtchn/evtchn_dev.c

Modified: head/sys/dev/xen/evtchn/evtchn_dev.c
==============================================================================
--- head/sys/dev/xen/evtchn/evtchn_dev.c	Wed May 20 08:15:09 2020	(r361273)
+++ head/sys/dev/xen/evtchn/evtchn_dev.c	Wed May 20 11:01:10 2020	(r361274)
@@ -261,9 +261,10 @@ evtchn_read(struct cdev *dev, struct uio *uio, int iof
 
 	sx_xlock(&u->ring_cons_mutex);
 	for (;;) {
-		error = EFBIG;
-		if (u->ring_overflow)
+		if (u->ring_overflow) {
+			error = EFBIG;
 			goto unlock_out;
+		}
 
 		c = u->ring_cons;
 		p = u->ring_prod;
@@ -271,13 +272,13 @@ evtchn_read(struct cdev *dev, struct uio *uio, int iof
 			break;
 
 		if (ioflag & IO_NDELAY) {
-			sx_xunlock(&u->ring_cons_mutex);
-			return (EWOULDBLOCK);
+			error = EWOULDBLOCK;
+			goto unlock_out;
 		}
 
 		error = sx_sleep(u, &u->ring_cons_mutex, PCATCH, "evtchw", 0);
 		if ((error != 0) && (error != EWOULDBLOCK))
-			return (error);
+			goto unlock_out;
 	}
 
 	/* Byte lengths of two chunks. Chunk split (if any) is at ring wrap. */


More information about the svn-src-head mailing list