]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - kernel/fork.c
[PATCH] autofs4: white space cleanup for waitq.c
[linux-2.6-omap-h63xx.git] / kernel / fork.c
index a8eab86de7f103123158f2de62481e67366a57b0..e0a2b449dea64ea1b0d79bdc7124a74cb5c4cbdf 100644 (file)
@@ -181,6 +181,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
        /* One for us, one for whoever does the "release_task()" (usually parent) */
        atomic_set(&tsk->usage,2);
        atomic_set(&tsk->fs_excl, 0);
+       tsk->btrace_seq = 0;
        return tsk;
 }
 
@@ -607,12 +608,12 @@ static struct files_struct *alloc_files(void)
        atomic_set(&newf->count, 1);
 
        spin_lock_init(&newf->file_lock);
+       newf->next_fd = 0;
        fdt = &newf->fdtab;
-       fdt->next_fd = 0;
        fdt->max_fds = NR_OPEN_DEFAULT;
-       fdt->max_fdset = __FD_SETSIZE;
-       fdt->close_on_exec = &newf->close_on_exec_init;
-       fdt->open_fds = &newf->open_fds_init;
+       fdt->max_fdset = EMBEDDED_FD_SET_SIZE;
+       fdt->close_on_exec = (fd_set *)&newf->close_on_exec_init;
+       fdt->open_fds = (fd_set *)&newf->open_fds_init;
        fdt->fd = &newf->fd_array[0];
        INIT_RCU_HEAD(&fdt->rcu);
        fdt->free_files = NULL;
@@ -768,8 +769,7 @@ int unshare_files(void)
        struct files_struct *files  = current->files;
        int rc;
 
-       if(!files)
-               BUG();
+       BUG_ON(!files);
 
        /* This can race but the race causes us to copy when we don't
           need to and drop the copy */
@@ -847,7 +847,7 @@ static inline int copy_signal(unsigned long clone_flags, struct task_struct * ts
        hrtimer_init(&sig->real_timer, CLOCK_MONOTONIC, HRTIMER_REL);
        sig->it_real_incr.tv64 = 0;
        sig->real_timer.function = it_real_fn;
-       sig->real_timer.data = tsk;
+       sig->tsk = tsk;
 
        sig->it_virt_expires = cputime_zero;
        sig->it_virt_incr = cputime_zero;
@@ -1020,6 +1020,7 @@ static task_t *copy_process(unsigned long clone_flags,
                p->mempolicy = NULL;
                goto bad_fork_cleanup_cpuset;
        }
+       mpol_fix_fork_child_flag(p);
 #endif
 
 #ifdef CONFIG_DEBUG_MUTEXES
@@ -1061,6 +1062,12 @@ static task_t *copy_process(unsigned long clone_flags,
         */
        p->clear_child_tid = (clone_flags & CLONE_CHILD_CLEARTID) ? child_tidptr: NULL;
 
+       /*
+        * sigaltstack should be cleared when sharing the same VM
+        */
+       if ((clone_flags & (CLONE_VM|CLONE_VFORK)) == CLONE_VM)
+               p->sas_ss_sp = p->sas_ss_size = 0;
+
        /*
         * Syscall tracing should be turned off in the child regardless
         * of CLONE_PTRACE.
@@ -1472,9 +1479,7 @@ static int unshare_vm(unsigned long unshare_flags, struct mm_struct **new_mmp)
 
        if ((unshare_flags & CLONE_VM) &&
            (mm && atomic_read(&mm->mm_users) > 1)) {
-               *new_mmp = dup_mm(current);
-               if (!*new_mmp)
-                       return -ENOMEM;
+               return -EINVAL;
        }
 
        return 0;
@@ -1530,6 +1535,12 @@ asmlinkage long sys_unshare(unsigned long unshare_flags)
 
        check_unshare_flags(&unshare_flags);
 
+       /* Return -EINVAL for all unsupported flags */
+       err = -EINVAL;
+       if (unshare_flags & ~(CLONE_THREAD|CLONE_FS|CLONE_NEWNS|CLONE_SIGHAND|
+                               CLONE_VM|CLONE_FILES|CLONE_SYSVSEM))
+               goto bad_unshare_out;
+
        if ((err = unshare_thread(unshare_flags)))
                goto bad_unshare_out;
        if ((err = unshare_fs(unshare_flags, &new_fs)))
@@ -1563,7 +1574,7 @@ asmlinkage long sys_unshare(unsigned long unshare_flags)
 
                if (new_sigh) {
                        sigh = current->sighand;
-                       current->sighand = new_sigh;
+                       rcu_assign_pointer(current->sighand, new_sigh);
                        new_sigh = sigh;
                }