From: Alex Guo <alexguo1023@gmail.com>
To: mchehab@kernel.org
Cc: alexguo1023@gmail.com, jpoimboe@kernel.org, algonell@gmail.com,
mingo@kernel.org, linux-media@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] media: dvb-frontends: w8096p: fix null-ptr-deref
Date: Sun, 15 Jun 2025 21:59:40 -0400 [thread overview]
Message-ID: <20250616015940.779326-1-alexguo1023@gmail.com> (raw)
msg is controlled by user. If accessing msg.buf without sanity
check, null pointer deref would happen. We add check on
msg.len to prevent crash.
Similar commit: commit 0ed554fd769a ("media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer()")
Signed-off-by: Alex Guo <alexguo1023@gmail.com>
---
drivers/media/dvb-frontends/dib8000.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/drivers/media/dvb-frontends/dib8000.c b/drivers/media/dvb-frontends/dib8000.c
index d90f1b0b2051..26988d2aa065 100644
--- a/drivers/media/dvb-frontends/dib8000.c
+++ b/drivers/media/dvb-frontends/dib8000.c
@@ -1677,6 +1677,8 @@ static int dib8096p_tuner_write_serpar(struct i2c_adapter *i2c_adap,
struct dib8000_state *state = i2c_get_adapdata(i2c_adap);
u8 n_overflow = 1;
u16 i = 1000;
+ if (msg[0].len < 3)
+ return -EINVAL;
u16 serpar_num = msg[0].buf[0];
while (n_overflow == 1 && i) {
@@ -1697,6 +1699,8 @@ static int dib8096p_tuner_read_serpar(struct i2c_adapter *i2c_adap,
struct dib8000_state *state = i2c_get_adapdata(i2c_adap);
u8 n_overflow = 1, n_empty = 1;
u16 i = 1000;
+ if (msg[0].len < 1 || msg[1].len < 2)
+ return -EINVAL;
u16 serpar_num = msg[0].buf[0];
u16 read_word;
@@ -1740,7 +1744,8 @@ static int dib8096p_rw_on_apb(struct i2c_adapter *i2c_adap,
{
struct dib8000_state *state = i2c_get_adapdata(i2c_adap);
u16 word;
-
+ if (msg[0].len < 3 || msg[1].len < 2)
+ return -EINVAL;
if (num == 1) { /* write */
dib8000_write_word(state, apb_address,
((msg[0].buf[1] << 8) | (msg[0].buf[2])));
@@ -1758,7 +1763,8 @@ static int dib8096p_tuner_xfer(struct i2c_adapter *i2c_adap,
struct dib8000_state *state = i2c_get_adapdata(i2c_adap);
u16 apb_address = 0, word;
int i = 0;
-
+ if (msg[0].len < 1)
+ return -EINVAL;
switch (msg[0].buf[0]) {
case 0x12:
apb_address = 1920;
@@ -1848,11 +1854,15 @@ static int dib8096p_tuner_xfer(struct i2c_adapter *i2c_adap,
/* get sad sel request */
i = ((dib8000_read_word(state, 921) >> 12)&0x3);
word = dib8000_read_word(state, 924+i);
+ if (msg[1].len < 2)
+ return -EINVAL;
msg[1].buf[0] = (word >> 8) & 0xff;
msg[1].buf[1] = (word) & 0xff;
return num;
case 0x1f:
if (num == 1) { /* write */
+ if (msg[0].len < 3)
+ return -EINVAL;
word = (u16) ((msg[0].buf[1] << 8) |
msg[0].buf[2]);
/* in the VGAMODE Sel are located on bit 0/1 */
--
2.34.1
reply other threads:[~2025-06-16 1:59 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250616015940.779326-1-alexguo1023@gmail.com \
--to=alexguo1023@gmail.com \
--cc=algonell@gmail.com \
--cc=jpoimboe@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=mingo@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®