Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1551934
| From | Jerome Marchand <jmarchan@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] proc: Fix integer overflow of VmLib |
| Date | 2017-01-05 13:10 +0100 |
| Message-ID | <sWf1L-2MX-7@gated-at.bofh.it> (permalink) |
| References | <sW3jX-37n-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
[Multipart message — attachments visible in raw view] - view raw
On 01/05/2017 12:29 AM, Richard Weinberger wrote: > /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. I guess returning 0 in such case is good enough, but the description of VmLib in Documentations/filesystems/proc.txt should be updated to warn users not to rely too much on this value. Jerome > > Signed-off-by: Richard Weinberger <richard@nod.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); >
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH] proc: Fix integer overflow of VmLib Richard Weinberger <richard@nod.at> - 2017-01-05 00:40 +0100
Re: [PATCH] proc: Fix integer overflow of VmLib Vlastimil Babka <vbabka@suse.cz> - 2017-01-05 09:50 +0100
Re: [PATCH] proc: Fix integer overflow of VmLib Michal Hocko <mhocko@kernel.org> - 2017-01-05 12:00 +0100
Re: [PATCH] proc: Fix integer overflow of VmLib Richard Weinberger <richard@nod.at> - 2017-01-05 12:10 +0100
Re: [PATCH] proc: Fix integer overflow of VmLib Michal Hocko <mhocko@kernel.org> - 2017-01-05 13:00 +0100
Re: [PATCH] proc: Fix integer overflow of VmLib Richard Weinberger <richard@nod.at> - 2017-01-05 14:30 +0100
Re: [PATCH] proc: Fix integer overflow of VmLib Michal Hocko <mhocko@kernel.org> - 2017-01-05 14:50 +0100
Re: [PATCH] proc: Fix integer overflow of VmLib Richard Weinberger <richard@nod.at> - 2017-01-06 01:20 +0100
Re: [PATCH] proc: Fix integer overflow of VmLib Jerome Marchand <jmarchan@redhat.com> - 2017-01-05 13:10 +0100
csiph-web