lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Date:	Tue, 14 Jun 2011 06:17:13 +0900
From:	Jongman Heo <jongman.heo@...il.com>
To:	linux-kernel@...r.kernel.org
Subject: Question regarding mmap() with MAP_FIXED flag

Dear all,

Please let me ask a dumb question.

I use following mmap call, to get the same virtual address with given
physical address.
And when reading the mmap-ed memory, it seems that the virtual address
correctly points to the physical address.

  ptr = mmap((void*)0x400000, getpagesize(), PROT_READ, MAP_PRIVATE |
MAP_FIXED , mem_fd, 0x400000);

  where mem_fd is the file descriptor of /dev/mem.

And using memmap boot arguments, 4M RAM location is not used by Linux.
The area is written by bootloader. (.. memmap=exactmap memmap=64k@0
memmap=3M@1M memmap=1019M@5M)


It works, but I'm afraid that the possiblity of mmap() failure with
MAP_FIXED flag.
man page of mmap states following:

   MAP_FIXED  Do not select a different address than the one
specified.  If the memory  region  speci-
                  fied  by  start  and  len overlaps pages of any
existing mapping(s), then the overlapped
                  part of the existing mapping(s) will be discarded.
If the specified address  cannot  be
                  used, mmap() will fail.  If MAP_FIXED is specified,
start must be a multiple of the page
                  size.  Use of this option is discouraged.


Q1. What does the existing mapping mean?
Another mmap mapping by any other user space process? Or it means that
the virtual address (0x400000 in my case) is already acquired/used by
others (kernel, process, or whatever)?

Q2. When can't the specified address be used?

Q3. Is there any solution such that mmap with MAP_FIXED being not
failed but always succeed?


Thanks in advance,
Jongman Heo.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ