Open Source Telephony
 help / color / mirror / Atom feed
* [PATCH] voicecall: Fix use after free
@ 2024-05-28 22:06 Denis Kenzior
  2024-05-30 14:40 ` patchwork-bot+ofono
  0 siblings, 1 reply; 2+ messages in thread
From: Denis Kenzior @ 2024-05-28 22:06 UTC (permalink / raw)
  To: ofono; +Cc: Denis Kenzior

On shutdown, if the sim atom is removed before the voicecall atom, the
sim context is removed automatically.  However, voicecall atom does set
sim_context to NULL in that case, resulting in the following valgrind
report:

==251105== Invalid read of size 8
==251105==    at 0x59B4F3: sim_fs_file_watch_remove (src/simfs.c:243)
==251105==    by 0x560E2A: ofono_sim_remove_file_watch (src/sim.c:2621)
==251105==    by 0x5412E3: unwatch_sim_ecc_numbers (src/voicecall.c:2820)
==251105==    by 0x53B8C8: voicecall_unregister (src/voicecall.c:2849)
==251105==    by 0x52B16B: __ofono_atom_unregister (src/modem.c:336)
==251105==    by 0x52E6E4: flush_atoms (src/modem.c:492)
==251105==    by 0x52C1BE: modem_change_state (src/modem.c:586)
==251105==    by 0x52E155: set_powered (src/modem.c:974)
==251105==    by 0x52E307: __ofono_modem_shutdown (src/modem.c:2279)
==251105==    by 0x5296B6: signal_handler (src/main.c:85)
==251105==    by 0x48FF198: ??? (in /usr/lib/libglib-2.0.so.0.8000.0)
==251105==    by 0x495E3BE: ??? (in /usr/lib/libglib-2.0.so.0.8000.0)
==251105==  Address 0x5baa6f8 is 8 bytes inside a block of size 16 free'd
==251105==    at 0x48458CF: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==251105==    by 0x59B2A1: sim_fs_context_free (src/simfs.c:213)
==251105==    by 0x59B133: sim_fs_free (src/simfs.c:123)
==251105==    by 0x5620EF: sim_remove (src/sim.c:3239)
==251105==    by 0x52E701: flush_atoms (src/modem.c:495)
==251105==    by 0x52C1BE: modem_change_state (src/modem.c:586)
==251105==    by 0x52E155: set_powered (src/modem.c:974)
==251105==    by 0x52E307: __ofono_modem_shutdown (src/modem.c:2279)
==251105==    by 0x5296B6: signal_handler (src/main.c:85)
==251105==    by 0x48FF198: ??? (in /usr/lib/libglib-2.0.so.0.8000.0)
==251105==    by 0x495E3BE: ??? (in /usr/lib/libglib-2.0.so.0.8000.0)
==251105==    by 0x48FFDC6: g_main_loop_run (in /usr/lib/libglib-2.0.so.0.8000.0)
---
 src/voicecall.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/voicecall.c b/src/voicecall.c
index d9f3dd82f0e6..398a576a3cc2 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -2966,6 +2966,7 @@ static void sim_watch(struct ofono_atom *atom,
 
 	if (cond == OFONO_ATOM_WATCH_CONDITION_UNREGISTERED) {
 		voicecall_close_settings(vc);
+		vc->sim_context = NULL;
 		vc->sim_state_watch = 0;
 		vc->sim = NULL;
 		return;
-- 
2.45.0


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

* Re: [PATCH] voicecall: Fix use after free
  2024-05-28 22:06 [PATCH] voicecall: Fix use after free Denis Kenzior
@ 2024-05-30 14:40 ` patchwork-bot+ofono
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+ofono @ 2024-05-30 14:40 UTC (permalink / raw)
  To: Denis Kenzior; +Cc: ofono

Hello:

This patch was applied to ofono.git (master)
by Denis Kenzior <denkenz@gmail.com>:

On Tue, 28 May 2024 17:06:29 -0500 you wrote:
> On shutdown, if the sim atom is removed before the voicecall atom, the
> sim context is removed automatically.  However, voicecall atom does set
> sim_context to NULL in that case, resulting in the following valgrind
> report:
> 
> ==251105== Invalid read of size 8
> ==251105==    at 0x59B4F3: sim_fs_file_watch_remove (src/simfs.c:243)
> ==251105==    by 0x560E2A: ofono_sim_remove_file_watch (src/sim.c:2621)
> ==251105==    by 0x5412E3: unwatch_sim_ecc_numbers (src/voicecall.c:2820)
> ==251105==    by 0x53B8C8: voicecall_unregister (src/voicecall.c:2849)
> ==251105==    by 0x52B16B: __ofono_atom_unregister (src/modem.c:336)
> ==251105==    by 0x52E6E4: flush_atoms (src/modem.c:492)
> ==251105==    by 0x52C1BE: modem_change_state (src/modem.c:586)
> ==251105==    by 0x52E155: set_powered (src/modem.c:974)
> ==251105==    by 0x52E307: __ofono_modem_shutdown (src/modem.c:2279)
> ==251105==    by 0x5296B6: signal_handler (src/main.c:85)
> ==251105==    by 0x48FF198: ??? (in /usr/lib/libglib-2.0.so.0.8000.0)
> ==251105==    by 0x495E3BE: ??? (in /usr/lib/libglib-2.0.so.0.8000.0)
> ==251105==  Address 0x5baa6f8 is 8 bytes inside a block of size 16 free'd
> ==251105==    at 0x48458CF: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==251105==    by 0x59B2A1: sim_fs_context_free (src/simfs.c:213)
> ==251105==    by 0x59B133: sim_fs_free (src/simfs.c:123)
> ==251105==    by 0x5620EF: sim_remove (src/sim.c:3239)
> ==251105==    by 0x52E701: flush_atoms (src/modem.c:495)
> ==251105==    by 0x52C1BE: modem_change_state (src/modem.c:586)
> ==251105==    by 0x52E155: set_powered (src/modem.c:974)
> ==251105==    by 0x52E307: __ofono_modem_shutdown (src/modem.c:2279)
> ==251105==    by 0x5296B6: signal_handler (src/main.c:85)
> ==251105==    by 0x48FF198: ??? (in /usr/lib/libglib-2.0.so.0.8000.0)
> ==251105==    by 0x495E3BE: ??? (in /usr/lib/libglib-2.0.so.0.8000.0)
> ==251105==    by 0x48FFDC6: g_main_loop_run (in /usr/lib/libglib-2.0.so.0.8000.0)
> 
> [...]

Here is the summary with links:
  - voicecall: Fix use after free
    https://git.kernel.org/pub/scm/network/ofono/ofono.git/?id=da1e4440a17b

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2024-05-30 14:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-28 22:06 [PATCH] voicecall: Fix use after free Denis Kenzior
2024-05-30 14:40 ` patchwork-bot+ofono

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