binfmt_flat: prevent kernel dammage from corrupted executable headers
authorNicolas Pitre <nicolas.pitre@linaro.org>
Sun, 24 Jul 2016 15:30:17 +0000 (11:30 -0400)
committerGreg Ungerer <gerg@linux-m68k.org>
Mon, 25 Jul 2016 06:51:42 +0000 (16:51 +1000)
Signed-off-by: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Greg Ungerer <gerg@linux-m68k.org>
fs/binfmt_flat.c

index c3ccdefdeac28862cafaeeb76cdcb037de2c6f8c..03301bad1f9b09588aa5b3f8990e9511b01e5ba1 100644 (file)
@@ -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
This page took 0.025505 seconds and 5 git commands to generate.