From owner-svn-src-all@freebsd.org Wed May 20 11:01:10 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B7DE72CDC9E; Wed, 20 May 2020 11:01:10 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49RqYf4VyMz43xb; Wed, 20 May 2020 11:01:10 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 9621A1ADCD; Wed, 20 May 2020 11:01:10 +0000 (UTC) (envelope-from royger@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 04KB1Ak1009668; Wed, 20 May 2020 11:01:10 GMT (envelope-from royger@FreeBSD.org) Received: (from royger@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 04KB1AP0009667; Wed, 20 May 2020 11:01:10 GMT (envelope-from royger@FreeBSD.org) Message-Id: <202005201101.04KB1AP0009667@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: royger set sender to royger@FreeBSD.org using -f From: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Date: Wed, 20 May 2020 11:01:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r361274 - head/sys/dev/xen/evtchn X-SVN-Group: head X-SVN-Commit-Author: royger X-SVN-Commit-Paths: head/sys/dev/xen/evtchn X-SVN-Commit-Revision: 361274 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 May 2020 11:01:10 -0000 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. */