Re: [PATCH v5 1/3] fpga: dfl: add bounds check in dfh_get_param_size()
From: Xu Yilun
Date: Mon May 11 2026 - 12:02:37 EST
On Mon, May 04, 2026 at 06:13:30AM -0600, Sebastian Alba Vives wrote:
> dfh_get_param_size() can return a parameter size larger than the feature
> region because the loop bounds check is evaluated before incrementing
> size. If the EOP (End of Parameters) bit is set in the same iteration,
> the inflated size is returned without re-validation against max.
>
> This can cause create_feature_instance() to call memcpy_fromio() with a
> size exceeding the ioremap'd region when a malicious FPGA device provides
> crafted DFHv1 parameter headers.
>
> Add a bounds check after the size increment to ensure the accumulated
> size never exceeds the feature boundary.
>
> Fixes: a80a4b2b2e4f ("fpga: dfl: add support for DFHv1")
> Signed-off-by: Sebastian Alba Vives <sebasjosue84@xxxxxxxxx>
> ---
> Changes in v5:
> - Add blank line after the new bounds check.
> Suggested by Xu Yilun.
> Changes in v4:
> - Resubmit as full series per maintainer request.
> Changes in v2:
> - Use (size > max) instead of (size + DFHv1_PARAM_HDR > max).
> Suggested by Xu Yilun.
> ---
> drivers/fpga/dfl.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c
> index 81d7a68..4c63c7c 100644
> --- a/drivers/fpga/dfl.c
> +++ b/drivers/fpga/dfl.c
> @@ -1134,6 +1134,7 @@ static int dfh_get_param_size(void __iomem *dfh_base, resource_size_t max)
> size += next * sizeof(u64);
> if (size > max)
> return -EINVAL;
> +
Hey, please provide a patch that can apply to linux-next. I can do
nothing to your series. Please read Documentation/process/ before
submit.
Also, please make a cover-letter (Patch #0) when you make the patch
series.
> if (FIELD_GET(DFHv1_PARAM_HDR_NEXT_EOP, v))
> return size;
> }
> --
> 2.43.0
>