Skip to content

Commit

Permalink
binfmt_flat: prevent kernel dammage from corrupted executable headers
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas Pitre <[email protected]>
Signed-off-by: Greg Ungerer <[email protected]>
  • Loading branch information
Nicolas Pitre authored and Greg Ungerer committed Jul 25, 2016
1 parent 4adbb6a commit c995ee2
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions fs/binfmt_flat.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,17 @@ static int load_flat_file(struct linux_binprm *bprm,
goto err;
}

/*
* Make sure the header params are sane.
* 28 bits (256 MB) is way more than reasonable in this case.
* If some top bits are set we have probable binary corruption.
*/
if ((text_len | data_len | bss_len | stack_len | full_data) >> 28) {
pr_err("bad header\n");
ret = -ENOEXEC;
goto err;
}

/*
* fix up the flags for the older format, there were all kinds
* of endian hacks, this only works for the simple cases
Expand Down

0 comments on commit c995ee2

Please sign in to comment.