Skip to content

Commit

Permalink
io-stat: xlator Segmentation fault
Browse files Browse the repository at this point in the history
The process is getting crashed during call ios_bump_stats
in cbk code path. After checked the code it seems the
process is getting crashed because the ios_stat_head list is
destroyed by the function ios_destroy_top_stats without
taking a list mutex while receive a clear profile event from
the client. If at the same time a process is trying to
access the list it can be crash.

Change-Id: I1b4d56517fa405eb84da7fffca61e15530652204
Solution: Destroy the ios_stat under the list mutex.
Fixes: gluster#3901
Signed-off-by: Mohit Agrawal <[email protected]>
  • Loading branch information
mohit84 authored and xhernandez committed Nov 14, 2022
1 parent 68856f7 commit 1ec7504
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions xlators/debug/io-stats/src/io-stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -3619,32 +3619,42 @@ ios_destroy_top_stats(struct ios_conf *conf)
list_head = &conf->list[i];
if (!list_head)
continue;
list_for_each_entry_safe(entry, tmp, &list_head->iosstats->list, list)
LOCK(&list_head->lock);
{
list = entry;
stat = list->iosstat;
ios_stat_unref(stat);
list_del(&list->list);
GF_FREE(list);
list_head->members--;
list_for_each_entry_safe(entry, tmp, &list_head->iosstats->list,
list)
{
list = entry;
stat = list->iosstat;
ios_stat_unref(stat);
list_del(&list->list);
GF_FREE(list);
list_head->members--;
}
GF_FREE(list_head->iosstats);
}
GF_FREE(list_head->iosstats);
UNLOCK(&list_head->lock);
}

for (i = 0; i < IOS_STATS_THRU_MAX; i++) {
list_head = &conf->thru_list[i];
if (!list_head)
continue;
list_for_each_entry_safe(entry, tmp, &list_head->iosstats->list, list)
LOCK(&list_head->lock);
{
list = entry;
stat = list->iosstat;
ios_stat_unref(stat);
list_del(&list->list);
GF_FREE(list);
list_head->members--;
list_for_each_entry_safe(entry, tmp, &list_head->iosstats->list,
list)
{
list = entry;
stat = list->iosstat;
ios_stat_unref(stat);
list_del(&list->list);
GF_FREE(list);
list_head->members--;
}
GF_FREE(list_head->iosstats);
}
GF_FREE(list_head->iosstats);
UNLOCK(&list_head->lock);
}

UNLOCK(&conf->lock);
Expand Down

0 comments on commit 1ec7504

Please sign in to comment.