public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sys_unshare: remove a broken CLONE_SIGHAND code
@ 2006-10-23 15:53 Oleg Nesterov
  2006-10-24  9:49 ` Peter Zijlstra
  0 siblings, 1 reply; 2+ messages in thread
From: Oleg Nesterov @ 2006-10-23 15:53 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Janak Desai, Peter Zijlstra, Alan Cox, linux-kernel

sys_unshare(CLONE_SIGHAND) is broken, the code under 'if (new_sigh)' is
never executed but very wrong. Just remove it to avoid a confusion,
task_lock() has nothing to do with ->sighand changing.

Also, change the comment in unshare_sighand(). Yes, CLONE_THREAD implies
CLONE_SIGHAND, but still it looks confusing. Also, we don't need to check
current->sighand != NULL.

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>

--- rc2-mm2/kernel/fork.c~	2006-10-22 19:28:17.000000000 +0400
+++ rc2-mm2/kernel/fork.c	2006-10-23 19:23:19.000000000 +0400
@@ -1523,15 +1523,13 @@ static int unshare_mnt_namespace(unsigne
 }
 
 /*
- * Unsharing of sighand for tasks created with CLONE_SIGHAND is not
- * supported yet
+ * Unsharing of sighand is not supported yet
  */
 static int unshare_sighand(unsigned long unshare_flags, struct sighand_struct **new_sighp)
 {
 	struct sighand_struct *sigh = current->sighand;
 
-	if ((unshare_flags & CLONE_SIGHAND) &&
-	    (sigh && atomic_read(&sigh->count) > 1))
+	if ((unshare_flags & CLONE_SIGHAND) && atomic_read(&sigh->count) > 1)
 		return -EINVAL;
 	else
 		return 0;
@@ -1605,7 +1603,7 @@ asmlinkage long sys_unshare(unsigned lon
 	int err = 0;
 	struct fs_struct *fs, *new_fs = NULL;
 	struct mnt_namespace *ns, *new_ns = NULL;
-	struct sighand_struct *sigh, *new_sigh = NULL;
+	struct sighand_struct *new_sigh = NULL;
 	struct mm_struct *mm, *new_mm = NULL, *active_mm = NULL;
 	struct files_struct *fd, *new_fd = NULL;
 	struct sem_undo_list *new_ulist = NULL;
@@ -1650,7 +1648,7 @@ asmlinkage long sys_unshare(unsigned lon
 		}
 	}
 
-	if (new_fs || new_ns || new_sigh || new_mm || new_fd || new_ulist ||
+	if (new_fs || new_ns || new_mm || new_fd || new_ulist ||
 				new_uts || new_ipc) {
 
 		task_lock(current);
@@ -1672,12 +1670,6 @@ asmlinkage long sys_unshare(unsigned lon
 			new_ns = ns;
 		}
 
-		if (new_sigh) {
-			sigh = current->sighand;
-			rcu_assign_pointer(current->sighand, new_sigh);
-			new_sigh = sigh;
-		}
-
 		if (new_mm) {
 			mm = current->mm;
 			active_mm = current->active_mm;


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

* Re: [PATCH] sys_unshare: remove a broken CLONE_SIGHAND code
  2006-10-23 15:53 [PATCH] sys_unshare: remove a broken CLONE_SIGHAND code Oleg Nesterov
@ 2006-10-24  9:49 ` Peter Zijlstra
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Zijlstra @ 2006-10-24  9:49 UTC (permalink / raw)
  To: Oleg Nesterov; +Cc: Andrew Morton, Janak Desai, Alan Cox, linux-kernel

On Mon, 2006-10-23 at 19:53 +0400, Oleg Nesterov wrote:
> sys_unshare(CLONE_SIGHAND) is broken, the code under 'if (new_sigh)' is
> never executed but very wrong. Just remove it to avoid a confusion,
> task_lock() has nothing to do with ->sighand changing.
> 
> Also, change the comment in unshare_sighand(). Yes, CLONE_THREAD implies
> CLONE_SIGHAND, but still it looks confusing. Also, we don't need to check
> current->sighand != NULL.
> 
> Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>

Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>

Good thing, this confused me when figuring out the ->siglock rules, its
tricky enough without being put off balance by dead code.

> --- rc2-mm2/kernel/fork.c~	2006-10-22 19:28:17.000000000 +0400
> +++ rc2-mm2/kernel/fork.c	2006-10-23 19:23:19.000000000 +0400
> @@ -1523,15 +1523,13 @@ static int unshare_mnt_namespace(unsigne
>  }
>  
>  /*
> - * Unsharing of sighand for tasks created with CLONE_SIGHAND is not
> - * supported yet
> + * Unsharing of sighand is not supported yet
>   */
>  static int unshare_sighand(unsigned long unshare_flags, struct sighand_struct **new_sighp)
>  {
>  	struct sighand_struct *sigh = current->sighand;
>  
> -	if ((unshare_flags & CLONE_SIGHAND) &&
> -	    (sigh && atomic_read(&sigh->count) > 1))
> +	if ((unshare_flags & CLONE_SIGHAND) && atomic_read(&sigh->count) > 1)
>  		return -EINVAL;
>  	else
>  		return 0;
> @@ -1605,7 +1603,7 @@ asmlinkage long sys_unshare(unsigned lon
>  	int err = 0;
>  	struct fs_struct *fs, *new_fs = NULL;
>  	struct mnt_namespace *ns, *new_ns = NULL;
> -	struct sighand_struct *sigh, *new_sigh = NULL;
> +	struct sighand_struct *new_sigh = NULL;
>  	struct mm_struct *mm, *new_mm = NULL, *active_mm = NULL;
>  	struct files_struct *fd, *new_fd = NULL;
>  	struct sem_undo_list *new_ulist = NULL;
> @@ -1650,7 +1648,7 @@ asmlinkage long sys_unshare(unsigned lon
>  		}
>  	}
>  
> -	if (new_fs || new_ns || new_sigh || new_mm || new_fd || new_ulist ||
> +	if (new_fs || new_ns || new_mm || new_fd || new_ulist ||
>  				new_uts || new_ipc) {
>  
>  		task_lock(current);
> @@ -1672,12 +1670,6 @@ asmlinkage long sys_unshare(unsigned lon
>  			new_ns = ns;
>  		}
>  
> -		if (new_sigh) {
> -			sigh = current->sighand;
> -			rcu_assign_pointer(current->sighand, new_sigh);
> -			new_sigh = sigh;
> -		}
> -
>  		if (new_mm) {
>  			mm = current->mm;
>  			active_mm = current->active_mm;
> 


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

end of thread, other threads:[~2006-10-24  9:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-23 15:53 [PATCH] sys_unshare: remove a broken CLONE_SIGHAND code Oleg Nesterov
2006-10-24  9:49 ` Peter Zijlstra

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