Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754528AbcLaCCh (ORCPT ); Fri, 30 Dec 2016 21:02:37 -0500 Received: from mail-vk0-f52.google.com ([209.85.213.52]:36620 "EHLO mail-vk0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754091AbcLaCCg (ORCPT ); Fri, 30 Dec 2016 21:02:36 -0500 MIME-Version: 1.0 In-Reply-To: <20161230155634.8692-5-dsafonov@virtuozzo.com> References: <20161230155634.8692-1-dsafonov@virtuozzo.com> <20161230155634.8692-5-dsafonov@virtuozzo.com> From: Andy Lutomirski Date: Fri, 30 Dec 2016 18:02:15 -0800 Message-ID: Subject: Re: [RFC 4/4] x86/arch_prctl: add ARCH_{GET,SET}_TASK_SIZE To: Dmitry Safonov Cc: "linux-kernel@vger.kernel.org" , Dmitry Safonov <0x7f454c46@gmail.com>, Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Andy Lutomirski , "Kirill A. Shutemov" , X86 ML Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1123 Lines: 19 On Fri, Dec 30, 2016 at 7:56 AM, Dmitry Safonov wrote: > Add arch_prctl getters/setters for size of virtual address space of task. > This adds ability to change task's virtual address space limit. > I need this for correctly restore virtual address space limits in CRIU. > Currently, on x86 there are three task sizes: 3GB for some old 32 bit java > apps, 4Gb for ordinary 32-bit compatible apps and 47-bits for native > x86_64 processes. > 32-bit applications are restored by CRIU with the help of 64-bit clone()-d > child, and on restore we need to place correct address space limitations > back - otherwise 32-bit restored application may mmap() address over > 4Gb space and as this address will not fit into 4-byte pointer, it > will silently reuse/corrupt the pointer that has the same lower 4-bytes. > I agree we need something like this, but this particular justification is a bit bogus. If 32-bit mmap() returns an address above 2^32, then I think it's a straight-up bug. The address space limit shouldn't have anything to do with it -- the kernel *knows* that it's a "compat" syscall.