summaryrefslogtreecommitdiffstats
path: root/fs/binfmt_flat.c
diff options
context:
space:
mode:
authorNicolas Pitre <nicolas.pitre@linaro.org>2016-07-24 11:30:17 -0400
committerGreg Ungerer <gerg@linux-m68k.org>2016-07-25 02:51:42 -0400
commitc995ee28d29d6f256c3a8a6c4e66469554374f25 (patch)
treeb8f84976a87dcb65671daac9e0be1b5633174586 /fs/binfmt_flat.c
parent4adbb6ac4b807e2f3f07887cf2a925fa012a7825 (diff)
binfmt_flat: prevent kernel dammage from corrupted executable headers
Signed-off-by: Nicolas Pitre <nico@linaro.org> Signed-off-by: Greg Ungerer <gerg@linux-m68k.org>
Diffstat (limited to 'fs/binfmt_flat.c')
-rw-r--r--fs/binfmt_flat.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
index c3ccdefdeac2..03301bad1f9b 100644
--- a/fs/binfmt_flat.c
+++ b/fs/binfmt_flat.c
@@ -466,6 +466,17 @@ static int load_flat_file(struct linux_binprm *bprm,
466 } 466 }
467 467
468 /* 468 /*
469 * Make sure the header params are sane.
470 * 28 bits (256 MB) is way more than reasonable in this case.
471 * If some top bits are set we have probable binary corruption.
472 */
473 if ((text_len | data_len | bss_len | stack_len | full_data) >> 28) {
474 pr_err("bad header\n");
475 ret = -ENOEXEC;
476 goto err;
477 }
478
479 /*
469 * fix up the flags for the older format, there were all kinds 480 * fix up the flags for the older format, there were all kinds
470 * of endian hacks, this only works for the simple cases 481 * of endian hacks, this only works for the simple cases
471 */ 482 */