Browse Source

Limit -ENOEXEC to mean "this is not in my format".

tags/v0.9.3
Michael Brown 18 years ago
parent
commit
819cd3f41c
2 changed files with 11 additions and 3 deletions
  1. 3
    3
      src/image/elf.c
  2. 8
    0
      src/include/gpxe/image.h

+ 3
- 3
src/image/elf.c View File

53
 	/* Check segment lies within image */
53
 	/* Check segment lies within image */
54
 	if ( ( phdr->p_offset + phdr->p_filesz ) > image->len ) {
54
 	if ( ( phdr->p_offset + phdr->p_filesz ) > image->len ) {
55
 		DBG ( "ELF segment outside ELF file\n" );
55
 		DBG ( "ELF segment outside ELF file\n" );
56
-		return -ENOEXEC;
56
+		return -ERANGE;
57
 	}
57
 	}
58
 
58
 
59
 	/* Find start address: use physical address for preference,
59
 	/* Find start address: use physical address for preference,
65
 		dest = phdr->p_vaddr;
65
 		dest = phdr->p_vaddr;
66
 	if ( ! dest ) {
66
 	if ( ! dest ) {
67
 		DBG ( "ELF segment loads to physical address 0\n" );
67
 		DBG ( "ELF segment loads to physical address 0\n" );
68
-		return -ENOEXEC;
68
+		return -ERANGE;
69
 	}
69
 	}
70
 	buffer = phys_to_user ( dest );
70
 	buffer = phys_to_user ( dest );
71
 
71
 
113
 		if ( phoff > image->len ) {
113
 		if ( phoff > image->len ) {
114
 			DBG ( "ELF program header %d outside ELF image\n",
114
 			DBG ( "ELF program header %d outside ELF image\n",
115
 			      phnum );
115
 			      phnum );
116
-			return -ENOEXEC;
116
+			return -ERANGE;
117
 		}
117
 		}
118
 		copy_from_user ( &phdr, image->data, phoff, sizeof ( phdr ) );
118
 		copy_from_user ( &phdr, image->data, phoff, sizeof ( phdr ) );
119
 		if ( ( rc = elf_load_segment ( image, &phdr ) ) != 0 )
119
 		if ( ( rc = elf_load_segment ( image, &phdr ) ) != 0 )

+ 8
- 0
src/include/gpxe/image.h View File

40
 	 * discarded after this call; the method must preserve any
40
 	 * discarded after this call; the method must preserve any
41
 	 * information it may require later (e.g. the execution
41
 	 * information it may require later (e.g. the execution
42
 	 * address) within the @c image structure.
42
 	 * address) within the @c image structure.
43
+	 *
44
+	 * The method should return -ENOEXEC if and only if the image
45
+	 * is not in the correct format.  Other errors will be
46
+	 * interpreted as "I claim this image format, but there's
47
+	 * something wrong with it that makes it unloadable".  In
48
+	 * particular, returning -ENOEXEC will cause the image probing
49
+	 * code to try the next available image type, while returning
50
+	 * any other error will terminate image probing.
43
 	 */
51
 	 */
44
 	int ( * load ) ( struct image *image );
52
 	int ( * load ) ( struct image *image );
45
 };
53
 };

Loading…
Cancel
Save