Bug 478543 - per-thread accounting uses uninitialised data
per-thread accounting uses uninitialised data
Status: CLOSED WONTFIX
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: kernel (Show other bugs)
4.6
All Linux
low Severity medium
: rc
: ---
Assigned To: Jerome Marchand
Martin Jenner
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2008-12-31 13:19 EST by Martin Poole
Modified: 2010-10-23 02:46 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2010-02-24 09:58:42 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Martin Poole 2008-12-31 13:19:35 EST
Description of problem:

the process accounting code uses the current thread data to calculate run time, and eventually the start time (as now - elapsed to allow for time changes)

For anything other than the group leader the start_time is not correct.

Current code in kernel/acct.c has something like

        /* 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->start_time.tv_sec*NSEC_PER_SEC
                                        + current->start_time.tv_nsec;

later kernels change this to

        /* 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;
Comment 1 Oleg Nesterov 2009-01-12 22:03:51 EST
Well, the subject is not right, ->start_time is initialized
correctly for any thread.

Yes, later kernels use ->group_leader->start_time. But rhel4
can't do this because it does acct_process() per thread, not
per process. And this is just wrong.

The real fix should first change do_exit() to call acct_process()
only if group_dead is true, this change is obviously correct.
Unfortunately, this change is very much user visible, it can
confuse the current users of bsd accounting.
Comment 3 Jerome Marchand 2010-02-24 09:58:42 EST
Correcting this would imply a too big change in the userspace interface.

Note You need to log in before you can comment on or make changes to this bug.