|
|
dc8c34 |
From e8b20f785742c611e6073f5e7f6723a8d2d6f264 Mon Sep 17 00:00:00 2001
|
|
|
dc8c34 |
From: Ludwig Krispenz <lkrispen@redhat.com>
|
|
|
dc8c34 |
Date: Tue, 5 Nov 2013 16:58:44 +0100
|
|
|
dc8c34 |
Subject: [PATCH 144/225] Ticket 47577 - crash when removing entries from cache
|
|
|
dc8c34 |
|
|
|
dc8c34 |
Bug Description: when the dn of an entry in the cache was adjusted to the parent dn, for soenm time
|
|
|
dc8c34 |
teh dn was not defined, anothe thread accessing the dn of teh chached entry could crash
|
|
|
dc8c34 |
|
|
|
dc8c34 |
Fix Description: hold the cache mutex when modifyingthe dn of an entry in the cache
|
|
|
dc8c34 |
|
|
|
dc8c34 |
https://fedorahosted.org/389/ticket/47577
|
|
|
dc8c34 |
|
|
|
dc8c34 |
Reviewed by: rmeggins
|
|
|
dc8c34 |
(cherry picked from commit 7272dbda7f43974eed003cbcfc0ddd57fe433687)
|
|
|
dc8c34 |
(cherry picked from commit 1056a6282f246a9c396b8052d726005fe8189512)
|
|
|
dc8c34 |
(cherry picked from commit 00b19f3b4af662341c72fa6cfd60b5e136f1428f)
|
|
|
dc8c34 |
(cherry picked from commit ecc210f3ca25528f5f718680409ded0021d5604c)
|
|
|
dc8c34 |
(cherry picked from commit 85a99e924e16ddc69b8b2cca97550d66f4ea11e0)
|
|
|
dc8c34 |
---
|
|
|
dc8c34 |
ldap/servers/slapd/back-ldbm/back-ldbm.h | 2 ++
|
|
|
dc8c34 |
ldap/servers/slapd/back-ldbm/cache.c | 8 ++++++++
|
|
|
dc8c34 |
ldap/servers/slapd/back-ldbm/id2entry.c | 2 ++
|
|
|
dc8c34 |
ldap/servers/slapd/back-ldbm/proto-back-ldbm.h | 2 ++
|
|
|
dc8c34 |
4 files changed, 14 insertions(+)
|
|
|
dc8c34 |
|
|
|
dc8c34 |
diff --git a/ldap/servers/slapd/back-ldbm/back-ldbm.h b/ldap/servers/slapd/back-ldbm/back-ldbm.h
|
|
|
dc8c34 |
index 9635813..7e5a261 100644
|
|
|
dc8c34 |
--- a/ldap/servers/slapd/back-ldbm/back-ldbm.h
|
|
|
dc8c34 |
+++ b/ldap/servers/slapd/back-ldbm/back-ldbm.h
|
|
|
dc8c34 |
@@ -408,6 +408,8 @@ struct cache {
|
|
|
dc8c34 |
#define CACHE_ADD(cache, p, a) cache_add((cache), (void *)(p), (void **)(a))
|
|
|
dc8c34 |
#define CACHE_RETURN(cache, p) cache_return((cache), (void **)(p))
|
|
|
dc8c34 |
#define CACHE_REMOVE(cache, p) cache_remove((cache), (void *)(p))
|
|
|
dc8c34 |
+#define CACHE_LOCK(cache) cache_lock((cache))
|
|
|
dc8c34 |
+#define CACHE_UNLOCK(cache) cache_unlock((cache))
|
|
|
dc8c34 |
|
|
|
dc8c34 |
/* various modules keep private data inside the attrinfo structure */
|
|
|
dc8c34 |
typedef struct dblayer_private dblayer_private;
|
|
|
dc8c34 |
diff --git a/ldap/servers/slapd/back-ldbm/cache.c b/ldap/servers/slapd/back-ldbm/cache.c
|
|
|
dc8c34 |
index 1c81a1b..d97644f 100644
|
|
|
dc8c34 |
--- a/ldap/servers/slapd/back-ldbm/cache.c
|
|
|
dc8c34 |
+++ b/ldap/servers/slapd/back-ldbm/cache.c
|
|
|
dc8c34 |
@@ -1460,6 +1460,14 @@ int cache_add_tentative(struct cache *cache, struct backentry *e,
|
|
|
dc8c34 |
{
|
|
|
dc8c34 |
return entrycache_add_int(cache, e, ENTRY_STATE_CREATING, alt);
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
+void cache_lock(struct cache *cache)
|
|
|
dc8c34 |
+{
|
|
|
dc8c34 |
+ PR_Lock(cache->c_mutex);
|
|
|
dc8c34 |
+}
|
|
|
dc8c34 |
+void cache_unlock(struct cache *cache)
|
|
|
dc8c34 |
+{
|
|
|
dc8c34 |
+ PR_Unlock(cache->c_mutex);
|
|
|
dc8c34 |
+}
|
|
|
dc8c34 |
|
|
|
dc8c34 |
/* locks an entry so that it can be modified (you should have gotten the
|
|
|
dc8c34 |
* entry via cache_find_*).
|
|
|
dc8c34 |
diff --git a/ldap/servers/slapd/back-ldbm/id2entry.c b/ldap/servers/slapd/back-ldbm/id2entry.c
|
|
|
dc8c34 |
index e278a2a..ea4523d 100644
|
|
|
dc8c34 |
--- a/ldap/servers/slapd/back-ldbm/id2entry.c
|
|
|
dc8c34 |
+++ b/ldap/servers/slapd/back-ldbm/id2entry.c
|
|
|
dc8c34 |
@@ -167,10 +167,12 @@ id2entry_add_ext(backend *be, struct backentry *e, back_txn *txn,
|
|
|
dc8c34 |
if (myparentdn && PL_strcmp(parentdn, myparentdn)) {
|
|
|
dc8c34 |
Slapi_DN *sdn = slapi_entry_get_sdn(e->ep_entry);
|
|
|
dc8c34 |
char *newdn = NULL;
|
|
|
dc8c34 |
+ CACHE_LOCK(&inst->inst_cache);
|
|
|
dc8c34 |
slapi_sdn_done(sdn);
|
|
|
dc8c34 |
newdn = slapi_ch_smprintf("%s,%s", myrdn, parentdn);
|
|
|
dc8c34 |
slapi_sdn_init_dn_passin(sdn, newdn);
|
|
|
dc8c34 |
slapi_sdn_get_ndn(sdn); /* to set ndn */
|
|
|
dc8c34 |
+ CACHE_UNLOCK(&inst->inst_cache);
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
slapi_ch_free_string(&myparentdn);
|
|
|
dc8c34 |
}
|
|
|
dc8c34 |
diff --git a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
|
|
|
dc8c34 |
index 060afe2..d7b88ed 100644
|
|
|
dc8c34 |
--- a/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
|
|
|
dc8c34 |
+++ b/ldap/servers/slapd/back-ldbm/proto-back-ldbm.h
|
|
|
dc8c34 |
@@ -76,6 +76,8 @@ void cache_get_stats(struct cache *cache, PRUint64 *hits, PRUint64 *tries,
|
|
|
dc8c34 |
void cache_debug_hash(struct cache *cache, char **out);
|
|
|
dc8c34 |
int cache_remove(struct cache *cache, void *e);
|
|
|
dc8c34 |
void cache_return(struct cache *cache, void **bep);
|
|
|
dc8c34 |
+void cache_lock(struct cache *cache);
|
|
|
dc8c34 |
+void cache_unlock(struct cache *cache);
|
|
|
dc8c34 |
struct backentry *cache_find_dn(struct cache *cache, const char *dn, unsigned long ndnlen);
|
|
|
dc8c34 |
struct backentry *cache_find_id(struct cache *cache, ID id);
|
|
|
dc8c34 |
struct backentry *cache_find_uuid(struct cache *cache, const char *uuid);
|
|
|
dc8c34 |
--
|
|
|
dc8c34 |
1.8.1.4
|
|
|
dc8c34 |
|