Skip to content

Commit 43a1974

Browse files
SebasteuoXu Yilun
authored andcommitted
fpga: microchip-spi: fix zero header_size OOB read in mpf_ops_parse_header()
mpf_ops_parse_header() reads header_size from the bitstream at MPF_HEADER_SIZE_OFFSET (24). When header_size is zero, the expression *(buf + header_size - 1) reads one byte before the buffer start. Since initial_header_size is set to 71 in mpf_ops, the fpga-mgr core guarantees the buffer is large enough to reach MPF_HEADER_SIZE_OFFSET. The only real gap is the zero header_size case, which cannot be resolved by providing a larger buffer, so return -EINVAL. Fixes: 5f8d4a9 ("fpga: microchip-spi: add Microchip MPF FPGA manager") Cc: stable@vger.kernel.org Signed-off-by: Sebastian Alba Vives <sebasjosue84@gmail.com> Reviewed-by: Xu Yilun <yilun.xu@intel.com> Link: https://lore.kernel.org/r/20260518190742.61426-4-sebasjosue84@gmail.com Signed-off-by: Xu Yilun <yilun.xu@linux.intel.com>
1 parent fc3b071 commit 43a1974

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

drivers/fpga/microchip-spi.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ static int mpf_ops_parse_header(struct fpga_manager *mgr,
116116
}
117117

118118
header_size = *(buf + MPF_HEADER_SIZE_OFFSET);
119+
if (!header_size)
120+
return -EINVAL;
121+
119122
if (header_size > count) {
120123
info->header_size = header_size;
121124
return -EAGAIN;

0 commit comments

Comments
 (0)