🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.debian.bugs.dist
Article #6534

Bug#1155636: tint2: segfault in on_change_systray (use-after-free when reparent_icon removes an icon)

#6534
From: HackThePlanet
Date: Sat, 28 Nov 2026 09:10
101 lines
5285 bytes
This is a multi-part MIME message sent by reportbug.


--===============4643894102895627148==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Package: tint2
Version: 17.0.1-1.3
Severity: important
Tags: patch upstream

Dear Maintainer,

tint2 crashes with SIGSEGV shortly after login (or whenever a tray application
registers an icon and removes it again right away, e.g. update notifiers,
nm-applet, nextcloud). Reproduced on Ubuntu 26.04 with 17.0.1-1.2build1; the
code in 17.0.1-1.3 is identical.

Backtrace (from core dump):
  #0 on_change_systray ()
  #1 resize_systray ()
  #2 relayout_fixed ()
  #3 relayout_fixed ()
  #4 render_panel ()
  #5 handle_panel_refresh ()
  #6 run_tint2_event_loop ()

Log before the crash (typical):
  tint2: Couldn't get geometry of window!
  systray 897: cannot embed icon for window ... parent ... pid ...
  tint2: remove_icon: ...

Cause: in on_change_systray() (src/systray/systraybar.c) the loop

  for (i = 1, l = systray.list_icons; l; i++, l = l->next)

calls reparent_icon(traywin). If embedding fails, reparent_icon() calls
remove_icon(), which does g_slist_remove() and g_free() on the current list
node/traywin. The loop then reads l->next from freed memory.

The attached patch saves the next pointer before the loop body and skips an
icon when XGetGeometry() fails (previously the code continued with
uninitialised width/height/xpos/ypos). With the patch built into
17.0.1-1.3+local1 the crash no longer occurs on the affected machine
(several icons are removed during login, see log above, without a crash).

This is also related to the glib 2.76 crash handled by glib2.76.patch, but is
a different location.

Patch: debian/patches/systray-uaf.patch (attached).


-- System Information:
Debian Release: forky/sid
  APT prefers resolute-updates
  APT policy: (500, 'resolute-updates'), (500, 'resolute-security'), (500, 'resolute'), (100, 'resolute-backports')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 7.0.0-44-generic (SMP w/4 CPU threads; PREEMPT)
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8), LANGUAGE=de_DE:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

--===============4643894102895627148==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="systray-uaf-debian.patch"

Description: Fix use-after-free in on_change_systray when reparent_icon removes the icon
--- tint2-17.0.1.orig/src/systray/systraybar.c
+++ tint2-17.0.1/src/systray/systraybar.c
@@ -292,9 +292,11 @@
     }
 
     TrayWindow *traywin;
-    GSList *l;
+    GSList *l, *next;
     int i;
-    for (i = 1, l = systray.list_icons; l; i++, l = l->next) {
+    for (i = 1, l = systray.list_icons; l; i++, l = next) {
+        // reparent_icon() may call remove_icon(), which frees the list node and traywin
+        next = l->next;
         traywin = (TrayWindow *)l->data;
 
         traywin->y = posy;
@@ -334,6 +336,7 @@
         Window root;
         if (!XGetGeometry(server.display, traywin->parent, &root, &xpos, &ypos, &width, &height, &border_width, &depth)) {
             fprintf(stderr, RED "tint2: Couldn't get geometry of window!" RESET "\n");
+            continue;
         }
         if (width != traywin->width || height != traywin->height || xpos != traywin->x || ypos != traywin->y) {
             if (systray_profile)

--===============4643894102895627148==--
Technical Details
Message-ID: <O4mBs-eE4q-17@gated-at.bofh.it>
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!news.tcpreset.net!newsfeed.bofh.team!news.samoylyk.net!gothmog.csi.it!bofh.it!news.nic.it!robomod

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lon.pugleaf.net!news.tcpreset.net!newsfeed.bofh.team!news.samoylyk.net!gothmog.csi.it!bofh.it!news.nic.it!robomod
From: HackThePlanet <raimund.koenig@gmail.com>
Newsgroups: linux.debian.bugs.dist
Subject: Bug#1155636: tint2: segfault in on_change_systray (use-after-free when reparent_icon removes an icon)
Date: Sat, 28 Nov 2026 10:10:02 +0100
Message-ID: <O4mBs-eE4q-17@gated-at.bofh.it>
X-Original-To: Debian Bug Tracking System <submit@bugs.debian.org>
X-Mailbox-Line: From debian-bugs-dist-request@lists.debian.org  Sat Nov 28 09:09:09 2026
Old-Return-Path: <debbugs@buxtehude.debian.org>
X-Spam-Flag: NO
X-Spam-Score: 1.401
Reply-To: HackThePlanet <raimund.koenig@gmail.com>, 1155636@bugs.debian.org
Resent-To: debian-bugs-dist@lists.debian.org
Resent-Cc: sre@debian.org
X-Debian-Pr-Message: report 1155636
X-Debian-Pr-Package: tint2
X-Debian-Pr-Keywords: patch upstream
X-Debian-Pr-Source: tint2
Content-Type: multipart/mixed; boundary="===============4643894102895627148=="
MIME-Version: 1.0
X-Mailer: reportbug 13.2.0+ubuntu1
X-Debian-Message: from BTS
X-Mailing-List: <debian-bugs-dist@lists.debian.org> archive/latest/2005567
List-ID: <debian-bugs-dist.lists.debian.org>
List-URL: <https://lists.debian.org/debian-bugs-dist/>
Approved: robomod@news.nic.it
Lines: 101
Organization: linux.* mail to news gateway
Sender: robomod@news.nic.it
X-Original-Date: Sat, 28 Nov 2026 10:07:21 +0100
X-Original-Message-ID: <179585684147.9604.6232738959270437044.reportbug@rebellsub.fritz.box>