Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 Jul 2018 11:41:52 +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: r336897 - head/sys/dev/xen/grant_table
Message-ID:  <201807301141.w6UBfq4j093191@repo.freebsd.org>

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



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