From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 808AD234984; Mon, 18 Aug 2025 14:07:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755526038; cv=none; b=bdMpnrP85c78OLTFMtXWSWbvyHd5LyfMQgxMdij2Sf+Co+KAD/9TOwtCnIgA3w5M3toQXZxqFsz20PdOhhSJRYg6wMjil6180MhloNnLmPTzMcCZbRDd6HzWGn23966K1Jt3SIrTd/PkUb+DaRmcVK9CGErHleB68yzcJUDdnRI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755526038; c=relaxed/simple; bh=C76PeATUBMEAnu/b9miGHNvLkm7bdENGZ7dGRN/sxBw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dy/ws0INW1LJvPqHdehONuH9hQNpbA0W5mQ07b4CkRXLFQMtYONFKp2PHngUt9Sva8SxTVVBs8wVyxCttzBLBpe4ik9Q4ABMmoJcTvC7jbGfVbq4+HVJBx5mWUyf5bHhiKc99j/Yru7Rh+a0RsezM4uxJNDnv2ffJGk/q/ZsRWs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=cHxHCFpK; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="cHxHCFpK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EFD66C4CEEB; Mon, 18 Aug 2025 14:07:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1755526038; bh=C76PeATUBMEAnu/b9miGHNvLkm7bdENGZ7dGRN/sxBw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cHxHCFpK+quyzNgNUiqm07wQ4y658m4FMCsl+S2otEOLWizETIdF1uhcvoOaqN+xO Ljwvh4+hK7KQD8ChlKJhQwqlYB8Qjqgw2q2WEnjAHlShihi4Uj5kJvPOrofU7iTt5C oOEJ62RJnvigrBsrK6/BJUC5fZpOE+9fiZPDEQ/E= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Alex Guo , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 6.16 413/570] media: dvb-frontends: w7090p: fix null-ptr-deref in w7090p_tuner_write_serpar and w7090p_tuner_read_serpar Date: Mon, 18 Aug 2025 14:46:40 +0200 Message-ID: <20250818124521.755800897@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250818124505.781598737@linuxfoundation.org> References: <20250818124505.781598737@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alex Guo [ Upstream commit ed0234c8458b3149f15e496b48a1c9874dd24a1b ] In w7090p_tuner_write_serpar, 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 commit: commit 0ed554fd769a ("media: dvb-usb: az6027: fix null-ptr-deref in az6027_i2c_xfer()") Signed-off-by: Alex Guo Link: https://lore.kernel.org/r/20250616013353.738790-1-alexguo1023@gmail.com Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/dvb-frontends/dib7000p.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/media/dvb-frontends/dib7000p.c b/drivers/media/dvb-frontends/dib7000p.c index 360a2d7dd3ed..7d3a994b7cc4 100644 --- a/drivers/media/dvb-frontends/dib7000p.c +++ b/drivers/media/dvb-frontends/dib7000p.c @@ -2193,6 +2193,8 @@ static int w7090p_tuner_write_serpar(struct i2c_adapter *i2c_adap, struct i2c_ms struct dib7000p_state *state = i2c_get_adapdata(i2c_adap); u8 n_overflow = 1; u16 i = 1000; + if (msg[0].len < 3) + return -EOPNOTSUPP; u16 serpar_num = msg[0].buf[0]; while (n_overflow == 1 && i) { @@ -2212,6 +2214,8 @@ static int w7090p_tuner_read_serpar(struct i2c_adapter *i2c_adap, struct i2c_msg struct dib7000p_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 -EOPNOTSUPP; u16 serpar_num = msg[0].buf[0]; u16 read_word; -- 2.39.5