Skip to content

Commit 17e3f9c

Browse files
committed
Merge: firmware: cs_dsp: Return error if block header overflows file
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/4989 JIRA: https://issues.redhat.com/browse/RHEL-53650 CVE: CVE-2024-42238 Signed-off-by: David Arcari <darcari@redhat.com> Approved-by: Steve Best <sbest@redhat.com> Approved-by: Tony Camuso <tcamuso@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Lucas Zampieri <lzampier@redhat.com>
2 parents d056a06 + 43b0db8 commit 17e3f9c

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

drivers/firmware/cirrus/cs_dsp.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,8 +1526,13 @@ static int cs_dsp_load(struct cs_dsp *dsp, const struct firmware *firmware,
15261526
cs_dsp_dbg(dsp, "%s: timestamp %llu\n", file,
15271527
le64_to_cpu(footer->timestamp));
15281528

1529-
while (pos < firmware->size &&
1530-
sizeof(*region) < firmware->size - pos) {
1529+
while (pos < firmware->size) {
1530+
/* Is there enough data for a complete block header? */
1531+
if (sizeof(*region) > firmware->size - pos) {
1532+
ret = -EOVERFLOW;
1533+
goto out_fw;
1534+
}
1535+
15311536
region = (void *)&(firmware->data[pos]);
15321537
region_name = "Unknown";
15331538
reg = 0;
@@ -2215,8 +2220,13 @@ static int cs_dsp_load_coeff(struct cs_dsp *dsp, const struct firmware *firmware
22152220
pos = le32_to_cpu(hdr->len);
22162221

22172222
blocks = 0;
2218-
while (pos < firmware->size &&
2219-
sizeof(*blk) < firmware->size - pos) {
2223+
while (pos < firmware->size) {
2224+
/* Is there enough data for a complete block header? */
2225+
if (sizeof(*blk) > firmware->size - pos) {
2226+
ret = -EOVERFLOW;
2227+
goto out_fw;
2228+
}
2229+
22202230
blk = (void *)(&firmware->data[pos]);
22212231

22222232
type = le16_to_cpu(blk->type);

0 commit comments

Comments
 (0)