Skip to content

Commit 7ab700f

Browse files
committed
Make failure to set SECCOMP or NO_NEW_PRIVS fatal
If your Linux system lacks support for these then please don't enable the seccomp sandbox. Prompted by manfred.kaiser@ssh-mitm.at
1 parent 4f4aeee commit 7ab700f

1 file changed

Lines changed: 3 additions & 11 deletions

File tree

sandbox-seccomp-filter.c

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,6 @@ void
535535
ssh_sandbox_child(struct ssh_sandbox *box)
536536
{
537537
struct rlimit rl_zero, rl_one = {.rlim_cur = 1, .rlim_max = 1};
538-
int nnp_failed = 0;
539538

540539
/* Set rlimits for completeness if possible. */
541540
rl_zero.rlim_cur = rl_zero.rlim_max = 0;
@@ -558,18 +557,11 @@ ssh_sandbox_child(struct ssh_sandbox *box)
558557
#endif /* SANDBOX_SECCOMP_FILTER_DEBUG */
559558

560559
debug3_f("setting PR_SET_NO_NEW_PRIVS");
561-
if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) == -1) {
562-
debug("%s: prctl(PR_SET_NO_NEW_PRIVS): %s",
563-
__func__, strerror(errno));
564-
nnp_failed = 1;
565-
}
560+
if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) == -1)
561+
fatal_f("prctl(PR_SET_NO_NEW_PRIVS): %s", strerror(errno));
566562
debug3_f("attaching seccomp filter program");
567563
if (prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &preauth_program) == -1)
568-
debug("%s: prctl(PR_SET_SECCOMP): %s",
569-
__func__, strerror(errno));
570-
else if (nnp_failed)
571-
fatal("%s: SECCOMP_MODE_FILTER activated but "
572-
"PR_SET_NO_NEW_PRIVS failed", __func__);
564+
fatal_f("prctl(PR_SET_SECCOMP): %s", strerror(errno));
573565
}
574566

575567
#endif /* SANDBOX_SECCOMP_FILTER */

0 commit comments

Comments
 (0)