lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20170104232918.25598-1-richard@nod.at>
Date:   Thu,  5 Jan 2017 00:29:18 +0100
From:   Richard Weinberger <richard@....at>
To:     linux-kernel@...r.kernel.org
Cc:     akpm@...ux-foundation.org, mhocko@...e.com, vbabka@...e.cz,
        kirill.shutemov@...ux.intel.com, jmarchan@...hat.com,
        gerald.schaefer@...ibm.com, hannes@...xchg.org, luto@...nel.org,
        Richard Weinberger <richard@....at>
Subject: [PATCH] proc: Fix integer overflow of VmLib

/proc/<pid>/status can report extremely high VmLib values which
will confuse monitoring tools.
VmLib is mm->exec_vm minus text size, where exec_vm is the number of
bytes backed by an executable memory mapping and text size is
mm->end_code - mm->start_code as set up by binfmt.

For the vast majority of all programs text size is smaller than exec_vm.
But if a program interprets binaries on its own the calculation result
can be negative.
UserModeLinux is such an example. It installs and removes lots of PROT_EXEC
mappings but mm->start_code and mm->start_code remain and VmLib turns
negative.

Fix this by detecting the overflow and just return 0.
For interpreting the value reported by VmLib is anyway useless but
returning 0 does at least not confuse userspace.

Signed-off-by: Richard Weinberger <richard@....at>
---
 fs/proc/task_mmu.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 8f96a49178d0..220091c29aa6 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -46,6 +46,8 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
 
 	text = (PAGE_ALIGN(mm->end_code) - (mm->start_code & PAGE_MASK)) >> 10;
 	lib = (mm->exec_vm << (PAGE_SHIFT-10)) - text;
+	if ((long)lib < 0)
+		lib = 0;
 	swap = get_mm_counter(mm, MM_SWAPENTS);
 	ptes = PTRS_PER_PTE * sizeof(pte_t) * atomic_long_read(&mm->nr_ptes);
 	pmds = PTRS_PER_PMD * sizeof(pmd_t) * mm_nr_pmds(mm);
-- 
2.10.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ