瀏覽代碼

[HCI] Display "Not an executable image" when appropriate

PXE is a catch-all image format with no signature checks.  If an
unsupported image file is loaded, it will be treated as a PXE image.  In
most cases, the image will be too large to be loaded as a PXE image (which
has to fit in base memory), so the error returned to the user will be that
the segment could not fit within the memory region.

Add an explicit check to pxe_image.c to reject images larger than base
memory with ENOEXEC.

Add ENOEXEC to the error string table.
tags/v0.9.4
Michael Brown 16 年之前
父節點
當前提交
3475b693b7
共有 2 個檔案被更改,包括 9 行新增0 行删除
  1. 8
    0
      src/arch/i386/image/pxe_image.c
  2. 1
    0
      src/hci/strerror.c

+ 8
- 0
src/arch/i386/image/pxe_image.c 查看文件

@@ -84,6 +84,14 @@ int pxe_load ( struct image *image ) {
84 84
 	size_t memsz = image->len;
85 85
 	int rc;
86 86
 
87
+	/* Images too large to fit in base memory cannot be PXE
88
+	 * images.  We include this check to help prevent unrecognised
89
+	 * images from being marked as PXE images, since PXE images
90
+	 * have no signature we can check against.
91
+	 */
92
+	if ( filesz > ( 0xa0000 - 0x7c00 ) )
93
+		return -ENOEXEC;
94
+
87 95
 	/* There are no signature checks for PXE; we will accept anything */
88 96
 	if ( ! image->type )
89 97
 		image->type = &pxe_image_type;

+ 1
- 0
src/hci/strerror.c 查看文件

@@ -118,4 +118,5 @@ struct errortab common_errors[] __errortab = {
118 118
 	{ ETIMEDOUT, "Connection timed out" },
119 119
 	{ EPIPE, "Broken pipe" },
120 120
 	{ ECANCELED, "Operation cancelled" },
121
+	{ ENOEXEC, "Not an executable image" },
121 122
 };

Loading…
取消
儲存