Package: procps
Version: 2:3.3.9-9
Severity: normal
File: /usr/bin/pmap
Tags: patch

Dear Maintainer,

# pmap -x `pidof X` Address   Kbytes     RSS   Dirty Mode  Mapping
[...]
338f6000 4293918720       0       0 -----   [ anon ]
[...]
# grep -A1 ^338f6000 /proc/`pidof X`/smaps
338f6000-f38f6000 ---p 00000000 00:00 0
Size:            3145728 kB

So, this map size is 3GiB, but it reported as 4TiB.

This error is is due to arithmetic right shift on signed integer type
for pmap.c:one_proc() variable:
...
        KLONG diff = 0;
...
                diff = end - start;
...
               [...], (unsigned long)(diff >> 10),

smaps file and trivial patch attached.

Fixed output (correct):
[...]
338f6000 3145728       0       0 -----   [ anon ]
[...]

-- System Information:
Debian Release: 8.1
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: i386 (x86_64)

Kernel: Linux 3.16.0-4-amd64 (SMP w/2 CPU cores)
Locale: LANG=ru_RU.KOI8-R, LC_CTYPE=ru_RU.KOI8-R (charmap=KOI8-R)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages procps depends on:
ii  initscripts   2.88dsf-59
ii  libc6         2.19-18
ii  libncurses5   5.9+20140913-1+b1
ii  libncursesw5  5.9+20140913-1+b1
ii  libprocps3    2:3.3.9-9
ii  libtinfo5     5.9+20140913-1+b1
ii  lsb-base      4.1+Debian13+nmu1

Versions of packages procps recommends:
ii  psmisc  22.21-2

procps suggests no packages.

-- no debconf information

Attachment: Xorg-smaps.txt.gz
Description: application/gzip

From: Yuriy M. Kaminskiy <yumkam+deb...@gmail.com>
Subject: [pmap] fix integer overflow on 2GiB+ maps on 32-bit platforms

Index: procps-3.3.9/pmap.c
===================================================================
--- procps-3.3.9.orig/pmap.c
+++ procps-3.3.9/pmap.c
@@ -517,7 +517,7 @@ static int one_proc(proc_t * p)
 	unsigned long total_shared = 0ul;
 	unsigned long total_private_readonly = 0ul;
 	unsigned long total_private_writeable = 0ul;
-	KLONG diff = 0;
+	unsigned KLONG diff = 0;
 	const char *cp2 = NULL;
 	unsigned long long rss = 0ull;
 	unsigned long long private_dirty = 0ull;

Reply via email to