* Re: [PATCH v3 0/2] firewire: core: validate descriptor and sub-block lengths in fw_core_add_descriptor()
@ 2026-07-27 17:42 Sreeraj S Kurup
2026-07-30 13:03 ` Takashi Sakamoto
0 siblings, 1 reply; 4+ messages in thread
From: Sreeraj S Kurup @ 2026-07-27 17:42 UTC (permalink / raw)
To: o-takashi; +Cc: linux1394-devel, linux-kernel
Hi Takashi,
Thanks for applying the series to the for-next branch!
Regarding the change in generate_config_rom():
I dropped that specific change from this patchset to keep the series
strictly focused on the out-of-bounds issue in fw_core_add_descriptor().
`WARN_ON(j != config_rom_length)` acts as an assertion that the ROM block
traversal matched the expected length. Replacing it with pr_warn() and
clamping `config_rom_length = j` avoids a kernel warning splat, but if
j != config_rom_length occurs, it indicates an unexpected state during
ROM generation rather than a standard runtime condition.
If you feel handling length mismatches gracefully via pr_warn() and updating
config_rom_length is preferred over the WARN_ON assertion, I would be happy
to send a follow-up patch for it.
Thanks,
Sreeraj
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3 0/2] firewire: core: validate descriptor and sub-block lengths in fw_core_add_descriptor()
2026-07-27 17:42 [PATCH v3 0/2] firewire: core: validate descriptor and sub-block lengths in fw_core_add_descriptor() Sreeraj S Kurup
@ 2026-07-30 13:03 ` Takashi Sakamoto
0 siblings, 0 replies; 4+ messages in thread
From: Takashi Sakamoto @ 2026-07-30 13:03 UTC (permalink / raw)
To: Sreeraj S Kurup; +Cc: linux1394-devel, linux-kernel
Hi,
On Mon, Jul 27, 2026 at 05:42:31PM +0000, Sreeraj S Kurup wrote:
> Hi Takashi,
>
> Thanks for applying the series to the for-next branch!
>
> Regarding the change in generate_config_rom():
>
> I dropped that specific change from this patchset to keep the series
> strictly focused on the out-of-bounds issue in fw_core_add_descriptor().
>
> `WARN_ON(j != config_rom_length)` acts as an assertion that the ROM block
> traversal matched the expected length. Replacing it with pr_warn() and
> clamping `config_rom_length = j` avoids a kernel warning splat, but if
> j != config_rom_length occurs, it indicates an unexpected state during
> ROM generation rather than a standard runtime condition.
>
> If you feel handling length mismatches gracefully via pr_warn() and updating
> config_rom_length is preferred over the WARN_ON assertion, I would be happy
> to send a follow-up patch for it.
Hm. The case that j does not equals to config_rom_length seems to be a
programming mistake and should be fixed immediately. So let me leave it
as is without any mitigation.
Thanks
Takashi Sakamoto
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v3 0/2] firewire: core: validate descriptor and sub-block lengths in fw_core_add_descriptor()
@ 2026-07-25 15:52 Sreeraj S Kurup
2026-07-27 0:47 ` Takashi Sakamoto
0 siblings, 1 reply; 4+ messages in thread
From: Sreeraj S Kurup @ 2026-07-25 15:52 UTC (permalink / raw)
To: o-takashi; +Cc: linux1394-devel, linux-kernel, Sreeraj S Kurup
This two-patch series addresses potential out-of-bounds memory
accesses when parsing Config ROM descriptors in
fw_core_add_descriptor().
Patch 1 adds overall length validation using the in_range() macro
to ensure descriptors fit within standard IEEE 1394 Config ROM
limits (256 quadlets).
Patch 2 validates individual sub-block header lengths during
iteration to prevent reading past allocated buffer boundaries on
malformed inputs.
v2 -> v3:
- Split original single patch into two distinct commits for cleaner
review as requested by Takashi Sakamoto.
- Simplified overall length check using the in_range() macro.
Sreeraj S Kurup (2):
firewire: core: validate overall descriptor length in
fw_core_add_descriptor()
firewire: core: validate sub-block lengths in fw_core_add_descriptor()
drivers/firewire/core-card.c | 28 ++++++++++++++++++++++------
1 file changed, 22 insertions(+), 6 deletions(-)
--
2.54.0
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v3 0/2] firewire: core: validate descriptor and sub-block lengths in fw_core_add_descriptor()
2026-07-25 15:52 Sreeraj S Kurup
@ 2026-07-27 0:47 ` Takashi Sakamoto
0 siblings, 0 replies; 4+ messages in thread
From: Takashi Sakamoto @ 2026-07-27 0:47 UTC (permalink / raw)
To: Sreeraj S Kurup; +Cc: linux1394-devel, linux-kernel
Hi,
On Sat, Jul 25, 2026 at 03:52:53PM +0000, Sreeraj S Kurup wrote:
> This two-patch series addresses potential out-of-bounds memory
> accesses when parsing Config ROM descriptors in
> fw_core_add_descriptor().
>
> Patch 1 adds overall length validation using the in_range() macro
> to ensure descriptors fit within standard IEEE 1394 Config ROM
> limits (256 quadlets).
>
> Patch 2 validates individual sub-block header lengths during
> iteration to prevent reading past allocated buffer boundaries on
> malformed inputs.
>
> v2 -> v3:
> - Split original single patch into two distinct commits for cleaner
> review as requested by Takashi Sakamoto.
> - Simplified overall length check using the in_range() macro.
>
> Sreeraj S Kurup (2):
> firewire: core: validate overall descriptor length in
> fw_core_add_descriptor()
> firewire: core: validate sub-block lengths in fw_core_add_descriptor()
>
> drivers/firewire/core-card.c | 28 ++++++++++++++++++++++------
> 1 file changed, 22 insertions(+), 6 deletions(-)
Applied to for-next branch.
By the way, how do you think about the following change in your previous
patches? It seems to be omitted from current patchset.
======== 8< --------
diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
index a754c6366b97..cb8ce491fe9d 100644
--- a/drivers/firewire/core-card.c
+++ b/drivers/firewire/core-card.c
@@ -143,7 +143,11 @@ static void generate_config_rom(struct fw_card *card, __be32 *config_rom)
for (i = 0; i < j; i += length + 1)
length = fw_compute_block_crc(config_rom + i);
- WARN_ON(j != config_rom_length);
+ if (j != config_rom_length) {
+ pr_warn("FireWire ROM length mismatch: expected %zu, got %d\n",
+ config_rom_length, j);
+ config_rom_length = j;
+ }
}
======== 8< --------
Thanks
Takashi Sakamoto
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-07-30 13:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-27 17:42 [PATCH v3 0/2] firewire: core: validate descriptor and sub-block lengths in fw_core_add_descriptor() Sreeraj S Kurup
2026-07-30 13:03 ` Takashi Sakamoto
-- strict thread matches above, loose matches on Subject: below --
2026-07-25 15:52 Sreeraj S Kurup
2026-07-27 0:47 ` Takashi Sakamoto
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®