00b2b3
--- subversion-1.10.2/subversion/libsvn_repos/authz.c	
00b2b3
+++ subversion-1.10.2/subversion/libsvn_repos/authz.c	
00b2b3
@@ -130,6 +130,30 @@
00b2b3
 static svn_object_pool__t *filtered_pool = NULL;
00b2b3
 static svn_atomic_t authz_pool_initialized = FALSE;
00b2b3
 
00b2b3
+/*
00b2b3
+ * Ensure that we will initialize authz again if the pool which
00b2b3
+ * our authz caches depend on is cleared.
00b2b3
+ *
00b2b3
+ * HTTPD may run pre/post config hooks multiple times and clear
00b2b3
+ * its global configuration pool which our authz pools depend on.
00b2b3
+ * This happens in a non-threaded context during HTTPD's intialization
00b2b3
+ * and HTTPD's main loop, so it is safe to reset static variables here.
00b2b3
+ * (And any applications which cleared this pool while SVN threads
00b2b3
+ * were running would crash no matter what.)
00b2b3
+ *
00b2b3
+ * See issue #4880, "Use-after-free of object-pools in
00b2b3
+ * subversion/libsvn_repos/authz.c when used as httpd module"
00b2b3
+ */
00b2b3
+static apr_status_t
00b2b3
+deinit_authz(void *data)
00b2b3
+{
00b2b3
+  /* The two object pools run their own cleanup handlers. */
00b2b3
+  authz_pool = NULL;
00b2b3
+  filtered_pool = NULL;
00b2b3
+  authz_pool_initialized = FALSE;
00b2b3
+  return APR_SUCCESS;
00b2b3
+}
00b2b3
+
00b2b3
 /* Implements svn_atomic__err_init_func_t. */
00b2b3
 static svn_error_t *
00b2b3
 synchronized_authz_initialize(void *baton, apr_pool_t *pool)
00b2b3
@@ -143,6 +167,7 @@
00b2b3
   SVN_ERR(svn_object_pool__create(&authz_pool, multi_threaded, pool));
00b2b3
   SVN_ERR(svn_object_pool__create(&filtered_pool, multi_threaded, pool));
00b2b3
 
00b2b3
+  apr_pool_cleanup_register(pool, NULL, deinit_authz, apr_pool_cleanup_null);
00b2b3
   return SVN_NO_ERROR;
00b2b3
 }
00b2b3