From owner-freebsd-hackers@FreeBSD.ORG Thu Nov 19 11:42:35 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 55494106568F; Thu, 19 Nov 2009 11:42:35 +0000 (UTC) (envelope-from rwatson@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id 2BBB98FC08; Thu, 19 Nov 2009 11:42:35 +0000 (UTC) Received: from [192.168.2.101] (host217-43-176-60.range217-43.btcentralplus.com [217.43.176.60]) by cyrus.watson.org (Postfix) with ESMTPSA id 0F44146B66; Thu, 19 Nov 2009 06:42:33 -0500 (EST) Mime-Version: 1.0 (Apple Message framework v1077) Content-Type: text/plain; charset=us-ascii From: "Robert N. M. Watson" In-Reply-To: <200911191627.34076.sharadc@in.niksun.com> Date: Thu, 19 Nov 2009 11:42:32 +0000 Content-Transfer-Encoding: quoted-printable Message-Id: <80FAFE47-C19C-4666-A279-6AF6DA8B6127@freebsd.org> References: <200911171529.20098.sharadc@in.niksun.com> <200911181433.52557.jkim@FreeBSD.org> <200911191627.34076.sharadc@in.niksun.com> To: Sharad Chandra X-Mailer: Apple Mail (2.1077) Cc: Kostik Belousov , freebsd-hackers@freebsd.org, Manprit Singh , Jung-uk Kim Subject: Re: mprotect(2) clears the flag for whole page which causes program crash. X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Nov 2009 11:42:35 -0000 On 19 Nov 2009, at 10:57, Sharad Chandra wrote: > Thanks everyone. mmap(2) worked and program did not crash. Only = problem with=20 > it I use only fraction of allocated memory (each request alocate = minimum of=20 > one page and my request is in hundreds), rest is waste of it so no one = else=20 > will get this memory to use. And if a process runs as daemon and makes = many=20 > request, It can hold a lot of it. Just a question floated in mind. One of the defining properties of pages is that they are the granularity = at which access protections are controlled in hardware, so your choices = are a minimum of one page per object, or having multiple objects that = share the same protection properties. However, it could be that you = could accomplish whatever your goals may be using techniques other than = paging; for example, using ptrace(2) to instrument individual accesses, = binary rewriting, a virtual machine, source code instrumentation, or = other methods along those lines that have been used for debugging and = security over the years. Robert=