Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix use-after-free in the lua object management #85

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kuruczgy
Copy link

Original PR: #77

Wlroots does not call wl_list_remove(&destroy.listener_list) after the destroy signal fires. It is the responsibility of the subscriber to handle their own wl_listener being left with an invalid link.

This was an issue because it might happen that the kiwmi_object is not destroyed immediately, but only later by a lua gc handler that finally decrements the refcount to zero. We have to ensure that kiwmi_object_destroy can succeed.

Here we first use wl_list_remove to unsubscribe from the signal, and then wl_list_init to leave the link in a valid state for kiwmi_object_destroy.

Wlroots does not call `wl_list_remove(&destroy.listener_list)` after the
destroy signal fires. It is the responsibility of the subscriber to
handle their own wl_listener being left with an invalid link.

This was an issue because it might happen that the kiwmi_object is not
destroyed immediately, but only later by a lua gc handler that finally
decrements the refcount to zero. We have to ensure that
`kiwmi_object_destroy` can succeed.

Here we first use `wl_list_remove` to unsubscribe from the signal, and
then `wl_list_init` to leave the link in a valid state for
`kiwmi_object_destroy`.
@kuruczgy
Copy link
Author

@buffet rebased my original PR that was closed due to the history rewriting.

If you ever want to pick up working on the project in the future (no pressure or anything), let me know, and I can create updated versions of my other closed PRs as well :)

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.

1 participant