From: Nicolas Pitre Date: Sun, 24 Jul 2016 15:30:17 +0000 (-0400) Subject: binfmt_flat: prevent kernel dammage from corrupted executable headers X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c995ee28d29d6f256c3a8a6c4e66469554374f25;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git binfmt_flat: prevent kernel dammage from corrupted executable headers Signed-off-by: Nicolas Pitre Signed-off-by: Greg Ungerer --- 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 @@ -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