Unix/Linux Go Back    


BSD BSD, sometimes called Berkeley Unix, is a Unix operating system developed by the Computer Systems Research Group of the UC Berkeley.

Mmap source

BSD


Tags
kernel, malloc, mmap, openbsd, security

Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 09-30-2013
dcicc dcicc is offline
Registered User
 
Join Date: Sep 2013
Last Activity: 4 October 2013, 11:47 AM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Mmap source

I'm new to kernels and C, and I am tinkering around trying to understand OpenBSD's secure memory management. I'm stumped on a couple points.

I've read up on malloc() which was apparently modified years ago to allocate memory using mmap. First question, that would be this here, right?


Code:
map_pages(size_t pages)
{
struct pdinfo *pi, *spi;
struct pginfo **pd;
u_long pidx,lidx;
void *result, *tail;
u_long index;

pages <<=malloc_pageshift;
result = MMAP(pages + malloc_guard);

For the life of me, I can't track down source code for mmap(). I know that this is a kernel system call, but where is that source? In particular, I'm interested to see how mmap() now returns a randomized location in memory.

Last edited by Scott; 09-30-2013 at 04:26 PM.. Reason: Code tags
Sponsored Links
    #2  
Old Unix and Linux 10-02-2013
dcicc dcicc is offline
Registered User
 
Join Date: Sep 2013
Last Activity: 4 October 2013, 11:47 AM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
mmap

I'll simplify my question. Can anyone direct me to the mmap code in the kernel?

Thanks.
Sponsored Links
    #3  
Old Unix and Linux 10-02-2013
blackrageous's Unix or Linux Image
blackrageous blackrageous is offline
Registered User
 
Join Date: Jul 2013
Last Activity: 27 March 2017, 2:57 PM EDT
Location: Austin, Texas
Posts: 540
Thanks: 13
Thanked 111 Times in 108 Posts
I am not familiar with the source tree for openBSD however that MMAP call may be a macro. If you've downloaded the source tree for openbsd maye there is a macro sub-directory or you can use the hammer approach and do something like

Code:
find <directory-where-src-is> -xdev -exec egrep -l MMAP {} \;

    #4  
Old Unix and Linux 10-02-2013
alister alister is offline
Registered User
 
Join Date: Dec 2009
Last Activity: 11 June 2014, 8:40 PM EDT
Posts: 3,231
Thanks: 179
Thanked 976 Times in 790 Posts
Quote:
Originally Posted by dcicc View Post
Can anyone direct me to the mmap code in the kernel?
The mmap kernel syscall implementation is in src/sys/uvm/uvm_mmap.c and the mmap syscall libc wrapper is in src/lib/libc/sys/mmap.c

Regards,
Alister

Last edited by alister; 10-02-2013 at 02:40 PM..
Sponsored Links
    #5  
Old Unix and Linux 10-04-2013
dcicc dcicc is offline
Registered User
 
Join Date: Sep 2013
Last Activity: 4 October 2013, 11:47 AM EDT
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks!

Thanks for the help. Just what I needed.
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
mmap xerox Emergency UNIX and Linux Support 2 10-24-2011 10:58 PM
mmap andrew.paul Programming 5 01-20-2011 10:22 AM
mmap gokult Homework & Coursework Questions 1 12-09-2010 03:33 AM
mmap() gokult Programming 5 12-08-2010 11:55 AM
mmap gusm Filesystems, Disks and Memory 0 07-30-2002 05:42 PM



All times are GMT -4. The time now is 12:17 AM.