diff options
-rw-r--r-- | fs/binfmt_elf_fdpic.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c index 32649f2a1654..ddd35d873391 100644 --- a/fs/binfmt_elf_fdpic.c +++ b/fs/binfmt_elf_fdpic.c | |||
@@ -136,8 +136,8 @@ static int elf_fdpic_fetch_phdrs(struct elf_fdpic_params *params, | |||
136 | 136 | ||
137 | retval = kernel_read(file, params->hdr.e_phoff, | 137 | retval = kernel_read(file, params->hdr.e_phoff, |
138 | (char *) params->phdrs, size); | 138 | (char *) params->phdrs, size); |
139 | if (retval < 0) | 139 | if (unlikely(retval != size)) |
140 | return retval; | 140 | return retval < 0 ? retval : -ENOEXEC; |
141 | 141 | ||
142 | /* determine stack size for this binary */ | 142 | /* determine stack size for this binary */ |
143 | phdr = params->phdrs; | 143 | phdr = params->phdrs; |
@@ -218,8 +218,11 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm, | |||
218 | phdr->p_offset, | 218 | phdr->p_offset, |
219 | interpreter_name, | 219 | interpreter_name, |
220 | phdr->p_filesz); | 220 | phdr->p_filesz); |
221 | if (retval < 0) | 221 | if (unlikely(retval != phdr->p_filesz)) { |
222 | if (retval >= 0) | ||
223 | retval = -ENOEXEC; | ||
222 | goto error; | 224 | goto error; |
225 | } | ||
223 | 226 | ||
224 | retval = -ENOENT; | 227 | retval = -ENOENT; |
225 | if (interpreter_name[phdr->p_filesz - 1] != '\0') | 228 | if (interpreter_name[phdr->p_filesz - 1] != '\0') |
@@ -245,8 +248,11 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm, | |||
245 | 248 | ||
246 | retval = kernel_read(interpreter, 0, bprm->buf, | 249 | retval = kernel_read(interpreter, 0, bprm->buf, |
247 | BINPRM_BUF_SIZE); | 250 | BINPRM_BUF_SIZE); |
248 | if (retval < 0) | 251 | if (unlikely(retval != BINPRM_BUF_SIZE)) { |
252 | if (retval >= 0) | ||
253 | retval = -ENOEXEC; | ||
249 | goto error; | 254 | goto error; |
255 | } | ||
250 | 256 | ||
251 | interp_params.hdr = *((struct elfhdr *) bprm->buf); | 257 | interp_params.hdr = *((struct elfhdr *) bprm->buf); |
252 | break; | 258 | break; |