mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] CRED: Move the exec mutex release out of bprm_free()
@ 2008-08-21 12:39 David Howells
  2008-08-21 23:32 ` James Morris
  0 siblings, 1 reply; 2+ messages in thread
From: David Howells @ 2008-08-21 12:39 UTC (permalink / raw)
  To: jmorris; +Cc: dhowells, linux-kernel, linux-security-module

Move the exec mutex release out of free_bprm() and into the error handling
paths of do_execve() and compat_do_execve().  install_exec_creds() already
takes care of the success path.

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

 fs/compat.c |    3 +--
 fs/exec.c   |    7 ++-----
 2 files changed, 3 insertions(+), 7 deletions(-)


diff --git a/fs/compat.c b/fs/compat.c
index 918f0f2..af24b8a 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -1373,7 +1373,7 @@ int compat_do_execve(char * filename,
 	file = open_exec(filename);
 	retval = PTR_ERR(file);
 	if (IS_ERR(file))
-		goto out_free;
+		goto out_unlock;
 
 	sched_exec();
 
@@ -1427,7 +1427,6 @@ out_file:
 		allow_write_access(bprm->file);
 		fput(bprm->file);
 	}
-	goto out_free;
 
 out_unlock:
 	mutex_unlock(&current->cred_exec_mutex);
diff --git a/fs/exec.c b/fs/exec.c
index 7b71679..9fa9a2d 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1277,10 +1277,8 @@ EXPORT_SYMBOL(search_binary_handler);
 void free_bprm(struct linux_binprm *bprm)
 {
 	free_arg_pages(bprm);
-	if (bprm->cred) {
-		mutex_unlock(&current->cred_exec_mutex);
+	if (bprm->cred)
 		abort_creds(bprm->cred);
-	}
 	kfree(bprm);
 }
 
@@ -1319,7 +1317,7 @@ int do_execve(char * filename,
 	file = open_exec(filename);
 	retval = PTR_ERR(file);
 	if (IS_ERR(file))
-		goto out_free;
+		goto out_unlock;
 
 	sched_exec();
 
@@ -1376,7 +1374,6 @@ out_file:
 		allow_write_access(bprm->file);
 		fput(bprm->file);
 	}
-	goto out_free;
 
 out_unlock:
 	mutex_unlock(&current->cred_exec_mutex);


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

* Re: [PATCH] CRED: Move the exec mutex release out of bprm_free()
  2008-08-21 12:39 [PATCH] CRED: Move the exec mutex release out of bprm_free() David Howells
@ 2008-08-21 23:32 ` James Morris
  0 siblings, 0 replies; 2+ messages in thread
From: James Morris @ 2008-08-21 23:32 UTC (permalink / raw)
  To: David Howells; +Cc: linux-kernel, linux-security-module

On Thu, 21 Aug 2008, David Howells wrote:

> Move the exec mutex release out of free_bprm() and into the error handling
> paths of do_execve() and compat_do_execve().  install_exec_creds() already
> takes care of the success path.
> 
> Signed-off-by: David Howells <dhowells@redhat.com>

This patch does not apply to my tree:

Applying CRED: Move the exec mutex release out of bprm_free()
error: patch failed: fs/compat.c:1373
error: fs/compat.c: patch does not apply
error: patch failed: fs/exec.c:1319
error: fs/exec.c: patch does not apply
Patch failed at 0001.


> ---
> 
>  fs/compat.c |    3 +--
>  fs/exec.c   |    7 ++-----
>  2 files changed, 3 insertions(+), 7 deletions(-)
> 
> 
> diff --git a/fs/compat.c b/fs/compat.c
> index 918f0f2..af24b8a 100644
> --- a/fs/compat.c
> +++ b/fs/compat.c
> @@ -1373,7 +1373,7 @@ int compat_do_execve(char * filename,
>  	file = open_exec(filename);
>  	retval = PTR_ERR(file);
>  	if (IS_ERR(file))
> -		goto out_free;
> +		goto out_unlock;
>  
>  	sched_exec();
>  
> @@ -1427,7 +1427,6 @@ out_file:
>  		allow_write_access(bprm->file);
>  		fput(bprm->file);
>  	}
> -	goto out_free;
>  
>  out_unlock:
>  	mutex_unlock(&current->cred_exec_mutex);
> diff --git a/fs/exec.c b/fs/exec.c
> index 7b71679..9fa9a2d 100644
> --- a/fs/exec.c
> +++ b/fs/exec.c
> @@ -1277,10 +1277,8 @@ EXPORT_SYMBOL(search_binary_handler);
>  void free_bprm(struct linux_binprm *bprm)
>  {
>  	free_arg_pages(bprm);
> -	if (bprm->cred) {
> -		mutex_unlock(&current->cred_exec_mutex);
> +	if (bprm->cred)
>  		abort_creds(bprm->cred);
> -	}
>  	kfree(bprm);
>  }
>  
> @@ -1319,7 +1317,7 @@ int do_execve(char * filename,
>  	file = open_exec(filename);
>  	retval = PTR_ERR(file);
>  	if (IS_ERR(file))
> -		goto out_free;
> +		goto out_unlock;
>  
>  	sched_exec();
>  
> @@ -1376,7 +1374,6 @@ out_file:
>  		allow_write_access(bprm->file);
>  		fput(bprm->file);
>  	}
> -	goto out_free;
>  
>  out_unlock:
>  	mutex_unlock(&current->cred_exec_mutex);
> 

-- 
James Morris
<jmorris@namei.org>

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

end of thread, other threads:[~2008-08-21 23:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-21 12:39 [PATCH] CRED: Move the exec mutex release out of bprm_free() David Howells
2008-08-21 23:32 ` James Morris

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

all inboxes | Powered by JetHome®