New issue
Advanced search Search tips

Issue 730682 link

Starred by 1 user

Issue metadata

Status: Verified
Owner:
Closed: Jun 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Bug



Sign in to add a comment

minijail exits when forwarding signal to child process

Project Member Reported by la...@chromium.org, Jun 7 2017

Issue description

Recently minijail gained the ability to forward signals to its sandboxed process. After forwarding the signal, minijail exits. This is generally fine when forwarding e.g. SIGTERM, but may be surprising if a non-terminal signal is forwarded or if the child process does not exit as expected.

This seems to be caused by minijail's waitpid call being terminated prior to its signal handler being called. One solution might be to set the SA_RESTART flag with sigaction(2).
 
Cc: vapier@chromium.org
Mike, didn't you say something about SA_RESTART in the original CL?

Comment 2 by la...@chromium.org, Jun 7 2017

Blocking: 726372
we are setting SA_RESTART already in the forwarding handlers.  mj shouldn't exit for any signal ... it should forward them all and only exit once its child does.

that said, i can't reproduce this report.  it's working for me.  are you testing minijail as it exists in CrOS today ?  that hasn't been rolled yet to include the signal forwarding logic.

what i tested:
- test.c:
int main(int argc, char *argv[])
{
        signal(SIGTERM, SIG_IGN);
        while (1)
                sleep(100);
}
- run `./minijail0 ./a.out &`
- run `kill -TERM %1` and see minijail send SIGTERM to its child process and then go back to waiting (and child ignores it so nothing exits)
- run `kill -INT %1` and see minijail send SIGINT to its child process which now exits, so minijail itself exits

Comment 4 by la...@chromium.org, Jun 8 2017

I tried reproducing your test but I'm seeing different results: after `kill -TERM %1` minijail terminates, orphaning a.out. I built minijail on my workstation at b9a7b16.
you'll need to use 98f4a938cbc4acaff5f06009af50bb4bf19e173b

Comment 6 by la...@chromium.org, Jun 8 2017

Status: Verified (was: Assigned)
That last commit fixes it. Thanks.
I'll tag a new Minijail release at 98f4a938cbc4acaff5f06009af50bb4bf19e173b.

Comment 8 by la...@chromium.org, Jun 9 2017

Blocking: -726372

Comment 9 by vapier@chromium.org, Jun 21 2018

Components: OS>Systems>Minijail

Sign in to add a comment