Re: [PATCH] pstore/ram: Validate ECC parameters against Reed-Solomon constraint

From: Tzung-Bi Shih
Date: Sun Jun 22 2025 - 23:03:41 EST


On Fri, Jun 20, 2025 at 02:47:57PM +0900, Naoya Tezuka wrote:
> The Reed-Solomon library enforces the constraint `n <= 2^m - 1` via a
> BUG_ON(), where `n` is `block_size + ecc_size` and `m` is `symsize` for
^^^^^^^^
Better to provide a link, e.g. [1].

[1]: https://elixir.bootlin.com/linux/v6.15/source/lib/reed_solomon/decode_rs.c#L43

> the pstore RAM backend. A driver providing invalid parameters can trigger
> this, leading to a kernel panic. For more details on the theory behind:
> https://www.cs.cmu.edu/~guyb/realworld/reedsolomon/reed_solomon_codes.html
>
> This issue was discovered during develop chromeos_pstore driver:

s/develop/developing/.

> https://lore.kernel.org/lkml/20250610050458.4014083-1-naoyatezuka@xxxxxxxxxxxx/
>
> Add a check to validate this constraint before initializing Reed-Solomon
> codec. On failure, return -EINVAL to prevent the panic.
>
> Signed-off-by: Naoya Tezuka <naoyatezuka@xxxxxxxxxxxx>

The patch makes sense to me:
Reviewed-by: Tzung-Bi Shih <tzungbi@xxxxxxxxxx>