Index: src/trusted/service_runtime/sys_memory.c |
diff --git a/src/trusted/service_runtime/sys_memory.c b/src/trusted/service_runtime/sys_memory.c |
index 7b0d7033d81a0b7192236b7dc312bb997d656b7a..d5bea0a916e4e17fc9b7399c5c86cf8f593998ea 100644 |
--- a/src/trusted/service_runtime/sys_memory.c |
+++ b/src/trusted/service_runtime/sys_memory.c |
@@ -329,9 +329,14 @@ int32_t NaClSysMmapIntern(struct NaClApp *nap, |
* granularity. (Windows.) |
*/ |
if (!NaClIsAllocPageMultiple(usraddr)) { |
- NaClLog(2, "NaClSysMmap: address not allocation granularity aligned\n"); |
- map_result = -NACL_ABI_EINVAL; |
- goto cleanup; |
+ if ((NACL_ABI_MAP_FIXED & flags) != 0) { |
+ NaClLog(2, "NaClSysMmap: address not allocation granularity aligned\n"); |
+ map_result = -NACL_ABI_EINVAL; |
+ goto cleanup; |
+ } else { |
+ NaClLog(2, "NaClSysMmap: Force alignment of misaligned hint address\n"); |
+ usraddr = NaClTruncAllocPage(usraddr); |
+ } |
} |
/* |
* Offset should be non-negative (nacl_abi_off_t is signed). This |