Skip to content

Commit

Permalink
MDEV-22903 heap-use-after-free while accessing fts cache deleted doc ids
Browse files Browse the repository at this point in the history
Problem:
=======
  fts_cache_append_deleted_doc_ids() holds the deleted_lock and tries to
access size of deleted_doc_ids. In the meantime, fts_cache_clear()
clears the sync_heap before clearing deleted_doc_ids. It leads to
invalid access of deleted_doc_ids.

Fix:
===
fts_cache_clear() should free the sync_heap after clearing
deleted_doc_ids.
  • Loading branch information
Thirunarayanan committed Jul 23, 2020
1 parent 52ccedd commit adeb736
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions storage/innobase/fts/fts0fts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1127,14 +1127,14 @@ fts_cache_clear(
index_cache->doc_stats = NULL;
}

mem_heap_free(static_cast<mem_heap_t*>(cache->sync_heap->arg));
cache->sync_heap->arg = NULL;

cache->total_size = 0;

mutex_enter((ib_mutex_t*) &cache->deleted_lock);
cache->deleted_doc_ids = NULL;
mutex_exit((ib_mutex_t*) &cache->deleted_lock);

mem_heap_free(static_cast<mem_heap_t*>(cache->sync_heap->arg));
cache->sync_heap->arg = NULL;
}

/*********************************************************************//**
Expand Down
6 changes: 3 additions & 3 deletions storage/xtradb/fts/fts0fts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1127,14 +1127,14 @@ fts_cache_clear(
index_cache->doc_stats = NULL;
}

mem_heap_free(static_cast<mem_heap_t*>(cache->sync_heap->arg));
cache->sync_heap->arg = NULL;

cache->total_size = 0;

mutex_enter((ib_mutex_t*) &cache->deleted_lock);
cache->deleted_doc_ids = NULL;
mutex_exit((ib_mutex_t*) &cache->deleted_lock);

mem_heap_free(static_cast<mem_heap_t*>(cache->sync_heap->arg));
cache->sync_heap->arg = NULL;
}

/*********************************************************************//**
Expand Down

0 comments on commit adeb736

Please sign in to comment.