Skip to content

mempool Memory out of bounds #3941

Closed
@feizai131

Description

Description of problem:
access memory size is NPOOLS ,but pool_list->pools[i]. size is NPOOLS -1
mem_get_pool_list(void)
{
...................
. .....................
if (!pool_list) {
pool_list = MALLOC(pool_list_size);
if (!pool_list) {
return NULL;
}

    INIT_LIST_HEAD(&pool_list->thr_list);
    (void)pthread_spin_init(&pool_list->lock, PTHREAD_PROCESS_PRIVATE);
    for (i = 0; i < NPOOLS; ++i) {
        pool_list->pools[i].parent = &pools[i];
        pool_list->pools[i].hot_list = NULL;
        pool_list->pools[i].cold_list = NULL;

size
mem_pools_preinit(void)
{
unsigned int i;

INIT_LIST_HEAD(&pool_threads);
INIT_LIST_HEAD(&pool_free_threads);

for (i = 0; i < NPOOLS; ++i) {
    pools[i].power_of_two = POOL_SMALLEST + i;
}

pool_list_size = sizeof(per_thread_pool_list_t) +
                 sizeof(per_thread_pool_t) * (NPOOLS - 1);

init_done = GF_MEMPOOL_INIT_EARLY;

}

pool_list->pools[i] is NPOOLS - 1,but the for (i = 0; i < NPOOLS; ++i) is NPOOLS . Memory out of bounds
The exact command to reproduce the issue:

The full output of the command that failed:

Expected results:

Mandatory info:
- The output of the gluster volume info command:

- The output of the gluster volume status command:

- The output of the gluster volume heal command:

**- Provide logs present on following locations of client and server nodes -
/var/log/glusterfs/

**- Is there any crash ? Provide the backtrace and coredump

Additional info:

- The operating system / glusterfs version:

Note: Please hide any confidential data which you don't want to share in public like IP address, file name, hostname or any other configuration

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions