mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] firewire: Fix out-of-bounds access in CSR iterator
@ 2026-11-02  6:53 Sreeraj S Kurup
  0 siblings, 0 replies; only message in thread
From: Sreeraj S Kurup @ 2026-11-02  6:53 UTC (permalink / raw)
  To: o-takashi; +Cc: linux1394-devel, linux-kernel, Sreeraj S Kurup

The fw_csr_iterator_next() function reads ci->p before
checking if it has reached the end.

This can cause an out-of-bounds read when the iterator
has no more entries.

Check the iterator position before reading the entry.
Move the pointer forward only after reading a valid entry.

Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
---
 drivers/firewire/core-device.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
index a68100d3da0b..36667841ca3c 100644
--- a/drivers/firewire/core-device.c
+++ b/drivers/firewire/core-device.c
@@ -40,10 +40,14 @@ EXPORT_SYMBOL(fw_csr_iterator_init);
 
 int fw_csr_iterator_next(struct fw_csr_iterator *ci, int *key, int *value)
 {
+	if (ci->p >= ci->end)
+		return 0;
+
 	*key = *ci->p >> 24;
 	*value = *ci->p & 0xffffff;
 
-	return ci->p++ < ci->end;
+	ci->p++;
+	return 1;
 }
 EXPORT_SYMBOL(fw_csr_iterator_next);
 
-- 
2.55.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-02  6:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-02  6:53 [PATCH] firewire: Fix out-of-bounds access in CSR iterator Sreeraj S Kurup

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®