[Bug 76972] [kernel] [patch] 64-bit integer overflow computing user cpu time in calcru() in kern_resource.c

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Sun Feb 10 20:58:15 UTC 2019


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=76972

Conrad Meyer <cem at freebsd.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|bugs at FreeBSD.org            |cem at freebsd.org
           Keywords|                            |patch, patch-ready
             Status|Open                        |In Progress
                 CC|                            |cem at freebsd.org

--- Comment #6 from Conrad Meyer <cem at freebsd.org> ---
I wrote a small program to empirically validate the proposed patch under some
assumptions.

"tu" (total time in microseconds) is drawn from [1, ~1000 years] (0 is
uninteresting).

"tt" (total time in ticks) is tu / 1000.

"ut" or "st" is <= tt.

With randomly drawn tu and ut/st in the given ranges (not precisely uniform due
to lack of arc4random_uniform64, but close to uniform distribution), I observe
overflow in something like 99.999976% of the input range with the current
algorithm and 0% (absolutely zero) instances of overflow with the proposed
patch.  Also, the result is correct, and not truncated, in all cases with the
bounds given above.

I believe it fixes the issue and can be committed.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list