From fca843606462f0e5d2d5d59cd2de025b1a819a58 Mon Sep 17 00:00:00 2001 From: Harumi Kuno Date: Tue, 30 Jul 2019 06:32:27 -0700 Subject: [PATCH] Fix mmap infinite recurse in memory patcher This commit fixes issue #6853 by removing MacOS/Darwin-specific logic from intercept_mmap. It also opportunistically converts tabs to spaces. Signed-off-by: Harumi Kuno --- opal/mca/memory/patcher/configure.m4 | 12 +++++++----- opal/mca/memory/patcher/memory_patcher_component.c | 5 ----- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/opal/mca/memory/patcher/configure.m4 b/opal/mca/memory/patcher/configure.m4 index b80f8f3c69..579c480fb0 100644 --- a/opal/mca/memory/patcher/configure.m4 +++ b/opal/mca/memory/patcher/configure.m4 @@ -47,13 +47,15 @@ AC_DEFUN([MCA_opal_memory_patcher_CONFIG],[ esac AC_MSG_RESULT([$opal_memory_patcher_happy]) + # syscall interface causes compiler warnings. + # Per the above logic, memory patcher no longer supports MacOS/Darwin, + # so we no longer support Darwin-specific logic for intercept_mmap. + # See issue #6853: mmap infinite recurse in opal/mca/memory/patcher AS_IF([test "$opal_memory_patcher_happy" == "yes"], [ AC_CHECK_FUNCS([__curbrk]) - AC_CHECK_HEADERS([linux/mman.h sys/syscall.h]) - AC_CHECK_DECLS([__mmap], [], [], [#include ]) - AC_CHECK_FUNCS([__mmap]) - AC_CHECK_DECLS([__syscall], [], [], [#include ]) - AC_CHECK_FUNCS([__syscall]) + AC_CHECK_HEADERS([linux/mman.h sys/syscall.h]) + AC_CHECK_DECLS([__syscall], [], [], [#include ]) + AC_CHECK_FUNCS([__syscall]) $1], [$2]) AC_CONFIG_FILES([opal/mca/memory/patcher/Makefile]) diff --git a/opal/mca/memory/patcher/memory_patcher_component.c b/opal/mca/memory/patcher/memory_patcher_component.c index 5db3a6016f..687d430fa3 100644 --- a/opal/mca/memory/patcher/memory_patcher_component.c +++ b/opal/mca/memory/patcher/memory_patcher_component.c @@ -125,12 +125,7 @@ static void *_intercept_mmap(void *start, size_t length, int prot, int flags, in } if (!original_mmap) { -#ifdef HAVE___MMAP - /* the darwin syscall returns an int not a long so call the underlying __mmap function */ - result = __mmap (start, length, prot, flags, fd, offset); -#else result = (void*)(intptr_t) memory_patcher_syscall(SYS_mmap, start, length, prot, flags, fd, offset); -#endif } else { result = original_mmap (start, length, prot, flags, fd, offset); }