mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] Potential DL_NOMMU_SUPPORT bug.
@ 2021-01-23  6:47 Andrew Rogers
  2021-01-24 15:40 ` Rich Felker
  0 siblings, 1 reply; 8+ messages in thread
From: Andrew Rogers @ 2021-01-23  6:47 UTC (permalink / raw)
  To: musl


[-- Attachment #1.1: Type: text/plain, Size: 951 bytes --]

Hi,

I was trying a DL_NOMMU_SUPPORT build so I could load binaries from the
sdcard on an android device. I managed to succeed but only after making a
mod which I later realised might apply beyond my application.

The mmap_fixed() function would return as if successful even when mmap()
call had failed

Hopefully the link and the patch below help.

Regards
Andrew

https://git.musl-libc.org/cgit/musl/tree/ldso/dynlink.c?id=85e0e3519655220688e757b9d5bfd314923548bd#n584

diff -Naur musl-1.2.2-orig/ldso/dynlink.c musl-1.2.2-new/ldso/dynlink.c
--- musl-1.2.2-orig/ldso/dynlink.c 2021-01-15 02:26:00.000000000 +0000
+++ musl-1.2.2-new/ldso/dynlink.c 2021-01-23 06:26:26.861158169 +0000
@@ -581,7 +581,7 @@
  char *q;
  if (!no_map_fixed) {
  q = mmap(p, n, prot, flags|MAP_FIXED, fd, off);
- if (!DL_NOMMU_SUPPORT || q != MAP_FAILED || errno != EINVAL)
+ if (!DL_NOMMU_SUPPORT && q != MAP_FAILED && errno != EINVAL)
  return q;
  no_map_fixed = 1;
  }

[-- Attachment #1.2: Type: text/html, Size: 1326 bytes --]

[-- Attachment #2: musl-DL_NOMMU_SUPPORT-dynlink.patch --]
[-- Type: text/x-patch, Size: 485 bytes --]

diff -Naur musl-1.2.2-orig/ldso/dynlink.c musl-1.2.2-new/ldso/dynlink.c
--- musl-1.2.2-orig/ldso/dynlink.c	2021-01-15 02:26:00.000000000 +0000
+++ musl-1.2.2-new/ldso/dynlink.c	2021-01-23 06:26:26.861158169 +0000
@@ -581,7 +581,7 @@
 	char *q;
 	if (!no_map_fixed) {
 		q = mmap(p, n, prot, flags|MAP_FIXED, fd, off);
-		if (!DL_NOMMU_SUPPORT || q != MAP_FAILED || errno != EINVAL)
+		if (!DL_NOMMU_SUPPORT && q != MAP_FAILED && errno != EINVAL)
 			return q;
 		no_map_fixed = 1;
 	}

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-01-30 19:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-23  6:47 [musl] Potential DL_NOMMU_SUPPORT bug Andrew Rogers
2021-01-24 15:40 ` Rich Felker
2021-01-24 15:58   ` Alexander Monakov
2021-01-24 18:10     ` Rich Felker
2021-01-24 18:48       ` Alexander Monakov
2021-01-24 18:55         ` Rich Felker
2021-01-30 17:44           ` Andrew Rogers
2021-01-30 19:01             ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).