[Bug 265937] linprocfs: process size incorrect

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 19 Aug 2022 09:18:55 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=265937

            Bug ID: 265937
           Summary: linprocfs: process size incorrect
           Product: Base System
           Version: 12.3-RELEASE
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: ray@bellis.me.uk

On our FreeBSD 12.3 systems, I've detected that the process size
column in a `linprocfs` process status file (`<pid>/stat`) derived
from the `ki_size` structure is reading four times higher than it
should be, compared to values returned by e.g. `ps` and `top`.

The reason appears to be the use of the P2K macro in this line:

sys/compat/linprocfs/linprocfs.c:1019
```C
PS_ADD("vsize",         "%ju",  P2K((uintmax_t)kp.ki_size));
```

https://github.com/freebsd/freebsd-src/blob/c8e7070ce3d98c3aa0b08249afe1d6d887f37f31/sys/compat/linprocfs/linprocfs.c#L1019

ki_size is calculated elsewhere from vm_map.size, but I could find
nothing to say explicitly whether .size is counted in pages or kB.

The issue is still present in the 14.x source.

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