From owner-freebsd-hackers Tue Feb 16 19: 8:37 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from iquest3.iquest.net (iquest3.iquest.net [209.43.20.203]) by hub.freebsd.org (Postfix) with SMTP id 4E26C10E6F for ; Tue, 16 Feb 1999 19:07:39 -0800 (PST) (envelope-from toor@y.dyson.net) Received: (qmail 17051 invoked from network); 17 Feb 1999 03:07:36 -0000 Received: from dyson.iquest.net (HELO y.dyson.net) (198.70.144.127) by iquest3.iquest.net with SMTP; 17 Feb 1999 03:07:36 -0000 Received: (from root@localhost) by y.dyson.net (8.9.1/8.9.1) id WAA27574; Tue, 16 Feb 1999 22:07:35 -0500 (EST) Message-Id: <199902170307.WAA27574@y.dyson.net> Subject: Re: vm_page_zero_fill In-Reply-To: <199902170218.TAA16616@usr08.primenet.com> from Terry Lambert at "Feb 17, 99 02:18:22 am" To: tlambert@primenet.com (Terry Lambert) Date: Tue, 16 Feb 1999 22:07:35 -0500 (EST) Cc: dyson@iquest.net, tlambert@primenet.com, toasty@home.dragondata.com, mike@smith.net.au, hackers@FreeBSD.ORG From: "John S. Dyson" Reply-To: dyson@iquest.net X-Mailer: ELM [version 2.4ME+ PL38 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Terry Lambert said: > > > Expecting sbrk'ed pages to be zero filled is just *wrong*. > > > > Actually, you have to support that on most practical architectures. > > [ ... ] > > > malloc and calloc are different. Memory is often recycled in the > > address space when using malloc. sbrk is a security violation if > > the pages aren't prezeroed (or defined to be something other than > > data in other processes or freed data from the kernel :-)). > > Well, the intended application doesn't care about security, so it > should be possible to turn it off. 8-). > > The thing that appalled me was what you said about BSS being zero'ed > in the kernel space using zeroed pages instead of as a result of an > explicit zeroing by the execution class loader. > That is the way that it works. Explict zeroing is wasteful because it cannot easily take advantage of background prezeroing... However, recently prezeroed pages make for efficient usage of cache. The zero queue (and all others) are designed to take advantage of recent cache usage. > > On second thought, though, are the BSS pages zeroed because they > are backed by zero-fill pages, rather than grabbed in user space > via sbrk? That's less apalling. You could conditionalize that > code. > They are backed by zero-fill pages. Processes don't do the zeroing themselves because of security reasons (in current kernels.) The execution class loaders sometimes have to do explict zeroes due to broken non-aligned binary formats. The kernel has efficient mechanisms for providing zeroed pages, but I guess that there are times that even efficiently zeroing pages isn't fast enough. > > I think the compile option he wants to add is "VM_FG_ZERO_PAGES" > or something similar, that indicates the subsystem effected and > the effect, and then "VM_DIRTY_PAGES_OK". > > In other words, I'd seperate turning off the background zeroing and > the default-mandatory nature of pages zeroed for security rather > than functional purposes. > Well, that is an application issue (how you would want to implement it from an enable/disable standpoint.) All I am saying is that implementing the details of how it works is easy -- perhaps not obvious to a non-kernel hacker though. The kind of thing being asked for requires only an addition of a simple flag to a map entry, and the appropriate modification of how fault works when that flag is set. > > Another place that would have to be conditionalized, besides the > /dev/zero and BSS issues, would be backing store for file pages > allocated on a file extend. I know a number of programs that > rely on the POSIX sideways promise that "holes contain zeros" > (it's OK to break security, but not semantics). > Those pages should be zeroed anyway in any case. In the same way that bss almost has to be pre-zeroed (for reasonable behavior of standard C programs), proper zeroing of file contents is likely necessary to keep programmers from going nutty. -- John | Never try to teach a pig to sing, dyson@iquest.net | it makes one look stupid jdyson@nc.com | and it irritates the pig. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message