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
smpl-os: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
smpl-os:fix/rename-use-after-free

Conversation

@KonTy
Copy link
Contributor

@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. The
nemo_file_clear_info() call immediately after then dereferences the
freed pointer, causing a SIGSEGV.

Fix: take a temporary ref before the if-block so the object stays alive
through both nemo_directory_remove_file() and nemo_file_clear_info(),
and release it only after both calls complete.

Closes linuxmint#3712
@KonTy KonTy force-pushed the fix/rename-use-after-free branch from c3f954f to 7288e9a Compare March 25, 2026 05:53
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

2 participants