From c951b82bb3198f435ebfe2af6db8c82f3d905fc6 Mon Sep 17 00:00:00 2001 From: HATAYAMA Daisuke Date: Fri, 25 Dec 2020 15:48:46 +0900 Subject: [PATCH 05/11] diskdump, zram: fix fault error when reading zram disk with no symbol information When no zram symbol information is initialized, reading memory swapped out into zram disk results in fault error as follows: crash> rd -u 0x00007f1cf6c37000 rd: invalid structure member offset: zram_compressor FILE: diskdump.c LINE: 2753 FUNCTION: try_zram_decompress() [./crash] error trace: 47a7b1 => 5766eb => 5401b7 => 540146 540146: OFFSET_verify.part.0+70 5401b7: OFFSET_verify+39 5766eb: try_zram_decompress+635 47a7b1: readmem+273 rd: invalid structure member offset: zram_compressor FILE: diskdump.c LINE: 2753 FUNCTION: try_zram_decompress() Before zram support, trying to read memory that is swapped out resulted in inaccessible error as follows: crash> rd -u 0x00007f1cf6c37000 rd: invalid user virtual address: 7f1cf6c37000 type: "64-bit UVADDR" This behavior is problematic for crash gcore command to support zram. The fault error terminates gcore command and then generating core file fails; this is regression. On the other hand, in the previous one, gcore command can continue by writing zero pages. Signed-off-by: HATAYAMA Daisuke --- diskdump.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/diskdump.c b/diskdump.c index 8dda58643f6a..2b80e4a96ce4 100644 --- a/diskdump.c +++ b/diskdump.c @@ -2753,8 +2753,11 @@ try_zram_decompress(ulonglong pte_val, unsigned char *buf, ulong len, ulonglong return 0; } - if (INVALID_MEMBER(zram_compressor)) + if (INVALID_MEMBER(zram_compressor)) { zram_init(); + if (INVALID_MEMBER(zram_compressor)) + return 0; + } if (CRASHDEBUG(2)) error(WARNING, "this page has swapped to zram\n"); -- 2.29.2