home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.unix.sysv386:16298 comp.unix.sys5.r4:452
- Newsgroups: comp.unix.sysv386,comp.unix.sys5.r4
- Path: sparky!uunet!charon.amdahl.com!pacbell.com!sgiblab!darwin.sura.net!wupost!gumby!yale!yale.edu!think.com!ames!kronos.arc.nasa.gov!iscnvx!netcomsv!cichlid!aab
- From: aab@cichlid.com (Andy Burgess)
- Subject: mmap and segv, a better way. Was: Re: av386mon source posted to alt.sources
- Message-ID: <1992Nov6.181051.8438@cichlid.com>
- Organization: SIlma Inc.
- References: <1992Oct2.184624.4441@omega.ssw.de>
- Date: Fri, 6 Nov 1992 18:10:51 GMT
- Lines: 28
-
- In <1992Oct2.184624.4441@omega.ssw.de> av@omega.ssw.de (Andreas Vogel) writes:
-
- >I've done some investigations about accessing kernel memory without
- >using the lseek() and read() system calls. This could be done with
- >the mmap() system call. The main point is, that the kernel pages will
- >be mapped in user address space on demand. If the user accesses a kernel
- >page, which is currently not mapped in user space, a SIGSEGV signal is
- >send by the kernel. A signal handler routine handles this signal by
- >mapping the kernel page holding the requested address and maps it
- >to user space. Afterwards the instruction which initiated the SIGSEGV
- >is restarted by a call to longjmp(). So before addressing a kernel
- >address a call to setjmp() must be done.
-
- An even cleaner way works on SunOS. You may want to check if sysvr4
- supports this. In the signal handler if you simply return the
- OS retrys the faulting instruction. Thus no longjmp/setjmp is necessary,
- any access violation can be trapped, the memory permission 'fixed'
- via mmap, any you continue on your merry way...
-
- Oh yes, the exact details of what address was accessed, program counter, etc
- is supplied to the signal handler (3rd argument is pointer to a struct that
- contains this info, as I recall).
-
- Andy
- --
- ==============================================================================
- Andrew A. Burgess aab@cichlid.com voice (408) 335 4779
- ==============================================================================
-