From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
To: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
Cc: linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] firewire: Fix out-of-bounds access in CSR iterator
Date: Tue, 3 Nov 2026 13:24:08 +0900 [thread overview]
Message-ID: <20261103042408.GB1229640@sakamocchi.jp> (raw)
In-Reply-To: <20261102065334.3087-1-sreekuttan2156239@gmail.com>
Hi,
Thank you for proposing this fix, however I have mixed feelings about
apply it, since the iterator is designed to traverse the cache data of the
actual configuration ROM, which has been generated by the parser.
If the configuration ROM contains any malformed entries, they should
already be detected by the parser. Therefore I don't think robustness of
the iterator is a critical concern in this case.
For the v7.4 kernel, I've merged KUnit tests for the parser
implementation. If you are still interested in discussion about this fix,
please check them at first then try to add tests specific to the iterator
itself.
On Mon, Nov 02, 2026 at 06:53:34AM +0000, Sreeraj S Kurup wrote:
> 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
Thanks
Takashi Sakamoto
next prev parent reply other threads:[~2026-11-03 4:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 6:53 Sreeraj S Kurup
2026-11-03 4:24 ` Takashi Sakamoto [this message]
2026-11-03 15:14 ` [PATCH v2 0/2] " Sreeraj S Kurup
2026-11-03 15:14 ` [PATCH v2 1/2] " Sreeraj S Kurup
2026-11-03 15:14 ` [PATCH v2 2/2] firewire: Add KUnit tests for " Sreeraj S Kurup
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=20261103042408.GB1229640@sakamocchi.jp \
--to=o-takashi@sakamocchi.jp \
--cc=linux-kernel@vger.kernel.org \
--cc=linux1394-devel@lists.sourceforge.net \
--cc=sreekuttan2156239@gmail.com \
/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®