[Bug 271069] syslogd service inside client jail requires restart before server jail receives logs

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 11 Aug 2023 21:04:40 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=271069

--- Comment #6 from Siva Mahadevan <me@svmhdvn.name> ---
Created attachment 244033
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=244033&action=edit
sleep in parent

(In reply to Siva Mahadevan from comment #3)

I was able to find the race condition inside the usr.sbin/jail command and
narrow it down to the area highlighted by the attached patches. Basing the
following commentary on the minimal repro from comment #3.

The confirmed issue is that the jail's start command (in this case, `rc`) runs
before the IPv6 alias address is set in the jail by `ifconfig`. This causes the
`sshd` service to be started before the IPv6 address is available.
When I add a sleep of 350 milliseconds or more to *either* the parent or the
child as shown in the above patches, the above issue does not occur and the
IPv6 alias address is available before `rc` starts the `sshd` service. This is
sensitive to timing; I found that if I change the sleep to 300 milliseconds or
less, the race condition consistently repros.

I tried adding a `waitpid(pid, NULL, 0)` in the parent immediately after the
`fork()` call, but that doesn't seem to work. I am not sure how to proceed in
the debug. I think that the solution here is to ensure that each setup command
runs to completion *serially* before the jail's `start.command` is run. The
code seems to already do this by tracking the process and waiting on it in
`next_proc()` at command.c:275, but I can't see why this doesn't work.

I will continue to debug further in the meantime; please let me know if there
are any ideas here and I will prepare a patch to fix the issue.

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