Open Source Telephony
 help / color / mirror / Atom feed
* [PATCH] sim: fix use-after-free in open_channel_cb watcher loop
@ 2026-05-07 23:02 Marius Gripsgard
  2026-05-18 22:19 ` Andres Salomon
  2026-11-30 16:48 ` Herman van Hazendonk
  0 siblings, 2 replies; 3+ messages in thread
From: Marius Gripsgard @ 2026-05-07 23:02 UTC (permalink / raw)
  To: ofono; +Cc: Marius Gripsgard

The notify callback (get_session_cb -> sim_fs_end_current) calls
__ofono_sim_remove_session_watch, which removes and frees the current
GSList node from session->watches->items. iter = g_slist_next(iter)
then reads ->next from the freed node, on newer glibc the freed memory
holds a random tcache key rather than accessible heap data, turning the
next iter->data dereference into a SIGSEGV.

Advance iter before calling notify so the next-pointer is captured
before the current node can be freed.
---
 src/sim.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/sim.c b/src/sim.c
index dedb7d8d..6a733169 100644
--- a/src/sim.c
+++ b/src/sim.c
@@ -3659,9 +3659,9 @@ end:
 		struct ofono_watchlist_item *item = iter->data;
 		ofono_sim_session_event_cb_t notify = item->notify;
 
-		notify(active, session->session_id, item->notify_data);
-
 		iter = g_slist_next(iter);
+
+		notify(active, session->session_id, item->notify_data);
 	}
 }
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-30 16:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-07 23:02 [PATCH] sim: fix use-after-free in open_channel_cb watcher loop Marius Gripsgard
2026-05-18 22:19 ` Andres Salomon
2026-11-30 16:48 ` Herman van Hazendonk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox