Ubuntu

su: kill child process group on signal, not just immediate child

Reported by Colin Watson on 2013-07-26
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
shadow (Debian)
Fix Committed
Unknown
shadow (Ubuntu)
High
Colin Watson
Raring
High
Colin Watson

Bug Description

[Impact] Operational pain on Ubuntu builders every time a build hangs.
[Test Case] See below, starting with 'pgrep sleep'.
[Regression Potential] It's su; we should be pretty careful. Running saucy builds with this for a while will help, and seeing whether anyone objects to the broader process-killing.

Original report follows:

Imported from Debian bug http://bugs.debian.org/713979:

Package: shadow
Version: 1:4.1.5.1-1
Severity: normal
User: <email address hidden>
Usertags: origin-ubuntu saucy

For some time I've noticed that, when an Ubuntu build times out (150
minutes with no output), sbuild tries to terminate it, and I see a
"Session terminated, terminating shell... ...terminated." message in the
log (which is from su), but the build does not actually terminate
properly. Now, in both Debian and Ubuntu, sbuild invokes builds using
something like this simplified command:

  sudo chroot $chroot su $username -s sh -c "cd $dir && exec dpkg-buildpackage"

When su receives a signal, it passes it on to its child process (it has
to go to unusual lengths here because it starts new sessions). However,
it only kills its immediate child, not the associated process group.
This means that you can do something like this:

  $ pgrep sleep
  $ su cjwatson -c 'sh -c "sleep 1h"'
  Password:
  [wait a few seconds]
  ^C
  Session terminated, terminating shell...Sessions still open, not unmounting
   ...killed.
  $ pgrep sleep
  32421

This is inconvenient; in this case it means we often have to ask
sysadmins to manually kill processes for us. I don't have much
visibility into Debian buildds but I suspect there are similar problems
there from time to time.

Could su please kill the process group associated with its immediate
child process instead? This should just be a matter of negating the pid
passed to kill. If it did that, then I think it would do a much better
job of cleaning up after itself.

Thanks,

--
Colin Watson [<email address hidden>]

Colin Watson (cjwatson) wrote :

I can only reproduce this in raring and saucy. It looks like this was triggered by the change in 4.1.5 (Debian #628843) to avoid giving noninteractive children a controlling terminal.

Changed in shadow (Ubuntu):
status: New → Triaged
importance: Undecided → High
assignee: nobody → Colin Watson (cjwatson)
status: Triaged → In Progress
Colin Watson (cjwatson) on 2013-07-26
description: updated

Hello Colin, or anyone else affected,

Accepted shadow into raring-proposed. The package will build now and be available at http://launchpad.net/ubuntu/+source/shadow/1:4.1.5.1-1ubuntu4.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in shadow (Ubuntu Raring):
status: New → Fix Committed
tags: added: verification-needed
Changed in shadow (Debian):
importance: Undecided → Unknown
Colin Watson (cjwatson) wrote :

shadow (1:4.1.5.1-1ubuntu6) saucy; urgency=low

  * debian/patches/496_su_kill_process_group: Kill the child process group,
    rather than just the immediate child; this is needed now that su no
    longer starts a controlling terminal when not running an interactive
    shell (closes: #713979).

 -- Colin Watson <email address hidden> Fri, 26 Jul 2013 16:55:52 +0100

Changed in shadow (Ubuntu):
status: In Progress → Fix Released
Changed in shadow (Ubuntu Raring):
importance: Undecided → High
assignee: nobody → Colin Watson (cjwatson)
Colin Watson (cjwatson) wrote :

This seems good. We've now seen:

 * the manual test case passing on raring
 * lots of builds running normally with the upgraded login package on saucy
 * a build being terminated correctly on saucy (https://launchpadlibrarian.net/146338663/buildlog_ubuntu-saucy-i386.llvm-toolchain-3.3_1%3A3.3-3ubuntu1_FAILEDTOBUILD.txt.gz)
 * builds running normally with the upgraded login package on raring (e.g. https://launchpadlibrarian.net/146376863/buildlog_ubuntu-raring-i386.whoopsie_0.2.15.1_UPLOADING.txt.gz)
 * a build being terminated correctly on raring (https://launchpadlibrarian.net/146386974/buildlog_ubuntu-raring-i386.hello_2.8-3ppa1_FAILEDTOBUILD.txt.gz)

tags: added: verification-done
removed: verification-needed
Changed in shadow (Debian):
status: New → Fix Committed
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package shadow - 1:4.1.5.1-1ubuntu4.1

---------------
shadow (1:4.1.5.1-1ubuntu4.1) raring; urgency=low

  * debian/patches/496_su_kill_process_group: Kill the child process group,
    rather than just the immediate child; this is needed now that su no
    longer starts a controlling terminal when not running an interactive
    shell (closes: #713979, LP: #1205407).
 -- Colin Watson <email address hidden> Fri, 26 Jul 2013 17:20:17 +0100

Changed in shadow (Ubuntu Raring):
status: Fix Committed → Fix Released

The verification of this Stable Release Update has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regresssions.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.