Return to BSD News archive
Newsgroups: comp.os.386bsd.bugs Path: sserve!newshost.anu.edu.au!munnari.oz.au!news.Hawaii.Edu!ames!agate!doc.ic.ac.uk!uknet!pavo.csi.cam.ac.uk!camcus!pc123 From: pc123@cus.cam.ac.uk (Pete Chown) Subject: Bug in mmap()? (and fix) Message-ID: <PC123.93May7010930@bootes.cus.cam.ac.uk> Sender: news@infodev.cam.ac.uk (USENET news) Nntp-Posting-Host: bootes.cus.cam.ac.uk Organization: U of Cambridge, England Date: Fri, 7 May 1993 00:09:38 GMT Lines: 44 I have found what I think must be a bug in the mmap() code. The idea of mmap(), in case you don't know, is that you can map files into virtual memory; you have a choice of three styles of operation: 1. Map the file in, and write any changes made back to disc. 2. Map the file in, but discard any changes made. 3. Copy the whole file before doing anything. For the first of these, you need write access to the file, but for 2 and 3 you only need read access. Unfortunately you are currently refused permission for all of them unless you have write access. The following diff corrects this behaviour, and should be applied to /sys/vm/vm_mmap.c. This may sound obscure, but unfortunately this call is sure to be used by whoever ends up doing the shared libraries. I'm afraid I don't know who is handling the patchkit now, but perhaps they would like to have to a look at this diff and add it to the kit if it looks alright. That way, the fix should have worked into everyone's systems before anyone is trying to distribute a shared library package. 201,205c201,209 < maxprot = VM_PROT_EXECUTE; < if (fp->f_flag & FREAD) < maxprot |= VM_PROT_READ; < if (fp->f_flag & FWRITE) < maxprot |= VM_PROT_WRITE; --- > if(flags & MAP_SHARED) { > maxprot = VM_PROT_EXECUTE; > if (fp->f_flag & FREAD) > maxprot |= VM_PROT_READ; > if (fp->f_flag & FWRITE) > maxprot |= VM_PROT_WRITE; > } else { > maxprot = VM_PROT_ALL; > } -- ---------------------------------------------+ "A tight hat can be stretched. Pete Chown, pc123@phx.cam.ac.uk (Internet) | First damp the head with steam pc123@uk.ac.cam.phx (Janet :-) -+ from a boiling kettle."