The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Chris Wright <chrisw@osdl.org>
To: Florian Heinz <heinz@cronon-ag.de>, linux-kernel@vger.kernel.org
Cc: Chris Wright <chrisw@osdl.org>
Subject: Re: a.out issue
Date: Thu, 11 Nov 2004 23:15:02 -0800	[thread overview]
Message-ID: <20041111231502.M2357@build.pdx.osdl.net> (raw)
In-Reply-To: <20041112035112.GA2075@kurtwerks.com>; from kwall@kurtwerks.com on Thu, Nov 11, 2004 at 10:51:12PM -0500

* Kurt Wall (kwall@kurtwerks.com) wrote:
> On Thu, Nov 11, 2004 at 07:27:27PM -0800, Chris Wright took 39 lines to write:
> > * Florian Heinz (heinz@cronon-ag.de) wrote:
> > > seems like find_vma_prepare does not what insert_vm_struct expects when
> > > the whole addresspace is occupied.
> > 
> > The setup_arg_pages() is inserting an overlapping region.  If nothing
> > else, this will fix that problem.   Perhaps there's a better solution.
> 
> It solves the oops here (I didn't get the oops at first because I didn't
> have CONFIG_BINFMT_AOUT set).

Heh, you're better off with it config'd off ;-)

> Sort of. Now I just get "Killed" with
> vm.overcommit_memory set to 1; with it set to 0 I get a seg fault.

Yeah, it should generate a SIGKILL and terminate the program.  Thanks for
testing.  The patch below should fixup that segfault as well.

-chris
-- 
Linux Security Modules     http://lsm.immunix.org     http://lsm.bkbits.net


===== fs/binfmt_aout.c 1.25 vs edited =====
--- 1.25/fs/binfmt_aout.c	2004-10-18 22:26:36 -07:00
+++ edited/fs/binfmt_aout.c	2004-11-11 22:28:58 -08:00
@@ -43,13 +43,18 @@
 	.min_coredump	= PAGE_SIZE
 };
 
-static void set_brk(unsigned long start, unsigned long end)
+#define BAD_ADDR(x)	((unsigned long)(x) >= TASK_SIZE)
+
+static int set_brk(unsigned long start, unsigned long end)
 {
 	start = PAGE_ALIGN(start);
 	end = PAGE_ALIGN(end);
-	if (end <= start)
-		return;
-	do_brk(start, end - start);
+	if (end > start) {
+		unsigned long addr = do_brk(start, end - start);
+		if (BAD_ADDR(addr))
+			return addr;
+	}
+	return 0;
 }
 
 /*
@@ -413,7 +418,11 @@
 beyond_if:
 	set_binfmt(&aout_format);
 
-	set_brk(current->mm->start_brk, current->mm->brk);
+	retval = set_brk(current->mm->start_brk, current->mm->brk);
+	if (retval < 0) {
+		send_sig(SIGKILL, current, 0);
+		return retval;
+	}
 
 	retval = setup_arg_pages(bprm, EXSTACK_DEFAULT);
 	if (retval < 0) { 

      reply	other threads:[~2004-11-12  7:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-11 22:09 a.out issue Florian Heinz
2004-11-11 22:23 ` Ed Schouten
2004-11-11 22:29 ` Ed Schouten
2004-11-11 22:32 ` Chris Wright
2004-11-11 23:05   ` Ed Schouten
2004-11-11 23:31     ` Chris Wright
2004-11-12  0:11 ` Kurt Wall
2004-11-12  3:27 ` Chris Wright
2004-11-12  3:51   ` Kurt Wall
2004-11-12  7:15     ` Chris Wright [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20041111231502.M2357@build.pdx.osdl.net \
    --to=chrisw@osdl.org \
    --cc=heinz@cronon-ag.de \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox