Re: [PATCH v6 1/3] fpga: dfl: add bounds check in dfh_get_param_size()
Xu Yilun <[email protected]> Mon, 18 May 2026 22:42:00 +0800
| Newsgroups | org.kernel.vger.linux-fpga,org.kernel.vger.linux-kernel,org.kernel.vger.stable |
|---|---|
| Message-ID | <agslOI8ngOTuDFuS@yilunxu-OptiPlex-7050> |
On Tue, May 12, 2026 at 07:07:08AM -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")
No such commit. Please run checkpatch before posting.