proccontrol allows to set process modes for port build stages,
e.g. to build ports on a builder with restricted page permissions.
Example:
USES= proccontrol
PROCCONTROL_SET=protmax:disable wxmap:enable
Differential D47086
Mk/Uses: add proccontrol 2khramtsov_gmail.com on Oct 12 2024, 3:48 PM. Authored by Tags None Referenced Files
Details
proccontrol allows to set process modes for port build stages, Example: USES= proccontrol
Diff Detail
Event TimelineComment Actions The goal here is to have a builder with vm.imply_prot_max=1 and kern.elf64.allow_wx=0 set and have opt out for ports which need WX pages for configure/build/stage/tests. This chain isn't exhaustive, after this chain is landed I plan to request exp-run to expose ports that can't build in restricted environment. I also plan to push elfctl related changes (so after pkg install software should "just work") but I decided that I want to work on proccontrol in ports first (to also be able to bootstrap ports to set elfctl on). JDK ports are an exception and are included in review chain because I've done that before local elfctl changes. PROCCONTROL_SET could also likely be used for e.g. modes in proccontrol(1), as of main: Modes: aslr|trace|trapcap|protmax|stackgap|nonewprivs|wxmap|kpti|la57|la48 Comment Actions PROCCONTROL_CMD -> PROCCONTROL and put in bsd.commands.mk like elfctl (also testing git arc) Comment Actions This approach is very intrusive and I don't think the is the right approach, the right one is do mark the binary which are not protmax or wx=0 friendly. Comment Actions
Agreed. The only way out I can see for ports at the moment is this due to e.g.:
Patching upstream sources to use elfctl(1) might be futile due:
I fail to see how this could be invasive because:
Maybe we could have something similar on poudriere side but then I can't see strict page permissions adoption outside of builders. This comment was removed by 2khramtsov_gmail.com. Comment Actions This feels like a big hammer. My most fundamental concern is that this assumes proccontrol flags are heritable and that it's appropriate to disable security functionality at a depth greater than the immediate child. In CheriBSD I am considering adding some flags (which should eventually land in FreeBSD) that exist for developer convenience and aren't inherited. The reason is that there's enough demand for some features that defeat a security mechanism that I think I need to support it, but I want to it be clearly auditable at the binary level which means (due to the shape of the APIs involved) something has to be present in the ELF headers. I don't think all the concerns about elfctl are particularly well founded. For example bootstrap-openjdk looks easy to fix. I'd support adding an ELF_FEATURES_POST_STAGE or the like to simplify it. Intermediate binaries needing opt-outs would best be discovered and fixed rather than hidden behind a knob at the level of the whole build. That being said, I don't understand the issues with process groups. Comment Actions Ports needing opt out may use JIT, thus these cases have parts likely written in languages different than C family. These languges may have compilers written in the same language that use JIT, thus multi-stage opt out is likely: for configure (e.g. bootstrap-openjdk), for build (bootstrap-openjdk builds javac which then builds the rest of JDK), for stage (post-built binaries are executed e.g. neovim), and for tests. Per stage opt out is redundant considering multi-stage opt out is likely until elfctl(1) has broad adoption (with changed behavior to accomodate Bug 271838), changing proccontrol.mk to have per stage opt out would not reduce bsd.port.mk diff and would complicate behavior for nothing, because benefit is still retained when distfile fetch would still be done with strict page permissions as it precedes build stages, and builders can run with strict permissions after port build. Do {configure,make,install,test} have environment set before *_CMD, and the install stage uses FAKEROOT as parent. Variable bandwagon if a concern could be addressed via e.g. WRAP_{CMD,ENV}. I don't see how PROCCONTROL_EXEC is different. See bug 256477 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=256477#c20 Please propose your solution. Build systems (as well as declarative ones e.g. meson) would need to have logic for executing external binaries (e.g. elfctl(1)) post build of a binary with specified name for opt out. Considering the variety in Mk/Uses amount of effort is high, and would still not work port tree wide until ELF opt out behavior in the base is changed to accomodate Bug 271838, meanwhile proccontrol(1) is in all supported FreeBSD versions. Both elfctl.mk and proccontrol.mk would have no use when build systems adopt elfctl(1) and Bug 271838 is accommodated. If the argument against proccontrol.mk is that opt out should occur intermidiately during build then elfctl.mk is the same as proccontrol.mk as neither can't set ELF notes on intermediate binaries during build stage, build systems can. Port maintainers with hostile upstreams may also not be interested to maintain local patches, e.g. www/chromium build failures when testing patch rebase cause loss of multi-hour builds due lack of support of incremental builds or ccache in ports: See bug 244532 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=244532#c0 Then consider not using proccontrol for non-heritable flags downstream. I can't be aware of every downstream before I propose a change. "well founded" means "based on facts", see https://dictionary.cambridge.org/dictionary/english/well-founded I may lose interest if mentioning PRs with elfctl(1) opt out limitations would get comments about whether concerns are based on evidence (PRs are) or not. Comment Actions
|