mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
To: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux1394-devel@lists.sourceforge.net
Subject: Re: [PATCH v2 0/2] firewire: Fix out-of-bounds access in CSR iterator
Date: Sun, 22 Nov 2026 22:49:47 +0900	[thread overview]
Message-ID: <20261122134947.GB503983@sakamocchi.jp> (raw)
In-Reply-To: <20261103151421.7248-1-sreekuttan2156239@gmail.com>

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

  parent reply	other threads:[~2026-11-22 13:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-02  6:53 [PATCH] " Sreeraj S Kurup
2026-11-03  4:24 ` Takashi Sakamoto
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
2026-11-22 13:49     ` Takashi Sakamoto [this message]
2026-11-24 16:57       ` [PATCH v2 0/2] firewire: Fix out-of-bounds access in " 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=20261122134947.GB503983@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®