Bug in VM pages protection handling.

Pawel Jakub Dawidek nick at garage.freebsd.pl
Sat Jul 12 14:27:29 PDT 2003


On Sat, Jul 12, 2003 at 03:57:18PM -0500, Alan L. Cox wrote:
+> > I've just send PR for this:
+> > 
+> >         http://www.freebsd.org/cgi/query-pr.cgi?pr=54418
+> > 
+> > I'll be greatful if somebody could review, commit and MFC it
+> > as soon as possible. I need to hold CerbNG next release until
+> > it will be fixed.
+> > 
+> 
+> As I've said in private e-mail, this is not a bug.  You're really asking
+> for a change in "specification".  Reductions in max_protection have had
+> permanent effect since the late 1980's.

You've also asked my in private mail why I need this, I'll answer here.

I need this to protect syscall arguments that I'm checking in CerbNG.
If I need to check an argument I've to be sure that kernel will check
exactly that same argument (here is ugly race).
So what I do is memory allocaton in process' vmspace, copy argument
there, mark newly allocated pages as read-only and call original
syscall with new pointer(s). Those pages are freed after that and
everything will be correct, but somebody has reported me about
'bus error'. I've track this problem for two days. It occurs for
majordomo, when perl is trying to execute something, nevermind.
Pages are marked as read-only for child process, but parent
process is killed with SIGBUS signal. I don't mees with this parent
process at all, but it looks they're sharing some memory or some
pages/map is mirrored (copy-on-write mechanism?) with VM_PROT_READ
protection.

Of course I could rewrite vm_map_protect() function locally and use my
version (I hate such hacks, but if there is no other way...), but for me
it is strange. Is there something that depends on this or proposed
patch breaks anything? Why specification says that?

Ok, I don't want to provoke specification breakage, I was just thinking
that this was a bug, so PR could be closed, sorry.

PS1. Maybe you (or anyone) have better solution for syscall arguments
     protecting to avoid this race?
PS2. Where could I find FreeBSD's VM specification? Or maybe I should
     look for posix VM spcification?

-- 
Pawel Jakub Dawidek                       pawel at dawidek.net
UNIX Systems Programmer/Administrator     http://garage.freebsd.pl
Am I Evil? Yes, I Am!                     http://cerber.sourceforge.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 305 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20030712/f98a992c/attachment.bin


More information about the freebsd-hackers mailing list