From owner-svn-src-all@freebsd.org Mon Jul 30 11:41:52 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CDA881053708; Mon, 30 Jul 2018 11:41:52 +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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7F64B9548A; Mon, 30 Jul 2018 11:41:52 +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 608DF23DE4; Mon, 30 Jul 2018 11:41:52 +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 w6UBfqv7093192; Mon, 30 Jul 2018 11:41:52 GMT (envelope-from royger@FreeBSD.org) Received: (from royger@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6UBfq4j093191; Mon, 30 Jul 2018 11:41:52 GMT (envelope-from royger@FreeBSD.org) Message-Id: <201807301141.w6UBfq4j093191@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: Mon, 30 Jul 2018 11:41:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r336897 - head/sys/dev/xen/grant_table X-SVN-Group: head X-SVN-Commit-Author: royger X-SVN-Commit-Paths: head/sys/dev/xen/grant_table X-SVN-Commit-Revision: 336897 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.27 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: Mon, 30 Jul 2018 11:41:53 -0000 Author: royger Date: Mon Jul 30 11:41:51 2018 New Revision: 336897 URL: https://svnweb.freebsd.org/changeset/base/336897 Log: xen/grants: fix deadlocks in the free callbacks This fixes the panic caused by deadlocking when grant-table free callbacks are used. The cause of the recursion is: check_free_callbacks() is always called with the lock gnttab_list_lock held. In turn the callback function is also called with the lock held. Then when the client uses any of the grant reference methods which also attempt the lock the gnttab_list_lock mutex from within the free callback a deadlock happens. Fix this by making the gnttab_list_lock recursive. Submitted by: Pratyush Yadav Differential Revision: https://reviews.freebsd.org/D16505 Modified: head/sys/dev/xen/grant_table/grant_table.c Modified: head/sys/dev/xen/grant_table/grant_table.c ============================================================================== --- head/sys/dev/xen/grant_table/grant_table.c Mon Jul 30 11:27:51 2018 (r336896) +++ head/sys/dev/xen/grant_table/grant_table.c Mon Jul 30 11:41:51 2018 (r336897) @@ -585,7 +585,7 @@ gnttab_expand(unsigned int req_entries) return (error); } -MTX_SYSINIT(gnttab, &gnttab_list_lock, "GNTTAB LOCK", MTX_DEF); +MTX_SYSINIT(gnttab, &gnttab_list_lock, "GNTTAB LOCK", MTX_DEF | MTX_RECURSE); /*------------------ Private Device Attachment Functions --------------------*/ /**