From: Vlastimil Babka <vbabka@suse.cz>
To: Richard Weinberger <richard@nod.at>, linux-kernel@vger.kernel.org
Cc: akpm@linux-foundation.org, mhocko@suse.com,
kirill.shutemov@linux.intel.com, jmarchan@redhat.com,
gerald.schaefer@de.ibm.com, hannes@cmpxchg.org, luto@kernel.org
Subject: Re: [PATCH] proc: Fix integer overflow of VmLib
Date: Thu, 5 Jan 2017 09:38:15 +0100 [thread overview]
Message-ID: <648b31b0-1c87-6d3d-addd-bd1c0e5ea421@suse.cz> (raw)
In-Reply-To: <20170104232918.25598-1-richard@nod.at>
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.
>
> Signed-off-by: Richard Weinberger <richard@nod.at>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
> ---
> 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);
>
next prev parent reply other threads:[~2017-01-05 8:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-04 23:29 Richard Weinberger
2017-01-05 8:38 ` Vlastimil Babka [this message]
2017-01-05 10:53 ` Michal Hocko
2017-01-05 11:03 ` Richard Weinberger
2017-01-05 11:49 ` Michal Hocko
2017-01-05 13:20 ` Richard Weinberger
2017-01-05 13:49 ` Michal Hocko
2017-01-06 0:11 ` Richard Weinberger
2017-01-05 12:01 ` Jerome Marchand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=648b31b0-1c87-6d3d-addd-bd1c0e5ea421@suse.cz \
--to=vbabka@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=gerald.schaefer@de.ibm.com \
--cc=hannes@cmpxchg.org \
--cc=jmarchan@redhat.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mhocko@suse.com \
--cc=richard@nod.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®