Blame SOURCES/bz1229194-1-quorum-don-t-allow-quorum_trackstart-to-be-called-tw.patch

850067
From 82526d2fe9137e8b604f1bbae6d6e39ba41377f9 Mon Sep 17 00:00:00 2001
850067
From: Christine Caulfield <ccaulfie@redhat.com>
850067
Date: Mon, 16 Mar 2015 11:37:52 +0000
850067
Subject: [PATCH] quorum: don't allow quorum_trackstart to be called twice
850067
850067
If quorum_trackstart() or votequorum_trackstart() are called twice with
850067
CS_TRACK_CHANGES then the client gets added twice to the notifications
850067
list effectively corrupting it. Users have reported segfaults in
850067
corosync when they did this (by mistake!).
850067
850067
As there's already a tracking_enabled flag in the private-data, we check
850067
that before adding to the list again and return an error if
850067
the process is already registered.
850067
850067
Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
850067
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
850067
---
850067
 exec/votequorum.c |   12 ++++++++++--
850067
 exec/vsf_quorum.c |   11 +++++++++--
850067
 2 files changed, 19 insertions(+), 4 deletions(-)
850067
850067
diff --git a/exec/votequorum.c b/exec/votequorum.c
850067
index 2ff0b43..f6faa25 100644
850067
--- a/exec/votequorum.c
850067
+++ b/exec/votequorum.c
850067
@@ -1,5 +1,5 @@
850067
 /*
850067
- * Copyright (c) 2009-2014 Red Hat, Inc.
850067
+ * Copyright (c) 2009-2015 Red Hat, Inc.
850067
  *
850067
  * All rights reserved.
850067
  *
850067
@@ -2615,8 +2615,10 @@ static void message_handler_req_lib_votequorum_trackstart (void *conn,
850067
 	const struct req_lib_votequorum_trackstart *req_lib_votequorum_trackstart = message;
850067
 	struct res_lib_votequorum_status res_lib_votequorum_status;
850067
 	struct quorum_pd *quorum_pd = (struct quorum_pd *)corosync_api->ipc_private_data_get (conn);
850067
+	cs_error_t error = CS_OK;
850067
 
850067
 	ENTER();
850067
+
850067
 	/*
850067
 	 * If an immediate listing of the current cluster membership
850067
 	 * is requested, generate membership list
850067
@@ -2627,6 +2629,11 @@ static void message_handler_req_lib_votequorum_trackstart (void *conn,
850067
 		votequorum_exec_send_quorum_notification(conn, req_lib_votequorum_trackstart->context);
850067
 	}
850067
 
850067
+	if (quorum_pd->tracking_enabled) {
850067
+		error = CS_ERR_EXIST;
850067
+		goto response_send;
850067
+	}
850067
+
850067
 	/*
850067
 	 * Record requests for tracking
850067
 	 */
850067
@@ -2640,9 +2647,10 @@ static void message_handler_req_lib_votequorum_trackstart (void *conn,
850067
 		list_add (&quorum_pd->list, &trackers_list);
850067
 	}
850067
 
850067
+response_send:
850067
 	res_lib_votequorum_status.header.size = sizeof(res_lib_votequorum_status);
850067
 	res_lib_votequorum_status.header.id = MESSAGE_RES_VOTEQUORUM_STATUS;
850067
-	res_lib_votequorum_status.header.error = CS_OK;
850067
+	res_lib_votequorum_status.header.error = error;
850067
 	corosync_api->ipc_response_send(conn, &res_lib_votequorum_status, sizeof(res_lib_votequorum_status));
850067
 
850067
 	LEAVE();
850067
diff --git a/exec/vsf_quorum.c b/exec/vsf_quorum.c
850067
index 2a3a263..a6c739d 100644
850067
--- a/exec/vsf_quorum.c
850067
+++ b/exec/vsf_quorum.c
850067
@@ -1,5 +1,5 @@
850067
 /*
850067
- * Copyright (c) 2008-2012 Red Hat, Inc.
850067
+ * Copyright (c) 2008-2015 Red Hat, Inc.
850067
  *
850067
  * All rights reserved.
850067
  *
850067
@@ -409,6 +409,7 @@ static void message_handler_req_lib_quorum_trackstart (void *conn,
850067
 	const struct req_lib_quorum_trackstart *req_lib_quorum_trackstart = msg;
850067
 	struct qb_ipc_response_header res;
850067
 	struct quorum_pd *quorum_pd = (struct quorum_pd *)corosync_api->ipc_private_data_get (conn);
850067
+	cs_error_t error = CS_OK;
850067
 
850067
 	log_printf(LOGSYS_LEVEL_DEBUG, "got trackstart request on %p", conn);
850067
 
850067
@@ -422,6 +423,11 @@ static void message_handler_req_lib_quorum_trackstart (void *conn,
850067
 		send_library_notification(conn);
850067
 	}
850067
 
850067
+	if (quorum_pd->tracking_enabled) {
850067
+		error = CS_ERR_EXIST;
850067
+		goto response_send;
850067
+	}
850067
+
850067
 	/*
850067
 	 * Record requests for tracking
850067
 	 */
850067
@@ -434,10 +440,11 @@ static void message_handler_req_lib_quorum_trackstart (void *conn,
850067
 		list_add (&quorum_pd->list, &lib_trackers_list);
850067
 	}
850067
 
850067
+response_send:
850067
 	/* send status */
850067
 	res.size = sizeof(res);
850067
 	res.id = MESSAGE_RES_QUORUM_TRACKSTART;
850067
-	res.error = CS_OK;
850067
+	res.error = error;
850067
 	corosync_api->ipc_response_send(conn, &res, sizeof(struct qb_ipc_response_header));
850067
 }
850067
 
850067
-- 
850067
1.7.1
850067