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 #77

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

Conversation

kuruczgy
Copy link

@kuruczgy kuruczgy commented Apr 1, 2023

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`.
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