Skip to content

Potential stale memory access in VFS #9575

@pkarashchenko

Description

@pkarashchenko

I've noticed that fs_getfilep() returns the pointer from list->fl_files. The returned pointer is used further and passed to other APIs. The list->fl_files access is protected by list->fl_lock, but after fs_getfilep() returns the list->fl_lock is released. On the other hand the files_extend() contains tmp = kmm_realloc(list->fl_files, sizeof(FAR struct file *) * row); call that potentially can move all the list entries to a new memory location. So it one thread is interrupted after fs_getfilep() returns and another thread leads to files_extend() call the first thread will potentially access already freed memory (maybe even allocated and used by another user), so potentially can cause memory corruption.

Metadata

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