public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Oleg Drokin <green@linuxhacker.ru>
To: alan@redhat.com, marcelo@conectiva.com.br,
	linux-kernel@vger.kernel.org, akpm@digeo.co
Subject: [2.4] binfmt_elf memleak (fix)
Date: Tue, 22 Apr 2003 23:17:40 +0400	[thread overview]
Message-ID: <20030422191740.GA7172@linuxhacker.ru> (raw)

Hello!

   Some time ago I have found a memleak in binfmt_elf.c in 2.5, that was quickly
   fixed by Andrew Morton. The same problem is present in current 2.4 tree.
   Andrew's fix applies to 2.4 with a little fuzz and the result looks correct
   to me. Consider applying following patch (against latest 2.4 bk tree).

Bye,
    Oleg

===== fs/binfmt_elf.c 1.21 vs edited =====
--- 1.21/fs/binfmt_elf.c	Sat May  4 21:05:24 2002
+++ edited/fs/binfmt_elf.c	Tue Apr 22 23:09:38 2003
@@ -375,7 +375,6 @@
 	unsigned long text_data, elf_entry = ~0UL;
 	char * addr;
 	loff_t offset;
-	int retval;
 
 	current->mm->end_code = interp_ex->a_text;
 	text_data = interp_ex->a_text + interp_ex->a_data;
@@ -397,11 +396,9 @@
 	}
 
 	do_brk(0, text_data);
-	retval = -ENOEXEC;
 	if (!interpreter->f_op || !interpreter->f_op->read)
 		goto out;
-	retval = interpreter->f_op->read(interpreter, addr, text_data, &offset);
-	if (retval < 0)
+	if (interpreter->f_op->read(interpreter, addr, text_data, &offset) < 0)
 		goto out;
 	flush_icache_range((unsigned long)addr,
 	                   (unsigned long)addr + text_data);
@@ -607,7 +604,7 @@
 	retval = setup_arg_pages(bprm);
 	if (retval < 0) {
 		send_sig(SIGKILL, current, 0);
-		return retval;
+		goto out_free_dentry;
 	}
 	
 	current->mm->start_stack = bprm->p;
@@ -711,7 +708,8 @@
 			printk(KERN_ERR "Unable to load interpreter\n");
 			kfree(elf_phdata);
 			send_sig(SIGSEGV, current, 0);
-			return 0;
+			retval = -ENOEXEC; /* Nobody gets to see this, but.. */
+			goto out;
 		}
 	}
 

                 reply	other threads:[~2003-04-22 19:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20030422191740.GA7172@linuxhacker.ru \
    --to=green@linuxhacker.ru \
    --cc=akpm@digeo.co \
    --cc=alan@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcelo@conectiva.com.br \
    /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