diff options
| author | Aruna Balakrishnaiah <aruna@linux.vnet.ibm.com> | 2013-08-08 13:04:00 -0400 |
|---|---|---|
| committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2013-08-09 04:06:44 -0400 |
| commit | 156c9ebdaca20d9ce428dc189f2b24d2a0ec8eaf (patch) | |
| tree | bb640b16b2be9040839f8d585a167458e1cfcd96 | |
| parent | 7e76f34fa103677a27d96a7cfef8ce61389a32de (diff) | |
powerpc/pseries: Add backward compatibilty to read old kernel oops-log
Older kernels has just length information in their header. Handle it
while reading old kernel oops log from pstore.
Applies on top of powerpc/pseries: Fix buffer overflow when reading from pstore
Signed-off-by: Aruna Balakrishnaiah <aruna@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
| -rw-r--r-- | arch/powerpc/platforms/pseries/nvram.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/arch/powerpc/platforms/pseries/nvram.c b/arch/powerpc/platforms/pseries/nvram.c index 893f36053c97..6a5f2b1f32ca 100644 --- a/arch/powerpc/platforms/pseries/nvram.c +++ b/arch/powerpc/platforms/pseries/nvram.c | |||
| @@ -720,15 +720,25 @@ static ssize_t nvram_pstore_read(u64 *id, enum pstore_type_id *type, | |||
| 720 | 720 | ||
| 721 | if (nvram_type_ids[read_type] == PSTORE_TYPE_DMESG) { | 721 | if (nvram_type_ids[read_type] == PSTORE_TYPE_DMESG) { |
| 722 | int length, unzipped_len; | 722 | int length, unzipped_len; |
| 723 | size_t hdr_size; | ||
| 723 | 724 | ||
| 724 | oops_hdr = (struct oops_log_info *)buff; | 725 | oops_hdr = (struct oops_log_info *)buff; |
| 725 | length = oops_hdr->report_length; | 726 | if (oops_hdr->version < OOPS_HDR_VERSION) { |
| 727 | /* Old format oops header had 2-byte record size */ | ||
| 728 | hdr_size = sizeof(u16); | ||
| 729 | length = oops_hdr->version; | ||
| 730 | time->tv_sec = 0; | ||
| 731 | time->tv_nsec = 0; | ||
| 732 | } else { | ||
| 733 | hdr_size = sizeof(*oops_hdr); | ||
| 734 | length = oops_hdr->report_length; | ||
| 735 | time->tv_sec = oops_hdr->timestamp; | ||
| 736 | time->tv_nsec = 0; | ||
| 737 | } | ||
| 726 | *buf = kmalloc(length, GFP_KERNEL); | 738 | *buf = kmalloc(length, GFP_KERNEL); |
| 727 | if (*buf == NULL) | 739 | if (*buf == NULL) |
| 728 | return -ENOMEM; | 740 | return -ENOMEM; |
| 729 | memcpy(*buf, buff + sizeof(*oops_hdr), length); | 741 | memcpy(*buf, buff + hdr_size, length); |
| 730 | time->tv_sec = oops_hdr->timestamp; | ||
| 731 | time->tv_nsec = 0; | ||
| 732 | kfree(buff); | 742 | kfree(buff); |
| 733 | 743 | ||
| 734 | if (err_type == ERR_TYPE_KERNEL_PANIC_GZ) { | 744 | if (err_type == ERR_TYPE_KERNEL_PANIC_GZ) { |
