[Bug 239873] www/firefox and mail/thunderbird don't like the new ASLR "stackgap" feature

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 11 Jun 2021 22:28:46 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=239873

--- Comment #14 from sigsys@gmail.com ---
Well, here's the patch updated to use the new feature names with the "no"
prefix. Not using the new elfctl -i flag (which would have been perfect for
this) because older 12.X might have an elfctl that doesn't support it yet.

And I tested it again to confirm that firefox/thunderbird still don't work with
the stackgap (same error as before) and that when built and installed with this
change they do work.

This seems very unlikely to cause any problems to me.  This is the first use of
elfctl in the ports but not the first use of ELF tampering (brandelf is used
for example).


diff --git a/Mk/bsd.commands.mk b/Mk/bsd.commands.mk
index 620c62eb1533..221a04e4b8f2 100644
--- a/Mk/bsd.commands.mk
+++ b/Mk/bsd.commands.mk
@@ -34,6 +34,7 @@ DIALOG4PORTS?=                ${LOCALBASE}/bin/dialog4ports
 DIFF?=                 /usr/bin/diff
 DIRNAME?=              /usr/bin/dirname
 EGREP?=                        /usr/bin/egrep
+ELFCTL?=               /usr/bin/elfctl
 EXPR?=                 /bin/expr
 FALSE?=                        false   # Shell builtin
 FILE?=                 /usr/bin/file
diff --git a/Mk/bsd.gecko.mk b/Mk/bsd.gecko.mk
index 3a48e802ea40..81ed6b7fc6dd 100644
--- a/Mk/bsd.gecko.mk
+++ b/Mk/bsd.gecko.mk
@@ -111,6 +111,7 @@ PLISTF?=    ${WRKDIR}/plist_files

 MOZCONFIG?=            ${WRKSRC}/.mozconfig
 MOZILLA_PLIST_DIRS?=   bin lib share/pixmaps share/applications
+MOZILLA_ELFCTLFIX_BINS?=       lib/${MOZILLA}/${MOZILLA}
lib/${MOZILLA}/${MOZILLA_BIN}

 # Adjust -C target-cpu if -march/-mcpu is set by bsd.cpu.mk
 .if ${ARCH} == amd64 || ${ARCH} == i386
@@ -385,7 +386,14 @@ pre-configure-script:
        @${SETENV} CC="${CC}" OPSYS="${OPSYS}" OSVERSION="${OSVERSION}"
WRKDIR="${WRKDIR}" \
                ${SH} ${SCRIPTSDIR}/rust-compat11-canary.sh

-post-install-script: gecko-create-plist
+post-install-script: gecko-elfctlfix gecko-create-plist
+
+gecko-elfctlfix:
+# Avoids "too much recursion" errors when the ASLR "stackgap" is globally
enabled.
+.for bin in ${MOZILLA_ELFCTLFIX_BINS}
+       @if test -x ${ELFCTL} && ${ELFCTL} -l | ${GREP} -q noaslrstkgap; then \
+               ${ELFCTL} -e +noaslrstkgap ${STAGEDIR}${PREFIX}/${bin}; fi
+.endfor

 gecko-create-plist:
 # Create the plist

-- 
You are receiving this mail because:
You are the assignee for the bug.