]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: vidtv: initialize local pointers upon transfer of memory ownership
authorJeongjun Park <aha310510@gmail.com>
Fri, 5 Sep 2025 05:18:16 +0000 (14:18 +0900)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Tue, 14 Oct 2025 13:07:37 +0000 (15:07 +0200)
vidtv_channel_si_init() creates a temporary list (program, service, event)
and ownership of the memory itself is transferred to the PAT/SDT/EIT
tables through vidtv_psi_pat_program_assign(),
vidtv_psi_sdt_service_assign(), vidtv_psi_eit_event_assign().

The problem here is that the local pointer where the memory ownership
transfer was completed is not initialized to NULL. This causes the
vidtv_psi_pmt_create_sec_for_each_pat_entry() function to fail, and
in the flow that jumps to free_eit, the memory that was freed by
vidtv_psi_*_table_destroy() can be accessed again by
vidtv_psi_*_event_destroy() due to the uninitialized local pointer, so it
is freed once again.

Therefore, to prevent use-after-free and double-free vulnerability,
local pointers must be initialized to NULL when transferring memory
ownership.

Cc: <stable@vger.kernel.org>
Reported-by: syzbot+1d9c0edea5907af239e0@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=1d9c0edea5907af239e0
Fixes: 3be8037960bc ("media: vidtv: add error checks")
Signed-off-by: Jeongjun Park <aha310510@gmail.com>
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/media/test-drivers/vidtv/vidtv_channel.c

index f3023e91b3ebc8003fda4cd0049c1f0accd8727b..3541155c6fc635316a1cadbdadfaaba9fb30a058 100644 (file)
@@ -461,12 +461,15 @@ int vidtv_channel_si_init(struct vidtv_mux *m)
 
        /* assemble all programs and assign to PAT */
        vidtv_psi_pat_program_assign(m->si.pat, programs);
+       programs = NULL;
 
        /* assemble all services and assign to SDT */
        vidtv_psi_sdt_service_assign(m->si.sdt, services);
+       services = NULL;
 
        /* assemble all events and assign to EIT */
        vidtv_psi_eit_event_assign(m->si.eit, events);
+       events = NULL;
 
        m->si.pmt_secs = vidtv_psi_pmt_create_sec_for_each_pat_entry(m->si.pat,
                                                                     m->pcr_pid);