--- zzzz-none-000/linux-2.4.17/fs/exec.c 2001-12-21 17:41:55.000000000 +0000 +++ sangam-fb-322/linux-2.4.17/fs/exec.c 2004-11-24 13:22:16.000000000 +0000 @@ -38,6 +38,8 @@ #define __NO_VERSION__ #include +#include + #include #include #include @@ -420,8 +422,8 @@ active_mm = current->active_mm; current->mm = mm; current->active_mm = mm; - task_unlock(current); activate_mm(active_mm, mm); + task_unlock(current); mm_release(); if (old_mm) { if (active_mm != old_mm) BUG(); @@ -579,6 +581,7 @@ flush_signal_handlers(current); flush_old_files(current->files); + exit_itimers(current); return 0; @@ -866,6 +869,11 @@ if (IS_ERR(file)) return retval; + TRACE_FILE_SYSTEM(TRACE_EV_FILE_SYSTEM_EXEC, + 0, + file->f_dentry->d_name.len, + file->f_dentry->d_name.name); + bprm.p = PAGE_SIZE*MAX_ARG_PAGES-sizeof(void *); memset(bprm.page, 0, MAX_ARG_PAGES*sizeof(bprm.page[0])); @@ -933,6 +941,10 @@ __MOD_DEC_USE_COUNT(old->module); } +#ifdef CONFIG_MULTITHREADED_CORES +static spinlock_t coredump_lock = SPIN_LOCK_UNLOCKED; +#endif + int do_coredump(long signr, struct pt_regs * regs) { struct linux_binfmt * binfmt; @@ -945,16 +957,32 @@ binfmt = current->binfmt; if (!binfmt || !binfmt->core_dump) goto fail; +#ifdef CONFIG_MULTITHREADED_CORES + spin_lock (&coredump_lock); + if (!current->mm->dumpable) { + spin_unlock (&coredump_lock); + goto fail; + } + current->mm->dumpable = 0; + spin_unlock (&coredump_lock); +#else if (!current->mm->dumpable) goto fail; current->mm->dumpable = 0; +#endif if (current->rlim[RLIMIT_CORE].rlim_cur < binfmt->min_coredump) goto fail; memcpy(corename,"core.", 5); corename[4] = '\0'; - if (core_uses_pid || atomic_read(¤t->mm->mm_users) != 1) +#ifndef CONFIG_MULTITHREADED_CORES + if (core_uses_pid || atomic_read(¤t->mm->mm_users) != 1) sprintf(&corename[4], ".%d", current->pid); +#else + if (core_uses_pid) + sprintf(&corename[4], ".%d", current->pid); +#endif + file = filp_open(corename, O_CREAT | 2 | O_NOFOLLOW, 0600); if (IS_ERR(file)) goto fail; @@ -973,7 +1001,17 @@ if (do_truncate(file->f_dentry, 0) != 0) goto close_fail; +#ifdef CONFIG_MULTITHREADED_CORES + /* Stop our siblings. We have the kernel lock, but schedule() will + nicely release it for us. */ + if (stop_all_threads (current->mm) != 0) + goto close_fail; +#endif retval = binfmt->core_dump(signr, regs, file); +#ifdef CONFIG_MULTITHREADED_CORES + /* Restart our siblings (so they can die, or whatever). */ + start_all_threads (current->mm); +#endif close_fail: filp_close(file, NULL);