public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Guard check in module loader against integer overflow
@ 2012-05-22 14:56 David Howells
  2012-05-23 12:11 ` Rusty Russell
  0 siblings, 1 reply; 2+ messages in thread
From: David Howells @ 2012-05-22 14:56 UTC (permalink / raw)
  To: rusty; +Cc: linux-kernel, David Howells

The check:

	if (len < hdr->e_shoff + hdr->e_shnum * sizeof(Elf_Shdr))

may not work if there's an overflow in the right-hand side of the condition.

Signed-off-by: David Howells <dhowells@redhat.com>
---

 kernel/module.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)


diff --git a/kernel/module.c b/kernel/module.c
index 78ac6ec..377cb06 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2429,7 +2429,8 @@ static int copy_and_check(struct load_info *info,
 		goto free_hdr;
 	}
 
-	if (len < hdr->e_shoff + hdr->e_shnum * sizeof(Elf_Shdr)) {
+	if (hdr->e_shoff >= len ||
+	    hdr->e_shnum * sizeof(Elf_Shdr) > len - hdr->e_shoff) {
 		err = -ENOEXEC;
 		goto free_hdr;
 	}


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Guard check in module loader against integer overflow
  2012-05-22 14:56 [PATCH] Guard check in module loader against integer overflow David Howells
@ 2012-05-23 12:11 ` Rusty Russell
  0 siblings, 0 replies; 2+ messages in thread
From: Rusty Russell @ 2012-05-23 12:11 UTC (permalink / raw)
  To: David Howells; +Cc: linux-kernel, David Howells

On Tue, 22 May 2012 15:56:13 +0100, David Howells <dhowells@redhat.com> wrote:
> The check:
> 
> 	if (len < hdr->e_shoff + hdr->e_shnum * sizeof(Elf_Shdr))
> 
> may not work if there's an overflow in the right-hand side of the condition.
> 
> Signed-off-by: David Howells <dhowells@redhat.com>

Thanks; though the sanity checks are merely against accidents, not
malice, it's worth fixing.

Applied,
Rusty.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-05-23 12:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-22 14:56 [PATCH] Guard check in module loader against integer overflow David Howells
2012-05-23 12:11 ` Rusty Russell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox