Input: elan_i2c - validate firmware size before use

commit 76b0d0baa9 upstream.

Ensure that the firmware file is large enough to contain the expected
number of pages and the signature (which resides at the end of the
firmware blob) before accessing them to prevent potential out-of-bounds
reads.

Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/ae2dOgiFvXRm4BHo@google.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Dmitry Torokhov
2026-06-19 13:37:01 +02:00
committed by Greg Kroah-Hartman
parent 9fe1d84f7e
commit 331d49b4e1
+5
View File
@@ -646,6 +646,11 @@ static ssize_t elan_sysfs_update_fw(struct device *dev,
return error;
}
if (fw->size < data->fw_signature_address + sizeof(signature)) {
dev_err(dev, "firmware file too small\n");
return -EBADF;
}
/* Firmware file must match signature data */
fw_signature = &fw->data[data->fw_signature_address];
if (memcmp(fw_signature, signature, sizeof(signature)) != 0) {