Skip to content

Commit

Permalink
HBSD: enable pid randomization in PAX_HARDENING case
Browse files Browse the repository at this point in the history
This commit effectiveliy reverts the following commit:

    HBSD: Use HARDEN_RANDOMPID for hardening kern.randompid

    Setting the kern.randompid sysctl node, as we do by default with the
    PAX_HARDENING kernel flag, can cause Poudriere's use of `pwait` to hang
    indefinately. So that users who want to build their own packages using
    Poudriere on HardenedBSD, provide a separate option for hardening PID
    randomization. Add the option to the HARDENEDBSD kernel.

    There is a candidate patch for `pwait` in upstream FreeBSD. However,
    that should be treated separately.

    Signed-off-by:  Shawn Webb <[email protected]>
    Sponsored-by:   SoldierX
    github-issue:   #263
    See-also:       https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=218598
    MFC-to:         10-STABLE
    MFC-to:         11-STABLE

Instead of working around user-space tools errors from kernel, pull in
the proper fix to pwait...

In the same time, this commit removes the last non-standard hardening knob.

And if someone want to disable pid randomization, then they still able
to do it with specifying ``hardening.randomize_pids=0`` in loader.conf.

MFC-to: 10-STABLE
MFC-to: 11-STABLE
Signed-off-by: Oliver Pinter <[email protected]>
(cherry picked from commit baf6bf5b16681f98941f25302074ff64df89e076)
Signed-off-by: Oliver Pinter <[email protected]>
(cherry picked from commit 9247a9f)
Signed-off-by: Oliver Pinter <[email protected]>
  • Loading branch information
opntr committed Sep 23, 2017
1 parent c694b80 commit 5c0bfdf
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions sys/kern/kern_fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,10 @@ SYSCTL_INT(_kern, OID_AUTO, lastpid, CTLFLAG_RD, &lastpid, 0,
*/
int randompid = 0;

#ifndef PAX_HARDENING
#ifdef PAX_HARDENING
SYSCTL_INT(_kern, OID_AUTO, randompid, CTLFLAG_RD, &randompid, 0,
"Random PID modulus");
#else
static int
sysctl_kern_randompid(SYSCTL_HANDLER_ARGS)
{
Expand All @@ -225,9 +228,6 @@ sysctl_kern_randompid(SYSCTL_HANDLER_ARGS)

SYSCTL_PROC(_kern, OID_AUTO, randompid, CTLTYPE_INT|CTLFLAG_RW,
0, 0, sysctl_kern_randompid, "I", "Random PID modulus");
#else
SYSCTL_INT(_kern, OID_AUTO, randompid, CTLFLAG_RD, &randompid, 0,
"Random PID modulus");
#endif

static int
Expand Down

0 comments on commit 5c0bfdf

Please sign in to comment.