فهرست منبع

kernel: properly handle paging errors in fit partition parser

The uImage.FIT partition uses page mapping without properly handling
paging errors. This can lead to Kernel Oops in case of read errors
while trying to parse uImage.FIT partitions.

Signed-off-by: Daniel Golle <[email protected]>
Daniel Golle 4 سال پیش
والد
کامیت
cf40141b51
1فایلهای تغییر یافته به همراه5 افزوده شده و 2 حذف شده
  1. 5 2
      target/linux/generic/files/block/partitions/fit.c

+ 5 - 2
target/linux/generic/files/block/partitions/fit.c

@@ -92,8 +92,11 @@ int parse_fit_partitions(struct parsed_partitions *state, u64 fit_start_sector,
 		return -ERANGE;
 		return -ERANGE;
 
 
 	page = read_mapping_page(mapping, fit_start_sector >> (PAGE_SHIFT - SECTOR_SHIFT), NULL);
 	page = read_mapping_page(mapping, fit_start_sector >> (PAGE_SHIFT - SECTOR_SHIFT), NULL);
-	if (!page)
-		return -ENOMEM;
+	if (IS_ERR(page))
+		return -EFAULT;
+
+	if (PageError(page))
+		return -EFAULT;
 
 
 	init_fit = page_address(page);
 	init_fit = page_address(page);