Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1644332
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCHv5, REBASED 9/9] x86/mm: Allow to have userspace mappings above 47-bits |
| Date | 2017-05-18 13:50 +0200 |
| Message-ID | <tIs6m-1V1-35@gated-at.bofh.it> (permalink) |
| References | <tHn8J-87x-7@gated-at.bofh.it> <tHn8J-87x-21@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Mon 15-05-17 15:12:18, Kirill A. Shutemov wrote:
[...]
> @@ -195,6 +207,16 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
> info.length = len;
> info.low_limit = PAGE_SIZE;
> info.high_limit = get_mmap_base(0);
> +
> + /*
> + * If hint address is above DEFAULT_MAP_WINDOW, look for unmapped area
> + * in the full address space.
> + *
> + * !in_compat_syscall() check to avoid high addresses for x32.
> + */
> + if (addr > DEFAULT_MAP_WINDOW && !in_compat_syscall())
> + info.high_limit += TASK_SIZE_MAX - DEFAULT_MAP_WINDOW;
> +
> info.align_mask = 0;
> info.align_offset = pgoff << PAGE_SHIFT;
> if (filp) {
I have two questions/concerns here. The above assumes that any address above
1<<47 will use the _whole_ address space. Is this what we want? What
if somebody does mmap(1<<52, ...) because he wants to (ab)use 53+ bits
for some other purpose? Shouldn't we cap the high_limit by the given
address?
Another thing would be that
/* requesting a specific address */
if (addr) {
addr = PAGE_ALIGN(addr);
vma = find_vma(mm, addr);
if (TASK_SIZE - len >= addr &&
(!vma || addr + len <= vma->vm_start))
return addr;
}
would fail for mmap(-1UL, ...) which is good because we do want to
fallback to vm_unmapped_area and have randomized address which is
ensured by your info.high_limit += ... but that wouldn't work for
mmap(1<<N, ...) where N>47. So the first such mapping won't be
randomized while others will be. This is quite unexpected I would say.
So it should be documented at least or maybe we want to skip the above
shortcut for addr > DEFAULT_MAP_WINDOW altogether.
The patch looks sensible other than that.
--
Michal Hocko
SUSE Labs
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCHv5, REBASED 9/9] x86/mm: Allow to have userspace mappings above 47-bits "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2017-05-15 14:20 +0200
Re: [PATCHv5, REBASED 9/9] x86/mm: Allow to have userspace mappings above 47-bits "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2017-05-15 21:50 +0200
Re: [PATCHv5, REBASED 9/9] x86/mm: Allow to have userspace mappings above 47-bits Michal Hocko <mhocko@kernel.org> - 2017-05-18 13:50 +0200
Re: [PATCHv5, REBASED 9/9] x86/mm: Allow to have userspace mappings above 47-bits "Kirill A. Shutemov" <kirill@shutemov.name> - 2017-05-18 17:30 +0200
Re: [PATCHv5, REBASED 9/9] x86/mm: Allow to have userspace mappings above 47-bits Michal Hocko <mhocko@kernel.org> - 2017-05-18 17:30 +0200
Re: [PATCHv5, REBASED 9/9] x86/mm: Allow to have userspace mappings above 47-bits "Kirill A. Shutemov" <kirill@shutemov.name> - 2017-05-18 17:50 +0200
Re: [PATCHv5, REBASED 9/9] x86/mm: Allow to have userspace mappings above 47-bits Michal Hocko <mhocko@kernel.org> - 2017-05-18 18:00 +0200
Re: [PATCHv5, REBASED 9/9] x86/mm: Allow to have userspace mappings above 47-bits Michal Hocko <mhocko@kernel.org> - 2017-05-18 18:00 +0200
Re: [PATCHv5, REBASED 9/9] x86/mm: Allow to have userspace mappings above 47-bits "Kirill A. Shutemov" <kirill@shutemov.name> - 2017-05-18 18:40 +0200
Re: [PATCHv5, REBASED 9/9] x86/mm: Allow to have userspace mappings above 47-bits Michal Hocko <mhocko@kernel.org> - 2017-05-18 19:20 +0200
Re: [PATCHv5, REBASED 9/9] x86/mm: Allow to have userspace mappings above 47-bits Michal Hocko <mhocko@kernel.org> - 2017-05-18 20:00 +0200
csiph-web