public inbox for linux-input@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Input: penmount: bound packet buffer indices in IRQ path
@ 2026-03-23 12:17 Pengpeng Hou
  2026-03-23 13:32 ` Andy Shevchenko
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Pengpeng Hou @ 2026-03-23 12:17 UTC (permalink / raw)
  To: dmitry.torokhov
  Cc: andriy.shevchenko, kees, linux-input, linux-kernel, pengpeng

The IRQ handler stores each incoming byte into pm->data[] before the
packet parser gets a chance to reset pm->idx. If the incoming serial
stream never matches one of the expected packet headers, pm->idx can
advance past the fixed receive buffer and the next IRQ will write beyond
PM_MAX_LENGTH.

Reset stale indices before writing the next byte so malformed packet
streams cannot walk past the end of the local packet buffer.

Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
---
 drivers/input/touchscreen/penmount.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/input/touchscreen/penmount.c b/drivers/input/touchscreen/penmount.c
index 4b57b6664e37..ba09096c6573 100644
--- a/drivers/input/touchscreen/penmount.c
+++ b/drivers/input/touchscreen/penmount.c
@@ -163,6 +163,9 @@ static irqreturn_t pm_interrupt(struct serio *serio,
 {
 	struct pm *pm = serio_get_drvdata(serio);
 
+	if (pm->idx >= pm->packetsize || pm->idx >= PM_MAX_LENGTH)
+		pm->idx = 0;
+
 	pm->data[pm->idx] = data;
 
 	pm->parse_packet(pm);
-- 
2.50.1 (Apple Git-155)


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-03-25  1:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-23 12:17 [PATCH] Input: penmount: bound packet buffer indices in IRQ path Pengpeng Hou
2026-03-23 13:32 ` Andy Shevchenko
2026-03-24  2:29 ` Pengpeng Hou
2026-03-24 12:11   ` Andy Shevchenko
2026-03-24 13:14 ` [PATCH v2] " Pengpeng Hou
2026-03-24 13:47   ` Andy Shevchenko
2026-03-25  1:36   ` Dmitry Torokhov
2026-03-25  1:46   ` Pengpeng Hou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox