Limit -ENOEXEC to mean "this is not in my format".
This commit is contained in:
parent
6a03552381
commit
819cd3f41c
@ -53,7 +53,7 @@ static int elf_load_segment ( struct image *image, Elf_Phdr *phdr ) {
|
|||||||
/* Check segment lies within image */
|
/* Check segment lies within image */
|
||||||
if ( ( phdr->p_offset + phdr->p_filesz ) > image->len ) {
|
if ( ( phdr->p_offset + phdr->p_filesz ) > image->len ) {
|
||||||
DBG ( "ELF segment outside ELF file\n" );
|
DBG ( "ELF segment outside ELF file\n" );
|
||||||
return -ENOEXEC;
|
return -ERANGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find start address: use physical address for preference,
|
/* Find start address: use physical address for preference,
|
||||||
@ -65,7 +65,7 @@ static int elf_load_segment ( struct image *image, Elf_Phdr *phdr ) {
|
|||||||
dest = phdr->p_vaddr;
|
dest = phdr->p_vaddr;
|
||||||
if ( ! dest ) {
|
if ( ! dest ) {
|
||||||
DBG ( "ELF segment loads to physical address 0\n" );
|
DBG ( "ELF segment loads to physical address 0\n" );
|
||||||
return -ENOEXEC;
|
return -ERANGE;
|
||||||
}
|
}
|
||||||
buffer = phys_to_user ( dest );
|
buffer = phys_to_user ( dest );
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ int elf_load ( struct image *image ) {
|
|||||||
if ( phoff > image->len ) {
|
if ( phoff > image->len ) {
|
||||||
DBG ( "ELF program header %d outside ELF image\n",
|
DBG ( "ELF program header %d outside ELF image\n",
|
||||||
phnum );
|
phnum );
|
||||||
return -ENOEXEC;
|
return -ERANGE;
|
||||||
}
|
}
|
||||||
copy_from_user ( &phdr, image->data, phoff, sizeof ( phdr ) );
|
copy_from_user ( &phdr, image->data, phoff, sizeof ( phdr ) );
|
||||||
if ( ( rc = elf_load_segment ( image, &phdr ) ) != 0 )
|
if ( ( rc = elf_load_segment ( image, &phdr ) ) != 0 )
|
||||||
|
@ -40,6 +40,14 @@ struct image_type {
|
|||||||
* discarded after this call; the method must preserve any
|
* discarded after this call; the method must preserve any
|
||||||
* information it may require later (e.g. the execution
|
* information it may require later (e.g. the execution
|
||||||
* address) within the @c image structure.
|
* address) within the @c image structure.
|
||||||
|
*
|
||||||
|
* The method should return -ENOEXEC if and only if the image
|
||||||
|
* is not in the correct format. Other errors will be
|
||||||
|
* interpreted as "I claim this image format, but there's
|
||||||
|
* something wrong with it that makes it unloadable". In
|
||||||
|
* particular, returning -ENOEXEC will cause the image probing
|
||||||
|
* code to try the next available image type, while returning
|
||||||
|
* any other error will terminate image probing.
|
||||||
*/
|
*/
|
||||||
int ( * load ) ( struct image *image );
|
int ( * load ) ( struct image *image );
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user