linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: Marcelo Tosatti <marcelo@conectiva.com.br>,
	Alan Cox <alan@lxorguk.ukuu.org.uk>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH] 2.4: Restore current->files in flush_old_exec
Date: Sat, 9 Aug 2003 11:11:16 +1000	[thread overview]
Message-ID: <20030809011116.GB10487@gondor.apana.org.au> (raw)
In-Reply-To: <20030809010736.GA10487@gondor.apana.org.au>

[-- Attachment #1: Type: text/plain, Size: 614 bytes --]

Hi:

The unshare_files patch to flush_old_exec() did not restore the original
state when exec_mmap fails.  This patch fixes that.

At this point, I believe the unshare_files stuff should be fine from
a correctness point of view.  However, there is still a performance
problem as every ELF exec call ends up dupliating the files structure
as well as walking through all file locks.

Cheers,
-- 
Debian GNU/Linux 3.0 is out! ( http://www.debian.org/ )
Email:  Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

[-- Attachment #2: q --]
[-- Type: text/plain, Size: 1206 bytes --]

Index: kernel-source-2.4/fs/exec.c
===================================================================
RCS file: /home/gondolin/herbert/src/CVS/debian/kernel-source-2.4/fs/exec.c,v
retrieving revision 1.5
diff -u -r1.5 exec.c
--- kernel-source-2.4/fs/exec.c	26 Jul 2003 02:54:45 -0000	1.5
+++ kernel-source-2.4/fs/exec.c	9 Aug 2003 01:00:28 -0000
@@ -557,7 +557,7 @@
 	char * name;
 	int i, ch, retval;
 	struct signal_struct * oldsig;
-	struct files_struct * files;
+	struct files_struct *files, *ftmp;
 
 	/*
 	 * Make sure we have a private signal table
@@ -576,8 +576,6 @@
 	retval = unshare_files();
 	if(retval)
 		goto flush_failed;
-	steal_locks(files, current->files);
-	put_files_struct(files);
 	
 	/* 
 	 * Release all of the old mmap stuff
@@ -586,6 +584,8 @@
 	if (retval) goto mmap_failed;
 
 	/* This is the point of no return */
+	steal_locks(files, current->files);
+	put_files_struct(files);
 	release_old_signals(oldsig);
 
 	current->sas_ss_sp = current->sas_ss_size = 0;
@@ -623,6 +623,9 @@
 	return 0;
 
 mmap_failed:
+	ftmp = current->files;
+	current->files = files;
+	put_files_struct(ftmp);
 flush_failed:
 	spin_lock_irq(&current->sigmask_lock);
 	if (current->sig != oldsig) {

  reply	other threads:[~2003-08-09  1:16 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-08 10:53 [PATCH] 2.4: Fix steal_locks race Herbert Xu
2003-08-09  1:07 ` Herbert Xu
2003-08-09  1:11   ` Herbert Xu [this message]
2003-08-09  1:48     ` [PATCH] 2.4: Restore current->files in flush_old_exec Andreas Gruenbacher
2003-08-09  1:48     ` Herbert Xu
2003-08-09  2:20       ` Andreas Gruenbacher
2003-08-09  2:53         ` Herbert Xu
2003-08-09  3:01           ` Andreas Gruenbacher
2003-08-09  3:19             ` Andreas Gruenbacher
     [not found]               ` <Pine.LNX.4.53.0308090554160.18879@Chaos.suse.de>
     [not found]                 ` <20030809100518.GA14688@gondor.apana.org.au>
2003-08-09 10:41                   ` Andreas Gruenbacher
2003-08-09  1:46   ` [PATCH] 2.4: Fix steal_locks race Andreas Gruenbacher
2003-08-09  2:04   ` Andreas Gruenbacher
2003-08-09  2:52     ` Herbert Xu
2003-08-09  3:13       ` Andreas Gruenbacher
2003-08-09  3:19         ` Herbert Xu
2003-08-09  3:30           ` Andreas Gruenbacher
2003-08-09  2:59 ` Andreas Gruenbacher
2003-08-09  3:04   ` Herbert Xu
2003-08-09  3:17     ` Andreas Gruenbacher

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=20030809011116.GB10487@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=alan@lxorguk.ukuu.org.uk \
    --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;
as well as URLs for NNTP newsgroup(s).