diff options
| author | Jitendra Sharma <shajit@codeaurora.org> | 2018-05-01 12:05:52 +0530 |
|---|---|---|
| committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2020-06-16 03:35:33 -0700 |
| commit | 9b2a0e89a37f8632024dc487f78f503d67e4fa38 (patch) | |
| tree | 804056131e5b84d12cb1aeef7d02a38b0de0b8a5 | |
| parent | 5bd445d880eb9952a6d6072965e4e9f85814b15b (diff) | |
soc: qcom: Reset string table index for each dump collection request
Section name should be placed in String table.
Currently, we used static version for string table
index to update subsequent section names.
Due to this string table index keeps on increasing
during every new dump(subsystem restart) request.
This ultimately will result in buffer overflow,
leading to Redzone overwritten.
Hence, as a fix, now reset, this string table
index once dump capture is complete.
Change-Id: Ibc2446ae4011db5291044eacdc1a1119597d862a
Signed-off-by: Jitendra Sharma <shajit@codeaurora.org>
| -rw-r--r-- | drivers/soc/qcom/ramdump.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/drivers/soc/qcom/ramdump.c b/drivers/soc/qcom/ramdump.c index c8353dc8a43a..c06ff285a512 100644 --- a/drivers/soc/qcom/ramdump.c +++ b/drivers/soc/qcom/ramdump.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2011-2017, The Linux Foundation. All rights reserved. +/* Copyright (c) 2011-2018, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -411,19 +411,19 @@ static inline char *elf_str_table(struct elfhdr *hdr) } static inline unsigned int set_section_name(const char *name, - struct elfhdr *ehdr) + struct elfhdr *ehdr, + int *strtable_idx) { char *strtab = elf_str_table(ehdr); - static int strtable_idx = 1; int idx, ret = 0; - idx = strtable_idx; + idx = *strtable_idx; if ((strtab == NULL) || (name == NULL)) return 0; ret = idx; idx += strlcpy((strtab + idx), name, MAX_NAME_LENGTH); - strtable_idx = idx + 1; + *strtable_idx = idx + 1; return ret; } @@ -436,6 +436,7 @@ static int _do_minidump(void *handle, struct ramdump_segment *segments, struct elfhdr *ehdr; struct elf_shdr *shdr; unsigned long offset, strtbl_off; + int strtable_idx = 1; if (!rd_dev->consumer_present) { pr_err("Ramdump(%s): No consumers. Aborting..\n", rd_dev->name); @@ -475,13 +476,14 @@ static int _do_minidump(void *handle, struct ramdump_segment *segments, shdr->sh_size = MAX_STRTBL_SIZE; shdr->sh_entsize = 0; shdr->sh_flags = 0; - shdr->sh_name = set_section_name("STR_TBL", ehdr); + shdr->sh_name = set_section_name("STR_TBL", ehdr, &strtable_idx); shdr++; for (i = 0; i < nsegments; i++, shdr++) { /* Update elf header */ shdr->sh_type = SHT_PROGBITS; - shdr->sh_name = set_section_name(segments[i].name, ehdr); + shdr->sh_name = set_section_name(segments[i].name, ehdr, + &strtable_idx); shdr->sh_addr = (elf_addr_t)segments[i].address; shdr->sh_size = segments[i].size; shdr->sh_flags = SHF_WRITE; |
