Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1551923
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] proc: Fix integer overflow of VmLib |
| Date | 2017-01-05 13:00 +0100 |
| Message-ID | <sWeS5-2ug-5@gated-at.bofh.it> (permalink) |
| References | <sW3jX-37n-5@gated-at.bofh.it> <sWdW2-1Sf-23@gated-at.bofh.it> <sWe5H-2bf-27@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Thu 05-01-17 12:03:47, Richard Weinberger wrote: > Michal, > > Am 05.01.2017 um 11:53 schrieb Michal Hocko: > > I guess you meant s@overflow@underflow@ right? > > Yep, of course. > > > On Thu 05-01-17 00:29:18, 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. > > > > Is really 0 what the userspace expects? Why shouldn't we just report > > exec_vm unconditionally? Btw. we used to do something that many years > > back https://lkml.org/lkml/2004/8/24/47. We are exporting the text size > > so the calculation can be done by the userspace. > > Strictly speaking both values, 0 and exec_vm are wrong. > Userspace expects VmLib to be 0 when an application has no libs loaded, > i.e. for statically linked binaries. > > So, either we report 0 as "I don't know" or exec_vm, which is also wrong. Yes unfortunately. > I thought 0 is the better choice since it will not lead to wrong results > when userspace tools compute the sum of values reported by /proc/<pid>/status. Dunno. If somebody translates 0 to statically linked library then it could be wrong. That being said, the underflow is _clearly_ wrong. I am not sure what the right way is to fix this but whatever we do it might just break somebody's usecase. Sad... -- Michal Hocko SUSE Labs
Back to linux.kernel | Previous | Next — Previous in thread | Next 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