[PATCH] binfmt_elf; check clear_user() return value in load_elf_binary()

From: Jesper Juhl
Date: Mon Oct 25 2004 - 16:37:53 EST



Andrew,

Here's yet another small patch for fs/binfmt_elf.c. This one was created
incrementally to my previous patch that dealt with the clear_user() in
padzero(). It doesn't depend on that patch, but just so you know why the
offsets may be a little fuzzy if you apply it to vanilla.

The patch gets rid of this warning:
fs/binfmt_elf.c: In function `load_elf_binary':
fs/binfmt_elf.c:758: warning: ignoring return value of `clear_user', declared with attribute warn_unused_result

And makes sure that we check the return value of clear_user() and fail
appropriately if it fails to do its job.

With this and the two previous patches we are now down to only two
warnings (and hopefully have a few potential problems less) in
binfmt_elf.c - patches for the remaining warnings will appear soon.

Patch has been compile tested.
Patch has been boot tested.
Patch needs more eyeballs to make sure sending SIGKILL and returning
-EFAULT really is appropriate here.


Signed-off-by: Jesper Juhl <juhl-lkml@xxxxxx>

diff -up linux-2.6.10-rc1-bk2/fs/binfmt_elf.c.juhl1 linux-2.6.10-rc1-bk2/fs/binfmt_elf.c
--- linux-2.6.10-rc1-bk2/fs/binfmt_elf.c.juhl1 2004-10-25 23:01:28.000000000 +0200
+++ linux-2.6.10-rc1-bk2/fs/binfmt_elf.c 2004-10-25 23:15:38.000000000 +0200
@@ -761,7 +761,11 @@ static int load_elf_binary(struct linux_
nbyte = ELF_MIN_ALIGN - nbyte;
if (nbyte > elf_brk - elf_bss)
nbyte = elf_brk - elf_bss;
- clear_user((void __user *) elf_bss + load_bias, nbyte);
+ if (clear_user((void __user *) elf_bss + load_bias, nbyte)) {
+ send_sig(SIGKILL, current, 0);
+ retval = -EFAULT;
+ goto out_free_dentry;
+ }
}
}


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/