All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Whitehouse <swhiteho@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 2/4] [DLM] fix a couple of races
Date: Mon, 18 Jun 2007 15:54:28 +0100	[thread overview]
Message-ID: <11821784801162-git-send-email-swhiteho@redhat.com> (raw)
In-Reply-To: <1182178478593-git-send-email-swhiteho@redhat.com>


Fix two races in fs/dlm/config.c:

(1) Grab the configfs subsystem semaphore before calling
config_group_find_obj() in get_space(). This solves a potential race
between get_space() and concurrent mkdir(2) or rmdir(2).

(2) Grab a reference on the found config_item _while_ holding the configfs
subsystem semaphore in get_comm(), and not after it. This solves a
potential race between get_comm() and concurrent rmdir(2).

Signed-off-by: Satyam Sharma <ssatyam@cse.iitk.ac.in>
Signed-off-by: David Teigland <teigland@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
---
 fs/dlm/config.c |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 1f692e48dd1f3fa00629c69b2e34ab35c9929b45.diff
Type: text/x-patch
Size: 1066 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/cluster-devel/attachments/20070618/badca0be/attachment.bin>

WARNING: multiple messages have this Message-ID (diff)
From: Steven Whitehouse <swhiteho@redhat.com>
To: cluster-devel@redhat.com, linux-kernel@vger.kernel.org
Cc: Satyam Sharma <ssatyam@cse.iitk.ac.in>,
	David Teigland <teigland@redhat.com>,
	Steven Whitehouse <swhiteho@redhat.com>
Subject: [PATCH 2/4] [DLM] fix a couple of races
Date: Mon, 18 Jun 2007 15:54:28 +0100	[thread overview]
Message-ID: <11821784801162-git-send-email-swhiteho@redhat.com> (raw)
In-Reply-To: <1182178478593-git-send-email-swhiteho@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 44 bytes --]

This is a multi-part message in MIME format.

[-- Attachment #2: Type: text/plain, Size: 677 bytes --]


Fix two races in fs/dlm/config.c:

(1) Grab the configfs subsystem semaphore before calling
config_group_find_obj() in get_space(). This solves a potential race
between get_space() and concurrent mkdir(2) or rmdir(2).

(2) Grab a reference on the found config_item _while_ holding the configfs
subsystem semaphore in get_comm(), and not after it. This solves a
potential race between get_comm() and concurrent rmdir(2).

Signed-off-by: Satyam Sharma <ssatyam@cse.iitk.ac.in>
Signed-off-by: David Teigland <teigland@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
---
 fs/dlm/config.c |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 1f692e48dd1f3fa00629c69b2e34ab35c9929b45.diff --]
[-- Type: text/x-patch; name="1f692e48dd1f3fa00629c69b2e34ab35c9929b45.diff", Size: 1066 bytes --]

diff --git a/fs/dlm/config.c b/fs/dlm/config.c
index 822abdc..5a3d390 100644
--- a/fs/dlm/config.c
+++ b/fs/dlm/config.c
@@ -748,9 +748,16 @@ static ssize_t node_weight_write(struct node *nd, const char *buf, size_t len)
 
 static struct space *get_space(char *name)
 {
+	struct config_item *i;
+
 	if (!space_list)
 		return NULL;
-	return to_space(config_group_find_obj(space_list, name));
+
+	down(&space_list->cg_subsys->su_sem);
+	i = config_group_find_obj(space_list, name);
+	up(&space_list->cg_subsys->su_sem);
+
+	return to_space(i);
 }
 
 static void put_space(struct space *sp)
@@ -776,20 +783,20 @@ static struct comm *get_comm(int nodeid, struct sockaddr_storage *addr)
 			if (cm->nodeid != nodeid)
 				continue;
 			found = 1;
+			config_item_get(i);
 			break;
 		} else {
 			if (!cm->addr_count ||
 			    memcmp(cm->addr[0], addr, sizeof(*addr)))
 				continue;
 			found = 1;
+			config_item_get(i);
 			break;
 		}
 	}
 	up(&clusters_root.subsys.su_sem);
 
-	if (found)
-		config_item_get(i);
-	else
+	if (!found)
 		cm = NULL;
 	return cm;
 }

  reply	other threads:[~2007-06-18 14:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-18 14:54 [Cluster-devel] [GFS2/DLM] Some small bug fixes Steven Whitehouse
2007-06-18 14:54 ` Steven Whitehouse
2007-06-18 14:54 ` [Cluster-devel] [PATCH 1/4] [GFS2] flush the glock completely in inode_go_sync Steven Whitehouse
2007-06-18 14:54   ` Steven Whitehouse
2007-06-18 14:54   ` Steven Whitehouse [this message]
2007-06-18 14:54     ` [PATCH 2/4] [DLM] fix a couple of races Steven Whitehouse
2007-06-18 14:54     ` [Cluster-devel] [PATCH 3/4] [GFS2] use zero_user_page Steven Whitehouse
2007-06-18 14:54       ` Steven Whitehouse
2007-06-18 14:54       ` [Cluster-devel] [PATCH 4/4] [DLM] keep dlm from panicing when traversing rsb list in debugfs Steven Whitehouse
2007-06-18 14:54         ` Steven Whitehouse
2007-06-18 15:13 ` [Cluster-devel] [GFS2/DLM] Pull request Steven Whitehouse
2007-06-18 15:13   ` Steven Whitehouse
2007-06-18 15:30   ` [Cluster-devel] " Steven Whitehouse
2007-06-18 15:30     ` Steven Whitehouse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11821784801162-git-send-email-swhiteho@redhat.com \
    --to=swhiteho@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.