Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260421075727.164197-1-florian.schmaus@codasip.com>
Date: Tue, 21 Apr 2026 09:57:27 +0200
From: Florian Schmaus <florian.schmaus@...asip.com>
To: musl@...ts.openwall.com
Cc: Florian Schmaus <florian.schmaus@...asip.com>
Subject: [PATCH] dynlink: set errno in case mprotect() fails

The format string of the error message uses %m to print the value of
errno in human-readable form. But the low-level __syscall() macro,
used to invoke mprotect(), will not implicitly set errno. Fix this by
setting errno explicitly before emitting the error message.
---
 ldso/dynlink.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/ldso/dynlink.c b/ldso/dynlink.c
index 715948f4f8b3..db0f9f52461c 100644
--- a/ldso/dynlink.c
+++ b/ldso/dynlink.c
@@ -1424,6 +1424,7 @@ static void reloc_all(struct dso *p)
 			long ret = __syscall(SYS_mprotect, laddr(p, p->relro_start),
 				p->relro_end-p->relro_start, PROT_READ);
 			if (ret != 0 && ret != -ENOSYS) {
+				errno = -ret;
 				error("Error relocating %s: RELRO protection failed: %m",
 					p->name);
 				if (runtime) longjmp(*rtld_fail, 1);
-- 
2.53.0

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.