Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 10 Sep 1997 14:40:45 +1000
From:      Bruce Evans <bde@zeta.org.au>
To:        bde@zeta.org.au, jlemon@americantv.com
Cc:        emulation@FreeBSD.ORG, hfwirth@ping.at
Subject:   Re: Doscmd, debugging with gdb
Message-ID:  <199709100440.OAA10269@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help
>> >	> cat /proc/<pid>/map
>> >	[.. snip ..]
>> >	0x8012000  0x8014000          0         2 rwx COW vnode
>> >	0x8014000  0x801c000          0         8 rwx     default
>> >	[.. snip ..]
>> >	(gdb) set *0x8012000 = 0
>> >	(gdb) set *0x8014000 = 0
>> >	Error accessing memory address 0x8014000: Bad address.
>> 
>> `w' apparently means write-protected here :-).  All the r-x COW vnodes
>> are writable and all the rwx COW vnodes are non-writable.
>
>No, I don't think that's it; the write to the 'rwx COW vnode' entry
>succeeds, while the write to the 'rwx default' entry fails.  

Oops, I read from the wrong column in the map.

>Also, the 'default' region in doscmd was allocated via brk(), so I'd
>certainly hope that allocated memory isn't non-writeable.  :-)
>
>I neglected to mention that this was on a -current machine, BTW.

Even the stack is currently non-writable via ptrace :-).

Try this fix.

diff -c2 vm_map.c~ vm_map.c
*** vm_map.c~	Mon Sep  1 18:00:38 1997
--- vm_map.c	Wed Sep 10 14:02:48 1997
***************
*** 2288,2292 ****
  		(entry->eflags & MAP_ENTRY_COW) == 0 ||
  		(entry->wired_count != 0)) {
! 		if ((fault_type & (prot)) != fault_type)
  			RETURN(KERN_PROTECTION_FAILURE);
  	}
--- 2288,2293 ----
  		(entry->eflags & MAP_ENTRY_COW) == 0 ||
  		(entry->wired_count != 0)) {
! 		if ((fault_type & prot) !=
! 		    (fault_type & ~VM_PROT_OVERRIDE_WRITE))
  			RETURN(KERN_PROTECTION_FAILURE);
  	}

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199709100440.OAA10269>