ignore ENOSYS error from mprotect in pthread_create and dynamic linker
authorRich Felker <dalias@aerifal.cx>
Wed, 17 Jun 2015 17:21:46 +0000 (17:21 +0000)
committerRich Felker <dalias@aerifal.cx>
Wed, 17 Jun 2015 17:21:46 +0000 (17:21 +0000)
this error simply indicated a system without memory protection (NOMMU)
and should not cause failure in the caller.

src/ldso/dynlink.c
src/thread/pthread_create.c

index 71252d0327cbb76c027f1e13feb988fe92773f6e..7e566933d6ad97b83daf25a12fafecc9d0629247 100644 (file)
@@ -536,7 +536,8 @@ static void *map_library(int fd, struct dso *dso)
        }
        for (i=0; ((size_t *)(base+dyn))[i]; i+=2)
                if (((size_t *)(base+dyn))[i]==DT_TEXTREL) {
-                       if (mprotect(map, map_len, PROT_READ|PROT_WRITE|PROT_EXEC) < 0)
+                       if (mprotect(map, map_len, PROT_READ|PROT_WRITE|PROT_EXEC)
+                           && errno != ENOSYS)
                                goto error;
                        break;
                }
@@ -927,7 +928,8 @@ static void reloc_all(struct dso *p)
                do_relocs(p, (void *)(p->base+dyn[DT_RELA]), dyn[DT_RELASZ], 3);
 
                if (head != &ldso && p->relro_start != p->relro_end &&
-                   mprotect(p->base+p->relro_start, p->relro_end-p->relro_start, PROT_READ) < 0) {
+                   mprotect(p->base+p->relro_start, p->relro_end-p->relro_start, PROT_READ)
+                   && errno != ENOSYS) {
                        error("Error relocating %s: RELRO protection failed: %m",
                                p->name);
                        if (runtime) longjmp(*rtld_fail, 1);
index 6e2e48161753e03f0296e97383b7e081b711fb32..e7df34a949d40758619325f8fc87b53484b1d2ec 100644 (file)
@@ -232,7 +232,8 @@ int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict att
                if (guard) {
                        map = __mmap(0, size, PROT_NONE, MAP_PRIVATE|MAP_ANON, -1, 0);
                        if (map == MAP_FAILED) goto fail;
-                       if (__mprotect(map+guard, size-guard, PROT_READ|PROT_WRITE)) {
+                       if (__mprotect(map+guard, size-guard, PROT_READ|PROT_WRITE)
+                           && errno != ENOSYS) {
                                __munmap(map, size);
                                goto fail;
                        }