mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
zdump/dfi_mem_chunk: Replace dfi_mem_read() with dfi_mem_read_rc()
Always use the function dfi_mem_read_rc() which verifies that the given address and size fall within a valid memory chunk. We cannot trust user's input. Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
02086f26d2
commit
c58cfd1ec1
@@ -394,17 +394,6 @@ struct dfi_mem_chunk *dfi_mem_chunk_find(u64 addr)
|
||||
return mem_chunk_find(&l.mem_virt, addr);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read memory at given address and do kdump swap if necessary
|
||||
*/
|
||||
void dfi_mem_read(u64 addr, void *buf, size_t cnt)
|
||||
{
|
||||
util_log_print(UTIL_LOG_TRACE,
|
||||
"DFI virt mem read addr 0x%016lx size 0x%016lx\n",
|
||||
addr, cnt);
|
||||
mem_read(&l.mem_virt, addr, buf, cnt);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read physical memory at given address
|
||||
*/
|
||||
@@ -421,9 +410,12 @@ void dfi_mem_phys_read(u64 addr, void *buf, size_t cnt)
|
||||
*/
|
||||
int dfi_mem_read_rc(u64 addr, void *buf, size_t cnt)
|
||||
{
|
||||
util_log_print(UTIL_LOG_TRACE,
|
||||
"DFI virt mem read addr 0x%016lx size 0x%016lx\n",
|
||||
addr, cnt);
|
||||
if (!dfi_mem_range_valid(addr, cnt))
|
||||
return -EINVAL;
|
||||
dfi_mem_read(addr, buf, cnt);
|
||||
mem_read(&l.mem_virt, addr, buf, cnt);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,10 +55,6 @@ struct util_list *dfi_mem_chunk_list(void);
|
||||
#define dfi_mem_chunk_iterate(mem_chunk) \
|
||||
util_list_iterate(dfi_mem_chunk_list(), mem_chunk)
|
||||
|
||||
/*
|
||||
* DFI external functions
|
||||
*/
|
||||
void dfi_mem_read(u64 addr, void *buf, size_t cnt);
|
||||
int dfi_mem_read_rc(u64 addr, void *buf, size_t cnt);
|
||||
void dfi_mem_phys_read(u64 addr, void *buf, size_t cnt);
|
||||
|
||||
|
||||
@@ -98,7 +98,8 @@ static void dfo_s390_dump_chunk_lc_fn(struct dfo_chunk *dump_chunk,
|
||||
struct dfi_cpu *cpu = dump_chunk->data;
|
||||
char lc[0x2000];
|
||||
|
||||
dfi_mem_read(cpu->prefix + off, &lc[off], cnt);
|
||||
if (dfi_mem_read_rc(cpu->prefix + off, &lc[off], cnt))
|
||||
return;
|
||||
if (dfi_arch() == DFI_ARCH_64)
|
||||
cpu2lc_64(lc, cpu);
|
||||
else
|
||||
@@ -142,7 +143,8 @@ static void add_cpu_to_dfo(struct dfi_cpu *cpu)
|
||||
return;
|
||||
if (!dfi_cpu_content_fac_check(DFI_CPU_CONTENT_FAC_VX))
|
||||
return;
|
||||
dfi_mem_read(cpu->prefix, &lc, sizeof(lc));
|
||||
if (dfi_mem_read_rc(cpu->prefix, &lc, sizeof(lc)))
|
||||
return;
|
||||
if (!dfi_cpu_lc_has_vx_sa(&lc))
|
||||
return;
|
||||
vx_regs = zg_alloc(DFI_VX_SA_SIZE);
|
||||
|
||||
Reference in New Issue
Block a user