* [PATCH] media: vidtv: fix to initialize local pointers upon transfer of memory ownership
@ 2025-08-22 6:58 Jeongjun Park
2025-08-22 13:40 ` Daniel Almeida
0 siblings, 1 reply; 4+ messages in thread
From: Jeongjun Park @ 2025-08-22 6:58 UTC (permalink / raw)
To: dwlsalmeida, mchehab
Cc: linux-media, linux-kernel, syzbot+1d9c0edea5907af239e0, Jeongjun Park
vidtv_channel_si_init() transfers ownership of each object to the correct
table through functions such as vidtv_psi_*_assign().
However, since it does not set the local pointer to NULL afterwards, if it
fails for various reasons and jumps to a place such as free_*it, memory
that was freed in vidtv_psi_*_table_destroy() will be accessed and freed
again, resulting in use-after-free and double-free vuln.
Therefore, local pointers that have completed ownership transfer must be
initialized to NULL to prevent re-access to already freed memory.
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>
---
drivers/media/test-drivers/vidtv/vidtv_channel.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/media/test-drivers/vidtv/vidtv_channel.c b/drivers/media/test-drivers/vidtv/vidtv_channel.c
index f3023e91b3eb..3541155c6fc6 100644
--- a/drivers/media/test-drivers/vidtv/vidtv_channel.c
+++ b/drivers/media/test-drivers/vidtv/vidtv_channel.c
@@ -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);
--
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] media: vidtv: fix to initialize local pointers upon transfer of memory ownership
2025-08-22 6:58 [PATCH] media: vidtv: fix to initialize local pointers upon transfer of memory ownership Jeongjun Park
@ 2025-08-22 13:40 ` Daniel Almeida
2025-08-22 15:19 ` Jeongjun Park
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Almeida @ 2025-08-22 13:40 UTC (permalink / raw)
To: Jeongjun Park
Cc: mchehab, linux-media, linux-kernel, syzbot+1d9c0edea5907af239e0
Hi Jeongjun,
> On 22 Aug 2025, at 03:58, Jeongjun Park <aha310510@gmail.com> wrote:
>
> vidtv_channel_si_init() transfers ownership of each object to the correct
> table through functions such as vidtv_psi_*_assign().
>
> However, since it does not set the local pointer to NULL afterwards, if it
> fails for various reasons and jumps to a place such as free_*it, memory
> that was freed in vidtv_psi_*_table_destroy() will be accessed and freed
> again, resulting in use-after-free and double-free vuln.
I get what you’re trying to say, but what you actually wrote is hard to
parse, can you improve the wording here?
>
> Therefore, local pointers that have completed ownership transfer must be
> initialized to NULL to prevent re-access to already freed memory.
>
> 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>
> ---
> drivers/media/test-drivers/vidtv/vidtv_channel.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/media/test-drivers/vidtv/vidtv_channel.c b/drivers/media/test-drivers/vidtv/vidtv_channel.c
> index f3023e91b3eb..3541155c6fc6 100644
> --- a/drivers/media/test-drivers/vidtv/vidtv_channel.c
> +++ b/drivers/media/test-drivers/vidtv/vidtv_channel.c
> @@ -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);
> --
The patch itself is ok, thanks a lot, however:
> media: vidtv: fix to initialize local pointers upon transfer of memory ownership
Can you please use imperative voice here? i.e.:
"media: vidtv: initialize local pointers upon transfer of memory ownership”
— Daniel
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] media: vidtv: fix to initialize local pointers upon transfer of memory ownership
2025-08-22 13:40 ` Daniel Almeida
@ 2025-08-22 15:19 ` Jeongjun Park
2025-08-22 15:35 ` Daniel Almeida
0 siblings, 1 reply; 4+ messages in thread
From: Jeongjun Park @ 2025-08-22 15:19 UTC (permalink / raw)
To: Daniel Almeida
Cc: mchehab, linux-media, linux-kernel, syzbot+1d9c0edea5907af239e0
Hello Daniel,
Daniel Almeida <dwlsalmeida@gmail.com> wrote:
>
> Hi Jeongjun,
>
> > On 22 Aug 2025, at 03:58, Jeongjun Park <aha310510@gmail.com> wrote:
> >
> > vidtv_channel_si_init() transfers ownership of each object to the correct
> > table through functions such as vidtv_psi_*_assign().
> >
> > However, since it does not set the local pointer to NULL afterwards, if it
> > fails for various reasons and jumps to a place such as free_*it, memory
> > that was freed in vidtv_psi_*_table_destroy() will be accessed and freed
> > again, resulting in use-after-free and double-free vuln.
>
> I get what you’re trying to say, but what you actually wrote is hard to
> parse, can you improve the wording here?
Oops, I think I made the explanation difficult to understand and confusing.
I'll try to rewrite it so it's as easy to understand as possible.
>
> >
> > Therefore, local pointers that have completed ownership transfer must be
> > initialized to NULL to prevent re-access to already freed memory.
> >
> > 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>
> > ---
> > drivers/media/test-drivers/vidtv/vidtv_channel.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/media/test-drivers/vidtv/vidtv_channel.c b/drivers/media/test-drivers/vidtv/vidtv_channel.c
> > index f3023e91b3eb..3541155c6fc6 100644
> > --- a/drivers/media/test-drivers/vidtv/vidtv_channel.c
> > +++ b/drivers/media/test-drivers/vidtv/vidtv_channel.c
> > @@ -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);
> > --
>
> The patch itself is ok, thanks a lot, however:
>
> > media: vidtv: fix to initialize local pointers upon transfer of memory ownership
>
> Can you please use imperative voice here? i.e.:
>
> "media: vidtv: initialize local pointers upon transfer of memory ownership”
If I do that, the patch subject will change. Should I just change the
subject and send it to you, or should I also send it with the v2 tag
included?
>
> — Daniel
Regards,
Jeongjun Park
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] media: vidtv: fix to initialize local pointers upon transfer of memory ownership
2025-08-22 15:19 ` Jeongjun Park
@ 2025-08-22 15:35 ` Daniel Almeida
0 siblings, 0 replies; 4+ messages in thread
From: Daniel Almeida @ 2025-08-22 15:35 UTC (permalink / raw)
To: Jeongjun Park
Cc: mchehab, linux-media, linux-kernel, syzbot+1d9c0edea5907af239e0
[…]
>>> --
>>
>> The patch itself is ok, thanks a lot, however:
>>
>>> media: vidtv: fix to initialize local pointers upon transfer of memory ownership
>>
>> Can you please use imperative voice here? i.e.:
>>
>> "media: vidtv: initialize local pointers upon transfer of memory ownership”
>
> If I do that, the patch subject will change. Should I just change the
> subject and send it to you, or should I also send it with the v2 tag
> included?
Just change the subject and send it to the list with the v2 tag.
Also, I just realize that you should rewrite this further: “Set local
pointers to NULL upon transfer of memory ownership” or something around
these lines.
— Daniel
>
>>
>> — Daniel
>
> Regards,
> Jeongjun Park
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-08-22 15:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-22 6:58 [PATCH] media: vidtv: fix to initialize local pointers upon transfer of memory ownership Jeongjun Park
2025-08-22 13:40 ` Daniel Almeida
2025-08-22 15:19 ` Jeongjun Park
2025-08-22 15:35 ` Daniel Almeida
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®