Merge to Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0...
[linux-2.6.git] / net / tux / cgi.c
index 476dcd5..e839bf6 100644 (file)
@@ -30,6 +30,8 @@
 
 static int exec_usermode(char *program_path, char *argv[], char *envp[])
 {
+       struct files_struct *files = current->files;
+       struct fdtable *fdt;
        int i, err;
 
        err = tux_chroot(tux_cgiroot);
@@ -41,11 +43,16 @@ static int exec_usermode(char *program_path, char *argv[], char *envp[])
        /* Allow execve args to be in kernel space. */
        set_fs(KERNEL_DS);
 
-       for (i = 3; i < current->files->max_fds; i++ )
-               if (current->files->fd[i])
+       // TODO: is this RCU-safe?
+       spin_lock(&files->file_lock);
+       fdt = files_fdtable(files);
+       spin_unlock(&files->file_lock);
+
+       for (i = 3; i < fdt->max_fds; i++ )
+               if (fdt->fd[i])
                        tux_close(i);
 
-       err = __exec_usermodehelper(program_path, argv, envp);
+       err = __exec_usermodehelper(program_path, argv, envp, NULL);
        if (err < 0)
                return err;
        return 0;
@@ -68,12 +75,12 @@ static int exec_helper (void * data)
        int ret;
 
        sprintf(current->comm,"doexec - %d", current->pid);
-#if CONFIG_SMP
+#ifdef CONFIG_SMP
        if (!tux_cgi_inherit_cpu) {
                cpumask_t map;
-               
+
                cpus_and(map, cpu_online_map, tux_cgi_cpu_mask);
-       
+
                if (!(cpus_empty(map)))
                        set_cpus_allowed(current, map);
                else
@@ -104,6 +111,9 @@ static int exec_helper (void * data)
         * CGI application.
         */
        if (param->pipe_fds) {
+               struct files_struct *files = current->files;
+               struct fdtable *fdt;
+
                tux_close(1);
                tux_close(2);
                tux_close(4);
@@ -114,11 +124,12 @@ static int exec_helper (void * data)
                tux_close(3);
                tux_close(5);
                // do not close on exec.
-               spin_lock(&current->files->file_lock);
-               FD_CLR(0, current->files->close_on_exec);
-               FD_CLR(1, current->files->close_on_exec);
-               FD_CLR(2, current->files->close_on_exec);
-               spin_unlock(&current->files->file_lock);
+               spin_lock(&files->file_lock);
+               fdt = files_fdtable(files);
+               FD_CLR(0, fdt->close_on_exec);
+               FD_CLR(1, fdt->close_on_exec);
+               FD_CLR(2, fdt->close_on_exec);
+               spin_unlock(&files->file_lock);
        }
        ret = exec_usermode(param->command, param->argv, param->envp);
        if (ret < 0)