Re: [PATCH v2 0/2] firewire: Fix out-of-bounds access in CSR iterator
From: Takashi Sakamoto
Date: Sun Nov 22 2026 - 08:49:56 EST
Hi,
Sorry for the delayed response. I wanted to take some time to carefully
consider the issue that this patch is intended to address.
On Tue, Nov 03, 2026 at 03:14:19PM +0000, Sreeraj S Kurup wrote:
> Hi Takashi,
>
> This series fixes an out-of-bounds read in fw_csr_iterator_next() and
> adds KUnit tests for the CSR iterator.
>
> The first patch fixes the iterator by checking its position before
> dereferencing the current entry.
>
> The second patch adds a separate KUnit test suite covering:
>
> - Iteration over valid entries.
> - Calling the iterator after reaching the end.
> - Iteration over an empty directory.
>
> It also adds a separate Kconfig option for the iterator tests.
>
> Testing:
>
> - Ran the FireWire KUnit tests using:
> python3 tools/testing/kunit/kunit.py run
> --kunitconfig=drivers/firewire/.kunitconfig
>
> - All tests passed.
>
> - Results:
> [14:47:14] ======== firewire-config-rom-iterator (3 subtests) =========
> [14:47:14] [PASSED] test_csr_iterator_with_valid_entries
> [14:47:14] [PASSED] test_csr_iterator_at_end
> [14:47:14] [PASSED] test_csr_iterator_empty_directory
> [14:47:14] ========== [PASSED] firewire-config-rom-iterator ===========
>
> Please review the patches.
>
> Regards,
> Sreeraj
At this point, I would like to reject this patchset, as I believe it
attempts to address problems that are unlikely to occur in practice.
In my review of the previous patchset, I mentioned the KUnit tests for
configuration ROM parser (read_config_rom() function). I hope these tests
have helped demonstrate that the parser can detect structurally malformed
configuration ROMs.
Consequently, the parser copies the content of well-formed configuration
ROM to the cache, after which the CSR iterator operates on that cached
data. Therefore, an out-of-bounds access is unlikely as long as the
iterator is used as intended, i.e. initialized directly with either
'struct fw_node.config_rom' or 'struct fw_unit.directory'.
I think it would be preferable to document the preconditions of
fw_csr_iterator_init() in the kernel documentation rather than add more
code to the function.
Of course, there is still room for discussion from the perspective of
defensive programming. However, I think it is also worth considering the
principle of Design by Contract.
> Sreeraj S Kurup (2):
> firewire: Fix out-of-bounds access in CSR iterator
> firewire: Add KUnit tests for CSR iterator
>
> drivers/firewire/.kunitconfig | 1 +
> drivers/firewire/Kconfig | 12 +++
> drivers/firewire/config-rom-iterator-test.c | 93 +++++++++++++++++++++
> drivers/firewire/core-device.c | 10 ++-
> 4 files changed, 115 insertions(+), 1 deletion(-)
> create mode 100644 drivers/firewire/config-rom-iterator-test.c
>
> --
> 2.55.0
Thanks
Takashi Sakamoto