kernel vm question

Jacques Fourie jacques.fourie at gmail.com
Thu Jan 27 23:54:51 PST 2005


Thanks for the reply - I really appreciate it. I have tried to change
the protection on the page in a way similar to mprotect() but no luck.
I have had a look at what ddb does when modifying kernel code and
after applying the same ideas to my code everything works without a
problem.

The funny thing is that the original code (a mechanism we use to
'intercept' certain network functions in the kernel in order to do
extra processing such as IPsec) was working on FreeBSD 4.8 on all the
hardware that I tested with. Only after I ported the software to
FreeBSD 4.9 I began seeing this issue and then only on 2 specific
hardware configurations.
Now that I have a working solution it is not that important to me but
I would still like to understand why this does not fail 100% of the
time if the kernel code pages are not writeable by default.

Thanks again for all the replies I have received so far.

regards,
jacques



On Thu, 27 Jan 2005 14:26:29 -0500, Brian Fundakowski Feldman
<green at freebsd.org> wrote:
> On Thu, Jan 27, 2005 at 06:48:56PM +0200, Jacques Fourie wrote:
> > Hi,
> >
> > Yes, I am trying to patch a piece of code in the kernel. The strange
> > thing is that this code works without a problem on FreeBSD 4.8 - has
> > the VM system changed to such an extent between 4.8 and 4.9 that the
> > pages in the kernel code segment are not writeable anymore?
> >
> > Thanks for the bit about the compiler optimization - at least I
> > understand that part now :)
> 
> They should have never been writable.  You should be able to change that
> protection on the page temporarily though to achieve the effect you want;
> take a look at e.g. mprotect(), you should be able to do much the same
> thing with kernel_map instead.
> 
> --
> Brian Fundakowski Feldman                           \'[ FreeBSD ]''''''''''\
>   <> green at FreeBSD.org                               \  The Power to Serve! \
>  Opinions expressed are my own.                       \,,,,,,,,,,,,,,,,,,,,,,\
>


More information about the freebsd-hackers mailing list