Skip to content

Commit bb82e0b

Browse files
tiwairafaeljw
authored andcommitted
ACPI: APEI / ERST: Fix missing error handling in erst_reader()
The commit f6f8285 ("pstore: pass allocated memory region back to caller") changed the check of the return value from erst_read() in erst_reader() in the following way: if (len == -ENOENT) goto skip; - else if (len < 0) { - rc = -1; + else if (len < sizeof(*rcd)) { + rc = -EIO; goto out; This introduced another bug: since the comparison with sizeof() is cast to unsigned, a negative len value doesn't hit any longer. As a result, when an error is returned from erst_read(), the code falls through, and it may eventually lead to some weird thing like memory corruption. This patch adds the negative error value check more explicitly for addressing the issue. Fixes: f6f8285 (pstore: pass allocated memory region back to caller) Cc: All applicable <[email protected]> Tested-by: Jerry Tang <[email protected]> Signed-off-by: Takashi Iwai <[email protected]> Acked-by: Kees Cook <[email protected]> Reviewed-by: Borislav Petkov <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 1291a0d commit bb82e0b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/acpi/apei/erst.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,7 @@ static ssize_t erst_reader(struct pstore_record *record)
10071007
/* The record may be cleared by others, try read next record */
10081008
if (len == -ENOENT)
10091009
goto skip;
1010-
else if (len < sizeof(*rcd)) {
1010+
else if (len < 0 || len < sizeof(*rcd)) {
10111011
rc = -EIO;
10121012
goto out;
10131013
}

0 commit comments

Comments
 (0)