0
 void *mmap(void *addr, size_t length, int prot, int flags,int fd, off_t offset);

I see call to mmap that prot=3 and flags=1 what does it mean about this buffer? ,How can I translate the flag that I see in man to number?

Is the user can read/write or read+write to this buffer?

parser1234
  • 111
  • 1
  • 7
  • 2
    http://man7.org/linux/man-pages/man2/mmap.2.html then go find in the source code what are the values of the macros (this is implementation specific). – Jazzwave06 May 11 '20 at 12:57
  • Which i found here: https://unix.superglobalmegacorp.com/Net2/newsrc/sys/mman.h.html – Jazzwave06 May 11 '20 at 12:59
  • If you decide to write programs above linux! You have to be tough enough to work with the terminal and type man on this function. you dont need any thing else! – Adam May 11 '20 at 13:12

1 Answers1

0

This kind of question in C can be asked in two steps. First you need to read the manual to find the macros/constants you're looking for. I usually search in google for syscall <system call> (e.g. syscall mmap). Then you have to find which header file defines them and the actual header file for your implementation.

For memory map:

The manual page can be found here: http://man7.org/linux/man-pages/man2/mmap.2.html

The header that defines the flags: https://unix.superglobalmegacorp.com/Net2/newsrc/sys/mman.h.html

Jazzwave06
  • 1,883
  • 1
  • 11
  • 19
  • So is that mean that user can write or exec code from this buffer but can't read from this buffer? PROT_WRITE(0x02) | PROT_EXEC(0x01) =3 – parser1234 May 11 '20 at 13:05
  • Yes this is most likely what it means. The `sys/mman.h` comes from BSD I think, but it should be the same implementation on linux. – Jazzwave06 May 11 '20 at 13:06