~zyga/checkbox/fix-1402421

  • Committer: Zygmunt Krynicki
  • Date: 2014-12-15 10:40:06 UTC
  • Revision ID: zygmunt.krynicki@canonical.com-20141215104006-ccgzm3mpfhicjzil
plainbox:vendor:extcmd use process-wide signal masks

This patch changes extcmd to use process-wide signal masks (aka
sigprocmask vs pthread_sigmask). This fixes a problem where in a
multi-threaded application, extcmd might misbehave if the SIGCHLD signal
was delivered to a different thread than the one running extcmd's event
loop. When that happens the signal itself is consumed and subsequent
read from signalfd() would return EAGAIN (aka errno 11, aka
BlockingIOError).

The precise sequence of events that need to happen in
order to trigger this bug is:

- assume that there is a process P1, running two threads T1 and T2.
  Extcmd is running in T1 and has blocked SIGCHLD (so that it can be
  collected via epoll-triggered signalfd). T2 runs unrelated code.
- assume that there is a process P2, that is a child of P1, that has
  just exited.
- the signal is enqueued as readable via signalfd, waking up T1
- since P1's T1 is blocking SIGCHLD, the signal is delivered to T2.
- T1 tries to read() from signalfd and receives EAGAIN

The patch fixes this so that no matter how the scheduling orders events,
this will happen:

- assume that there is a process P1, running two threads T1 and T2.
  Extcmd is running in T1 and has blocked SIGCHLD (so that it can be
  collected via epoll-triggered signalfd). T2 runs unrelated code.
- assume that there is a process P2, that is a child of P1, that has
  just exited.
- the signal is enqueued as readable via signalfd, waking up T1
- since P1 is blocking SIGCHLD for all threads the signal is not
  delivered
- T1 reads signal details from signalfd

Fixes: https://bugs.launchpad.net/plainbox/+bug/1402421

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Filename Latest Rev Last Changed Committer Comment Size
..
checkbox-gui 2549.2.3 10 years ago Brendan Donegan Rename plainbox-gui and canonical-driver-test-suit Diff
checkbox-ng 2128.1.1 11 years ago Zygmunt Krynicki checkbox-ng: add CheckBoxNG sub-project CheckBoxN Diff
checkbox-support 2585.1.2 10 years ago Sylvain Pineau checkbox-support: Copy required modules from check Diff
checkbox-touch 3178.1.1 9 years ago Zygmunt Krynicki checkbox-touch: generate simple checkbox-touch app Diff
plainbox 0.1.26 11 years ago Zygmunt Krynicki Rename new-root to plainbox Diff
plainbox-client 2418.2.1 10 years ago Zygmunt Krynicki plainbox-client: add the new plainbox client packa Diff
providers 2716.1.1 10 years ago Zygmunt Krynicki providers: add the meta-test provider PlainBox ca Diff
support 2145.1.8 11 years ago Zygmunt Krynicki support: add dependency support module This patch Diff
.bzrignore 2810.1.1 10 years ago Zygmunt Krynicki .{git,bzr}ignore: ignore checkbox-gui build stuff 1.1 KB Diff Download File
.coveragerc 2708.1.9 10 years ago Zygmunt Krynicki .coveragerc: sort entries 545 bytes Diff Download File
.gitignore 3211.1.3 9 years ago Zygmunt Krynicki .gitignore: ignore lxc-logs/ Signed-off-by: Zygmu 1.3 KB Diff Download File
.travis.yml 3391 9 years ago Daniel Manrique "Release_2014_Week45 [r=sylvain-pineau][bug=133130 3.2 KB Diff Download File
Symlink mk-venv 2145.1.8 11 years ago Zygmunt Krynicki support: add dependency support module This patch .
README.md 3189.1.1 9 years ago Zygmunt Krynicki README.md: add a description of checkbox-touch Si 2.2 KB Diff Download File
File setup.py 2808.1.14 10 years ago Zygmunt Krynicki support: don't multiplex to checkbox-old 1.5 KB Diff Download File
File tarmac-verify 3026.1.1 10 years ago Daniel Manrique tarmac-verify: fix setting of KEEP_DATA environmen 1 KB Diff Download File
File test-in-lxc.sh 3072.1.1 9 years ago Daniel Manrique test-in-lxc: fix recommended sudo configuration fo 10 KB Diff Download File
File test-in-vagrant.sh 2973.1.2 10 years ago Daniel Manrique test-in-vagrant: Use per-component mini-scripts fo 5.1 KB Diff Download File
Symlink test-with-coverage 2708.1.8 10 years ago Zygmunt Krynicki support: beef up test-with-coverage This patch ma .
Vagrantfile 2974.1.1 10 years ago Daniel Manrique provision-vagrant: A few changes to support other 2.4 KB Diff Download File