* [PATCH] media: dvb-frontends: tda665x: fix stack overflow in get_status()
@ 2026-10-29 7:25 Guo Zihao
0 siblings, 0 replies; only message in thread
From: Guo Zihao @ 2026-10-29 7:25 UTC (permalink / raw)
To: Mauro Carvalho Chehab; +Cc: Manu Abraham, linux-media, linux-kernel, stable
tda665x_get_status() declares a single-byte stack variable and passes
its address to tda665x_read():
u8 result = 0;
err = tda665x_read(state, &result);
tda665x_read() builds an i2c_msg with .len = 2 and .buf = &result, so
the I2C transfer writes two bytes into a one-byte buffer: the second
byte, controlled by the tuner's response, lands on whatever follows
result on the kernel stack. The get_status callback runs on every
FE_READ_STATUS ioctl, which frontends typically poll in a tight loop.
Verified with a userspace copy of the two functions under
AddressSanitizer: the 2-byte write into the 1-byte buffer reports
"stack-buffer-overflow WRITE of size 2".
Make the buffer two bytes wide and test the lock bit on the first
byte, matching the register layout of the driver. The buffer is
zero-initialized so the unused second byte stays well defined.
Fixes: 3e978a828408 ("V4L/DVB (13797): [Mantis/Hopper/TDA665x] Large overhaul,")
Cc: stable@vger.kernel.org
Signed-off-by: Guo Zihao <guozh23@xiaopeng.com>
---
drivers/media/dvb-frontends/tda665x.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/media/dvb-frontends/tda665x.c b/drivers/media/dvb-frontends/tda665x.c
index b2201ec14..7b876c16a 100644
--- a/drivers/media/dvb-frontends/tda665x.c
+++ b/drivers/media/dvb-frontends/tda665x.c
@@ -66,16 +66,16 @@ static int tda665x_get_frequency(struct dvb_frontend *fe, u32 *frequency)
static int tda665x_get_status(struct dvb_frontend *fe, u32 *status)
{
struct tda665x_state *state = fe->tuner_priv;
- u8 result = 0;
+ u8 result[2] = { 0 };
int err = 0;
*status = 0;
- err = tda665x_read(state, &result);
+ err = tda665x_read(state, result);
if (err < 0)
goto exit;
- if ((result >> 6) & 0x01) {
+ if ((result[0] >> 6) & 0x01) {
printk(KERN_DEBUG "%s: Tuner Phase Locked\n", __func__);
*status = 1;
}
--
2.50.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-29 7:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-29 7:25 [PATCH] media: dvb-frontends: tda665x: fix stack overflow in get_status() Guo Zihao
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®