diff -rc2P linux-3.13.11/fs/exec.c linux-3.13.11-acct/fs/exec.c *** linux-3.13.11/fs/exec.c 2014-04-22 19:49:33.000000000 -0400 --- linux-3.13.11-acct/fs/exec.c 2014-09-25 18:06:02.418172384 -0400 *************** *** 1444,1447 **** --- 1444,1448 ---- } + void acct_process_exec(void); /* * sys_execve() executes a new program. *************** *** 1542,1545 **** --- 1543,1547 ---- task_numa_free(current); free_bprm(bprm); + acct_process_exec(); if (displaced) put_files_struct(displaced); diff -rc2P linux-3.13.11/include/uapi/linux/acct.h linux-3.13.11-acct/include/uapi/linux/acct.h *** linux-3.13.11/include/uapi/linux/acct.h 2014-04-22 19:49:33.000000000 -0400 --- linux-3.13.11-acct/include/uapi/linux/acct.h 2014-09-25 17:43:47.582070411 -0400 *************** *** 107,110 **** --- 107,112 ---- #define ACORE 0x08 /* ... dumped core */ #define AXSIG 0x10 /* ... was killed by a signal */ + #define ANPROC 0x20 /* ... This is an entry for a new process */ + #define AEXEC 0x40 /* ... This is an entry when the process exec */ #if defined(__BYTE_ORDER) ? __BYTE_ORDER == __BIG_ENDIAN : defined(__BIG_ENDIAN) diff -rc2P linux-3.13.11/kernel/acct.c linux-3.13.11-acct/kernel/acct.c *** linux-3.13.11/kernel/acct.c 2014-04-22 19:49:33.000000000 -0400 --- linux-3.13.11-acct/kernel/acct.c 2014-09-25 17:47:54.226731436 -0400 *************** *** 77,81 **** */ static void do_acct_process(struct bsd_acct_struct *acct, ! struct pid_namespace *ns, struct file *); /* --- 77,81 ---- */ static void do_acct_process(struct bsd_acct_struct *acct, ! struct pid_namespace *ns, struct file *, struct task_struct *, unsigned); /* *************** *** 188,192 **** mnt_unpin(old_acct->f_path.mnt); spin_unlock(&acct_lock); ! do_acct_process(acct, old_ns, old_acct); filp_close(old_acct, NULL); spin_lock(&acct_lock); --- 188,192 ---- mnt_unpin(old_acct->f_path.mnt); spin_unlock(&acct_lock); ! do_acct_process(acct, old_ns, old_acct,current,0); filp_close(old_acct, NULL); spin_lock(&acct_lock); *************** *** 453,459 **** */ static void do_acct_process(struct bsd_acct_struct *acct, ! struct pid_namespace *ns, struct file *file) { ! struct pacct_struct *pacct = ¤t->signal->pacct; acct_t ac; mm_segment_t fs; --- 453,459 ---- */ static void do_acct_process(struct bsd_acct_struct *acct, ! struct pid_namespace *ns, struct file *file, struct task_struct *p, unsigned flag) { ! struct pacct_struct *pacct = &p->signal->pacct; acct_t ac; mm_segment_t fs; *************** *** 482,492 **** ac.ac_version = ACCT_VERSION | ACCT_BYTEORDER; ! strlcpy(ac.ac_comm, current->comm, sizeof(ac.ac_comm)); /* calculate run_time in nsec*/ do_posix_clock_monotonic_gettime(&uptime); run_time = (u64)uptime.tv_sec*NSEC_PER_SEC + uptime.tv_nsec; ! run_time -= (u64)current->group_leader->start_time.tv_sec * NSEC_PER_SEC ! + current->group_leader->start_time.tv_nsec; /* convert nsec -> AHZ */ elapsed = nsec_to_AHZ(run_time); --- 482,492 ---- ac.ac_version = ACCT_VERSION | ACCT_BYTEORDER; ! strlcpy(ac.ac_comm, p->comm, sizeof(ac.ac_comm)); /* calculate run_time in nsec*/ do_posix_clock_monotonic_gettime(&uptime); run_time = (u64)uptime.tv_sec*NSEC_PER_SEC + uptime.tv_nsec; ! run_time -= (u64)p->group_leader->start_time.tv_sec * NSEC_PER_SEC ! + p->group_leader->start_time.tv_nsec; /* convert nsec -> AHZ */ elapsed = nsec_to_AHZ(run_time); *************** *** 519,540 **** #endif #if ACCT_VERSION==3 ! ac.ac_pid = task_tgid_nr_ns(current, ns); rcu_read_lock(); ! ac.ac_ppid = task_tgid_nr_ns(rcu_dereference(current->real_parent), ns); rcu_read_unlock(); #endif ! spin_lock_irq(¤t->sighand->siglock); ! tty = current->signal->tty; /* Safe as we hold the siglock */ ac.ac_tty = tty ? old_encode_dev(tty_devnum(tty)) : 0; ac.ac_utime = encode_comp_t(jiffies_to_AHZ(cputime_to_jiffies(pacct->ac_utime))); ac.ac_stime = encode_comp_t(jiffies_to_AHZ(cputime_to_jiffies(pacct->ac_stime))); ! ac.ac_flag = pacct->ac_flag; ac.ac_mem = encode_comp_t(pacct->ac_mem); ac.ac_minflt = encode_comp_t(pacct->ac_minflt); ac.ac_majflt = encode_comp_t(pacct->ac_majflt); ac.ac_exitcode = pacct->ac_exitcode; ! spin_unlock_irq(¤t->sighand->siglock); ! ac.ac_io = encode_comp_t(0 /* current->io_usage */); /* %% */ ac.ac_rw = encode_comp_t(ac.ac_io / 1024); ac.ac_swaps = encode_comp_t(0); --- 519,540 ---- #endif #if ACCT_VERSION==3 ! ac.ac_pid = task_tgid_nr_ns(p, ns); rcu_read_lock(); ! ac.ac_ppid = task_tgid_nr_ns(rcu_dereference(p->real_parent), ns); rcu_read_unlock(); #endif ! spin_lock_irq(&p->sighand->siglock); ! tty = p->signal->tty; /* Safe as we hold the siglock */ ac.ac_tty = tty ? old_encode_dev(tty_devnum(tty)) : 0; ac.ac_utime = encode_comp_t(jiffies_to_AHZ(cputime_to_jiffies(pacct->ac_utime))); ac.ac_stime = encode_comp_t(jiffies_to_AHZ(cputime_to_jiffies(pacct->ac_stime))); ! ac.ac_flag = pacct->ac_flag|flag; ac.ac_mem = encode_comp_t(pacct->ac_mem); ac.ac_minflt = encode_comp_t(pacct->ac_minflt); ac.ac_majflt = encode_comp_t(pacct->ac_majflt); ac.ac_exitcode = pacct->ac_exitcode; ! spin_unlock_irq(&p->sighand->siglock); ! ac.ac_io = encode_comp_t(0 /* p->io_usage */); /* %% */ ac.ac_rw = encode_comp_t(ac.ac_io / 1024); ac.ac_swaps = encode_comp_t(0); *************** *** 555,563 **** * Accounting records are not subject to resource limits. */ ! flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur; ! current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY; file->f_op->write(file, (char *)&ac, sizeof(acct_t), &file->f_pos); ! current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim; set_fs(fs); file_end_write(file); --- 555,563 ---- * Accounting records are not subject to resource limits. */ ! flim = p->signal->rlim[RLIMIT_FSIZE].rlim_cur; ! p->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY; file->f_op->write(file, (char *)&ac, sizeof(acct_t), &file->f_pos); ! p->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim; set_fs(fs); file_end_write(file); *************** *** 610,614 **** } ! static void acct_process_in_ns(struct pid_namespace *ns) { struct file *file = NULL; --- 610,614 ---- } ! static void acct_process_in_ns(struct pid_namespace *ns, struct task_struct *p, unsigned flag) { struct file *file = NULL; *************** *** 631,635 **** spin_unlock(&acct_lock); ! do_acct_process(acct, ns, file); fput(file); } --- 631,635 ---- spin_unlock(&acct_lock); ! do_acct_process(acct, ns, file,p,flag); fput(file); } *************** *** 641,645 **** * handles process accounting for an exiting task */ ! void acct_process(void) { struct pid_namespace *ns; --- 641,645 ---- * handles process accounting for an exiting task */ ! static void acct_process_p(struct task_struct *p, unsigned flag) { struct pid_namespace *ns; *************** *** 650,654 **** * its parent. */ ! for (ns = task_active_pid_ns(current); ns != NULL; ns = ns->parent) ! acct_process_in_ns(ns); } --- 650,668 ---- * its parent. */ ! for (ns = task_active_pid_ns(p); ns != NULL; ns = ns->parent) ! acct_process_in_ns(ns,p,flag); ! } ! ! void acct_process(void) ! { ! acct_process_p (current,0); ! } ! ! void acct_process_new (struct task_struct *p) ! { ! acct_process_p (p,ANPROC); ! } ! void acct_process_exec (void) ! { ! acct_process_p (current,AEXEC); } diff -rc2P linux-3.13.11/kernel/fork.c linux-3.13.11-acct/kernel/fork.c *** linux-3.13.11/kernel/fork.c 2014-10-01 15:53:27.222597728 -0400 --- linux-3.13.11-acct/kernel/fork.c 2014-09-25 17:57:06.606184520 -0400 *************** *** 1585,1589 **** return task; } ! /* * Ok, this is the main fork-routine. --- 1585,1589 ---- return task; } ! void acct_process_new (struct task_struct *); /* * Ok, this is the main fork-routine. *************** *** 1642,1645 **** --- 1642,1646 ---- } + acct_process_new(p); wake_up_new_task(p);