pstore: fix potential logic issue in pstore read interface
authorChen Gong <gong.chen@linux.intel.com>
Mon, 16 May 2011 18:01:39 +0000 (11:01 -0700)
committerTony Luck <tony.luck@intel.com>
Mon, 16 May 2011 18:05:08 +0000 (11:05 -0700)
1) in the calling of erst_read, the parameter of buffer size
maybe overflows and cause crash

2) the return value of erst_read should be checked more strictly

Signed-off-by: Chen Gong <gong.chen@linux.intel.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
drivers/acpi/apei/erst.c

index ddb68c4f8d3e4e4e9d7835d73291304de57e65d3..e6cef8e1b53455db9927668c1da1157c364e6b6e 100644 (file)
@@ -1006,7 +1006,14 @@ skip:
        }
 
        len = erst_read(record_id, &rcd->hdr, sizeof(*rcd) +
-                         erst_erange.size);
+                       erst_info.bufsize);
+       /* The record may be cleared by others, try read next record */
+       if (len == -ENOENT)
+               goto skip;
+       else if (len < 0) {
+               rc = -1;
+               goto out;
+       }
        if (uuid_le_cmp(rcd->hdr.creator_id, CPER_CREATOR_PSTORE) != 0)
                goto skip;