Guest User

systray-iterator-uaf.patch

a guest
May 1st, 2026
86
0
Never
4
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. From: zackattackz
  2. Subject: [PATCH] systray: fix iterator UAF in on_change_systray
  3.  
  4. on_change_systray() iterates systray.list_icons and calls reparent_icon()
  5. for each icon not yet reparented. If the XEMBED handshake fails,
  6. reparent_icon() calls remove_icon(), which g_slist_remove()s and g_free()s
  7. the current node. The loop then advances via l = l->next on the freed node,
  8. and the next iteration dereferences l->data on garbage memory (SIGSEGV).
  9.  
  10. Trigger: any tray client that requests dock then destroys its window before
  11. the embed completes — e.g. Steam's transient 200x200 loader icon, Electron
  12. apps (Vesktop/Discord) that tear down their GdkWindow mid-embed.
  13.  
  14. Fix: capture l->next at the top of the loop body, before any call that
  15. might free the current node. remove_icon() only frees the current node, so
  16. the pre-captured next pointer stays valid.
  17.  
  18. This is the same iterator-invalidation pattern fixed in uevent_handler() by
  19. the glib2.76 patch (issue #4). That fix addressed one occurrence; this is
  20. the missed sibling in systraybar.c.
  21.  
  22. Tested with a reproducer that queues N_SYSTEM_TRAY_REQUEST_DOCK events then
  23. destroys the windows before on_change_systray can reparent them:
  24. unpatched → SIGSEGV within a few rounds; patched → all rounds survive.
  25. ---
  26. src/systray/systraybar.c | 4 ++--
  27. 1 file changed, 2 insertions(+), 2 deletions(-)
  28.  
  29. diff --git a/src/systray/systraybar.c b/src/systray/systraybar.c
  30. --- a/src/systray/systraybar.c
  31. +++ b/src/systray/systraybar.c
  32. @@ -299,8 +299,9 @@ void on_change_systray(void *obj)
  33. TrayWindow *traywin;
  34. - GSList *l;
  35. + GSList *l, *next;
  36. int i;
  37. - for (i = 1, l = systray.list_icons; l; i++, l = l->next) {
  38. + for (i = 1, l = systray.list_icons; l; i++, l = next) {
  39. + next = l->next;
  40. traywin = l->data;
  41.  
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
  • User was banned
Add Comment
Please, Sign In to add comment