Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 May 2020 11:01:10 +0000 (UTC)
From:      =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= <royger@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r361274 - head/sys/dev/xen/evtchn
Message-ID:  <202005201101.04KB1AP0009667@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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. */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202005201101.04KB1AP0009667>