[Crash-utility] Re: [RFC PATCH 2/9] diskdump: Add function,sanity_check_page_desc() that sanity checks an entry of page, descriptor table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2/15/24 18:04, devel-request@xxxxxxxxxxxxxxxxxxxxxxxxxxx wrote:

Date: Thu, 15 Feb 2024 19:02:38 +0900
From: HATAYAMA Daisuke<d.hatayama@xxxxxxxxxxx>
Subject:  [RFC PATCH 2/9] diskdump: Add function
	sanity_check_page_desc() that sanity checks an entry of page
	descriptor table
To:devel@xxxxxxxxxxxxxxxxxxxxxxxxxxx
Message-ID:<20240215100246.437-3-d.hatayama@xxxxxxxxxxx>

Add function sanity_check_page_desc(). This sanity checks an given
entry of page descriptor table based on the conditions that are
expected to hold in each filed, i.e.:

- offset must be smaller than a file size of dump file.
- size must not be 0 and equal to or smaller than a block size.
- If size is equal to a block size, it means the page is not
   compressed and so flags must be 0.
- If size is smaller than a block size, it means the page is
   compressed and so flags must hold any of compression flags.
- page_flags must constantly be 0 because this field is unused.

This will be later used to validate a single entry of page descriptor
table when it is read in cache_page() and to validate a whole part of
page descriptor table when --validate_kdump_headers command-line
option is specified.
---
  diskdump.c | 11 +++++++++++
  1 file changed, 11 insertions(+)

diff --git a/diskdump.c b/diskdump.c
index a495120..2d2cf97 100644
--- a/diskdump.c
+++ b/diskdump.c
@@ -92,6 +92,7 @@ static void dump_note_offsets(FILE *);
  static char *vmcoreinfo_read_string(const char *);
  static void diskdump_get_osrelease(void);
  static int valid_note_address(unsigned char *);
+static int sanity_check_page_desc(page_desc_t *);
/* For split dumpfile */
  static struct diskdump_data **dd_list = NULL;
@@ -3134,3 +3135,13 @@ out:
  	FREEBUF(zram_buf);
  	return len;
  }
+
+static int sanity_check_page_desc(page_desc_t *pd)
+{
+	return pd->offset < dd->stat.st_size &&


I do not remember if there might be a hole in the kcore or dump core, if yes, could the above checking break something in such cases? Not sure, just impression.


Thanks

Lianbo

+		pd->size &&
+		pd->size <= dd->block_size &&
+		((pd->size == dd->block_size && pd->flags == 0) ||
+		 (pd->size < dd->block_size && pd->flags & (DUMP_DH_COMPRESSED_ZLIB|DUMP_DH_COMPRESSED_LZO|DUMP_DH_COMPRESSED_SNAPPY|DUMP_DH_COMPRESSED_ZSTD))) &&
+		pd->page_flags == 0;
+}
-- 2.43.1
--
Crash-utility mailing list -- devel@xxxxxxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxxxxxxxxxxxx
https://${domain_name}/admin/lists/devel.lists.crash-utility.osci.io/
Contribution Guidelines: https://github.com/crash-utility/crash/wiki




[Index of Archives]     [Fedora Development]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [KDE Users]     [Fedora Tools]

 

Powered by Linux