From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755419AbdKOOST (ORCPT ); Wed, 15 Nov 2017 09:18:19 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:41765 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752523AbdKOOSL (ORCPT ); Wed, 15 Nov 2017 09:18:11 -0500 Date: Wed, 15 Nov 2017 15:18:02 +0100 (CET) From: Thomas Gleixner To: "Kirill A. Shutemov" cc: "Kirill A. Shutemov" , Ingo Molnar , x86@kernel.org, "H. Peter Anvin" , Linus Torvalds , Andy Lutomirski , Nicholas Piggin , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCHv2 1/2] x86/mm: Do not allow non-MAP_FIXED mapping across DEFAULT_MAP_WINDOW border In-Reply-To: <20171115121042.dt2us5fsuqmepx4i@node.shutemov.name> Message-ID: References: <20171114134322.40321-1-kirill.shutemov@linux.intel.com> <20171114202102.crpgiwgv2lu5aboq@node.shutemov.name> <20171114222718.76w4lmclf6wasbl3@node.shutemov.name> <20171115112702.e2m66wons37imtcj@node.shutemov.name> <20171115121042.dt2us5fsuqmepx4i@node.shutemov.name> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 15 Nov 2017, Kirill A. Shutemov wrote: > On Wed, Nov 15, 2017 at 12:39:40PM +0100, Thomas Gleixner wrote: > > > I *think* we should be fine with checking unaligned 'addr'. > > > > I think we should keep it consistent for the normal and the huge case and > > just check aligned and be done with it. > > Aligned 'addr'? Or 'len'? Both? > > We would have problem with checking aligned addr. I steped it in hugetlb > case: > > - User asks for mmap((1UL << 47) - PAGE_SIZE, 2 << 20, MAP_HUGETLB); > > - On 4-level paging machine this gives us invalid hint address as > 'TASK_SIZE - len' is more than 'addr'. Goto get_unmapped_area. > > - On 5-level paging machine hint address gets rounded up to next 2MB > boundary that is exactly 1UL << 47 and we happily allocate from full > address space which may lead to trouble. Ah, right because that ALIGN is using huge_page_size(h) and not PAGE_SIZE.