From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B58CA44AB61; Tue, 21 Jul 2026 21:42:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784670124; cv=none; b=M+4Fo47+pSNNrUdFD7sZt7Uo1oncxzHWRTVi5ssu4K3cITQ1ozSyMUQSvqdaW54349dOYsiuN2+FBXd36sBOc0mydmyRixSEFyKUxZq3znHj7RSRNwx33F4s2lwZ92F3rBnpaY5yzbknPKPN+DJCanrdPkdBLeVuXet/pyqlrVI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784670124; c=relaxed/simple; bh=eNptxZ2yN+sNHnvpnGFR+sxkdQuH6D1llMZuZzyYf3o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ofgFPfEGH0cbd7iFkCRFHLwwxf3QrNTqJtSLjGQ3uvR5nISegFeUeZs9991/M+gsVLejWDqCwwol5n6SqHrQyF/NlJeO6sfU8vnRAXxF1vFJEpb+sqnSqT+lLBhepss94dlbJMMI/5q7NVWx2Adfhmz1HUWjrTU6xE5krdF6bZE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=l9eOKR19; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="l9eOKR19" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 280601F000E9; Tue, 21 Jul 2026 21:42:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784670123; bh=XG6LtmRg8v0mK4WAvmu/hz5sQm9AgjfW8Od4jEVkObo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=l9eOKR19dgnteZ2EPgp4SZrw/K/FLxSDKEltHC9lAR7BPt5Z1AdFnpO1Y4HmJMY/F 1974XnvJPMCs26/63ARgMewq5lpakcPF4t03FSC2BWh+Wx5Hw6RQN3ghC5mSsSP/9c S4lSgFv6UEB7rMle0CjdbX8UZlHzXHTBG1f94Jqo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Sebastian Alba Vives , Xu Yilun , Xu Yilun Subject: [PATCH 6.1 0814/1067] fpga: microchip-spi: fix zero header_size OOB read in mpf_ops_parse_header() Date: Tue, 21 Jul 2026 17:23:35 +0200 Message-ID: <20260721152442.763446309@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152424.521567757@linuxfoundation.org> References: <20260721152424.521567757@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sebastian Alba Vives commit 43a1974da6bc7ce8f4d1dc1d03d56997428c29c3 upstream. 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: 5f8d4a900830 ("fpga: microchip-spi: add Microchip MPF FPGA manager") Cc: stable@vger.kernel.org Signed-off-by: Sebastian Alba Vives Reviewed-by: Xu Yilun Link: https://lore.kernel.org/r/20260518190742.61426-4-sebasjosue84@gmail.com Signed-off-by: Xu Yilun Signed-off-by: Greg Kroah-Hartman --- drivers/fpga/microchip-spi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/fpga/microchip-spi.c b/drivers/fpga/microchip-spi.c index 6134cea86ac8..cc8f6d7bb978 100644 --- a/drivers/fpga/microchip-spi.c +++ b/drivers/fpga/microchip-spi.c @@ -116,6 +116,9 @@ static int mpf_ops_parse_header(struct fpga_manager *mgr, } header_size = *(buf + MPF_HEADER_SIZE_OFFSET); + if (!header_size) + return -EINVAL; + if (header_size > count) { info->header_size = header_size; return -EAGAIN; -- 2.55.0