libc: don't treat 'mmap()' address hint w/o MAP_FIXED flag as error

Fixes #3855
This commit is contained in:
Christian Prochaska 2020-08-20 16:54:54 +02:00 committed by Norman Feske
parent 2f55ffdf20
commit dd8777093d
2 changed files with 10 additions and 4 deletions

View File

@ -413,9 +413,15 @@ __SYS_(void *, mmap, (void *addr, ::size_t length,
int prot, int flags,
int libc_fd, ::off_t offset),
{
/* handle requests for anonymous memory */
if (!addr && libc_fd == -1) {
if ((flags & MAP_ANONYMOUS) || (flags & MAP_ANON)) {
if (flags & MAP_FIXED) {
Genode::error("mmap for fixed predefined address not supported yet");
errno = EINVAL;
return MAP_FAILED;
}
bool const executable = prot & PROT_EXEC;
void *start = mem_alloc(executable)->alloc(length, PAGE_SHIFT);
if (!start) {

View File

@ -1640,8 +1640,8 @@ void *Libc::Vfs_plugin::mmap(void *addr_in, ::size_t length, int prot, int flags
return (void *)-1;
}
if (addr_in != 0) {
error("mmap for predefined address not supported");
if (flags & MAP_FIXED) {
error("mmap for fixed predefined address not supported yet");
errno = EINVAL;
return (void *)-1;
}