mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-07-08 18:13:59 +02:00
media: vidtv: fix NULL pointer dereference in vidtv_mux_push_si
commit7d8bf3d8f9upstream. syzbot reported a general protection fault in vidtv_psi_ts_psi_write_into [1]. vidtv_mux_get_pid_ctx() can return NULL, but vidtv_mux_push_si() does not check for this before dereferencing the returned pointer to access the continuity counter. This leads to a general protection fault when accessing a near-NULL address. The root cause is that vidtv_mux_pid_ctx_init() does not check the return value of vidtv_mux_create_pid_ctx_once() for PMT section PIDs. If the allocation fails, the PID context is never created, but init returns success. The subsequent vidtv_mux_push_si() call then gets NULL from vidtv_mux_get_pid_ctx() and crashes. Fix both the root cause (add error check in vidtv_mux_pid_ctx_init for PMT PIDs) and add defensive NULL checks in vidtv_mux_push_si for all vidtv_mux_get_pid_ctx() calls. [1] Oops: general protection fault, probably for non-canonical address 0xdffffc0000000000: 0000 [#1] SMP KASAN PTI KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] Workqueue: events vidtv_mux_tick RIP: 0010:vidtv_psi_ts_psi_write_into+0x54a/0xbc0 drivers/media/test-drivers/vidtv/vidtv_psi.c:197 Call Trace: <TASK> vidtv_psi_table_header_write_into drivers/media/test-drivers/vidtv/vidtv_psi.c:799 [inline] vidtv_psi_pmt_write_into+0x3b2/0xa70 drivers/media/test-drivers/vidtv/vidtv_psi.c:1231 vidtv_mux_push_si+0x932/0xe80 drivers/media/test-drivers/vidtv/vidtv_mux.c:196 vidtv_mux_tick+0xe9b/0x1480 drivers/media/test-drivers/vidtv/vidtv_mux.c:408 Fixes:f90cf6079b("media: vidtv: add a bridge driver") Cc: stable@vger.kernel.org Reported-by: syzbot+814c351d094f4f1a1b86@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=814c351d094f4f1a1b86 Signed-off-by: Ruslan Valiyev <linuxoid@gmail.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
43a6281790
commit
455bc12e7b
@@ -101,7 +101,8 @@ static int vidtv_mux_pid_ctx_init(struct vidtv_mux *m)
|
||||
/* add a ctx for all PMT sections */
|
||||
while (p) {
|
||||
pid = vidtv_psi_get_pat_program_pid(p);
|
||||
vidtv_mux_create_pid_ctx_once(m, pid);
|
||||
if (!vidtv_mux_create_pid_ctx_once(m, pid))
|
||||
goto free;
|
||||
p = p->next;
|
||||
}
|
||||
|
||||
@@ -170,6 +171,9 @@ static u32 vidtv_mux_push_si(struct vidtv_mux *m)
|
||||
nit_ctx = vidtv_mux_get_pid_ctx(m, VIDTV_NIT_PID);
|
||||
eit_ctx = vidtv_mux_get_pid_ctx(m, VIDTV_EIT_PID);
|
||||
|
||||
if (!pat_ctx || !sdt_ctx || !nit_ctx || !eit_ctx)
|
||||
return 0;
|
||||
|
||||
pat_args.offset = m->mux_buf_offset;
|
||||
pat_args.continuity_counter = &pat_ctx->cc;
|
||||
|
||||
@@ -186,6 +190,8 @@ static u32 vidtv_mux_push_si(struct vidtv_mux *m)
|
||||
}
|
||||
|
||||
pmt_ctx = vidtv_mux_get_pid_ctx(m, pmt_pid);
|
||||
if (!pmt_ctx)
|
||||
continue;
|
||||
|
||||
pmt_args.offset = m->mux_buf_offset;
|
||||
pmt_args.pmt = m->si.pmt_secs[i];
|
||||
|
||||
Reference in New Issue
Block a user