Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: dvb-frontends: dib7090p: fix null-ptr-deref in dib7090p_rw_on_apb()

In dib7090p_rw_on_apb, msg is controlled by user. When msg[0].buf is null and
msg[0].len is zero, former checks on msg[0].buf would be passed. If accessing
msg[0].buf[2] without sanity check, null pointer deref would happen. We add
check on msg[0].len to prevent crash. Similar issue occurs when access
msg[1].buf[0] and msg[1].buf[1].

Similar commit: commit 0ed554fd769a ("media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer()")

Signed-off-by: Alex Guo <alexguo1023@gmail.com>
Link: https://lore.kernel.org/r/20250616013231.730221-1-alexguo1023@gmail.com
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

authored by

Alex Guo and committed by
Mauro Carvalho Chehab
ce5cac69 ed0234c8

+4
+4
drivers/media/dvb-frontends/dib7000p.c
··· 2260 2260 u16 word; 2261 2261 2262 2262 if (num == 1) { /* write */ 2263 + if (msg[0].len < 3) 2264 + return -EOPNOTSUPP; 2263 2265 dib7000p_write_word(state, apb_address, ((msg[0].buf[1] << 8) | (msg[0].buf[2]))); 2264 2266 } else { 2267 + if (msg[1].len < 2) 2268 + return -EOPNOTSUPP; 2265 2269 word = dib7000p_read_word(state, apb_address); 2266 2270 msg[1].buf[0] = (word >> 8) & 0xff; 2267 2271 msg[1].buf[1] = (word) & 0xff;