Skip to content

libnemo-private: fix use-after-free crash in nemo_file_mark_gone#3724

Open
KonTy wants to merge 1 commit intolinuxmint:masterfrom
KonTy:fix/rename-use-after-free
Open

libnemo-private: fix use-after-free crash in nemo_file_mark_gone#3724
KonTy wants to merge 1 commit intolinuxmint:masterfrom
KonTy:fix/rename-use-after-free

Conversation

@KonTy
Copy link

@KonTy KonTy commented Mar 6, 2026

Fixes #3712.

nemo_directory_remove_file() calls nemo_file_unref() when the directory is monitoring its file list. If the caller holds no extra ref on the file, this can drop the refcount to zero and free the NemoFile object. The nemo_file_clear_info() call immediately after then dereferences the freed pointer, causing a SIGSEGV.

This crash surfaces during file rename: rename_get_info_callback finds an existing file with the same new name and passes it to nemo_file_mark_gone() without holding an extra ref.

The fix is to take a temporary ref around the nemo_directory_remove_file() call so the object stays alive until nemo_file_clear_info() returns.

nemo_directory_remove_file() calls nemo_file_unref() when the directory
is monitoring its file list. If the caller holds no extra ref, this can
drop the refcount to zero and free the NemoFile object in place. The
subsequent nemo_file_clear_info() call then dereferences the freed
pointer, causing a SIGSEGV.

Reproduced during file rename: rename_get_info_callback finds an
existing_file with the same new name and calls nemo_file_mark_gone on
it with no extra ref held, triggering the crash.

Fix by holding a temporary ref around nemo_directory_remove_file so the
object remains valid until nemo_file_clear_info returns.

Fixes linuxmint#3712
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Seg fault on file rename

1 participant