3ce7d3
From 66c074b707318005d50f14910678ba451877a7a6 Mon Sep 17 00:00:00 2001
3ce7d3
From: Petr Mensik <pemensik@redhat.com>
3ce7d3
Date: Wed, 19 Jun 2019 12:28:08 +0200
3ce7d3
Subject: [PATCH] Fix CVE-2019-6471
3ce7d3
3ce7d3
5244.	[security]	Fixed a race condition in dns_dispatch_getnext()
3ce7d3
			that could cause an assertion failure if a
3ce7d3
			significant number of incoming packets were
3ce7d3
			rejected. (CVE-2019-6471) [GL #942]
3ce7d3
---
3ce7d3
 lib/dns/dispatch.c | 10 +++++++---
3ce7d3
 1 file changed, 7 insertions(+), 3 deletions(-)
3ce7d3
3ce7d3
diff --git a/lib/dns/dispatch.c b/lib/dns/dispatch.c
3ce7d3
index 321459ebcb..ae5c9c0fc7 100644
3ce7d3
--- a/lib/dns/dispatch.c
3ce7d3
+++ b/lib/dns/dispatch.c
3ce7d3
@@ -3419,13 +3419,14 @@ dns_dispatch_getnext(dns_dispentry_t *resp, dns_dispatchevent_t **sockevent) {
3ce7d3
 	disp = resp->disp;
3ce7d3
 	REQUIRE(VALID_DISPATCH(disp));
3ce7d3
 
3ce7d3
-	REQUIRE(resp->item_out == ISC_TRUE);
3ce7d3
-	resp->item_out = ISC_FALSE;
3ce7d3
-
3ce7d3
 	ev = *sockevent;
3ce7d3
 	*sockevent = NULL;
3ce7d3
 
3ce7d3
 	LOCK(&disp->lock);
3ce7d3
+
3ce7d3
+	REQUIRE(resp->item_out == ISC_TRUE);
3ce7d3
+	resp->item_out = ISC_FALSE;
3ce7d3
+
3ce7d3
 	if (ev->buffer.base != NULL)
3ce7d3
 		free_buffer(disp, ev->buffer.base, ev->buffer.length);
3ce7d3
 	free_devent(disp, ev);
3ce7d3
@@ -3570,6 +3571,9 @@ dns_dispatch_removeresponse(dns_dispentry_t **resp,
3ce7d3
 		isc_task_send(disp->task[0], &disp->ctlevent);
3ce7d3
 }
3ce7d3
 
3ce7d3
+/*
3ce7d3
+ * disp must be locked.
3ce7d3
+ */
3ce7d3
 static void
3ce7d3
 do_cancel(dns_dispatch_t *disp) {
3ce7d3
 	dns_dispatchevent_t *ev;
3ce7d3
-- 
3ce7d3
2.20.1
3ce7d3