RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1063887 - su terminates its parent process upon receiving SIGTERM
Summary: su terminates its parent process upon receiving SIGTERM
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: coreutils
Version: 6.5
Hardware: Unspecified
OS: Linux
urgent
urgent
Target Milestone: rc
: ---
Assignee: Ondrej Oprala
QA Contact: Tomas Dolezal
URL:
Whiteboard:
Depends On:
Blocks: 1056252 1111584
TreeView+ depends on / blocked
 
Reported: 2014-02-11 15:25 UTC by Marcel Kolaja
Modified: 2018-12-09 17:30 UTC (History)
4 users (show)

Fixed In Version: coreutils-8.4-33.el6
Doc Type: Bug Fix
Doc Text:
Cause: Fix for #889531 introduced a regression. Consequence: Parent process was killed instead of the su process when SIGTERM signal was received. Fix: Handling of the SIGTERM signal was fixed. Result: Parent process is no longer killed when su gets SIGTERM signal.
Clone Of:
: 1111584 (view as bug list)
Environment:
Last Closed: 2014-10-14 06:34:23 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
part of the reproducer (372 bytes, application/x-shellscript)
2014-02-11 15:27 UTC, Marcel Kolaja
no flags Details
part of the reproducer (72 bytes, application/x-shellscript)
2014-02-11 15:27 UTC, Marcel Kolaja
no flags Details
part of the reproducer (55 bytes, application/x-shellscript)
2014-02-11 15:28 UTC, Marcel Kolaja
no flags Details
proposed patch (406 bytes, patch)
2014-02-11 16:59 UTC, Marcel Kolaja
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2014:1457 0 normal SHIPPED_LIVE coreutils bug fix and enhancement update 2014-10-14 01:10:58 UTC

Description Marcel Kolaja 2014-02-11 15:25:50 UTC
Description of problem:
Let's assume processes listed in this partial output of:

$ ps -Heawww o user,pid,ppid,pgrp,c,stime,tty,time,cmd

root     14874 13214 14874  0 16:49 pts/0    00:00:00         /bin/sh ./quick.sh
root     14875 14874 14874  0 16:49 pts/0    00:00:00           sh /var/tmp/in-between.sh
root     14876 14875 14874  0 16:49 pts/0    00:00:00             su - testuser -c /var/tmp/testsleep.sh
testuser 14878 14876 14878  0 16:49 ?        00:00:00               /bin/sh /var/tmp/testsleep.sh
testuser 14895 14878 14878  0 16:49 ?        00:00:00                 sleep 30

When 14876 receives SIGTERM, the parent process is terminated.

Version-Release number of selected component (if applicable):
coreutils-8.4-31.el6.x86_64

How reproducible:
always

Steps to Reproduce:
1. create user testuser
2. deploy the attached scripts in /var/tmp/
3. # cd /var/tmp/
4. # ./quick.sh

Actual results:
[root@el6vm tmp]# ./quick.sh 
start of ./quick.sh
start of /var/tmp/in-between.sh
OPID = 19051
start of /var/tmp/testsleep.sh

Út úno 11 16:08:50 CET 2014
root     19049 19009 19049  0 16:08 pts/0    00:00:00         /bin/sh ./quick.sh
root     19050 19049 19049  0 16:08 pts/0    00:00:00           sh /var/tmp/in-between.sh
root     19051 19050 19049  0 16:08 pts/0    00:00:00             su - testuser -c /var/tmp/testsleep.sh
testuser 19053 19051 19053  0 16:08 ?        00:00:00               /bin/sh /var/tmp/testsleep.sh
testuser 19070 19053 19053  0 16:08 ?        00:00:00                 sleep 30
killing testsleep.sh

Session terminated, killing shell...after killing testsleep.sh
 ...killed.
Ukončen (SIGTERM)
[root@el6vm tmp]# 

Expected results:
[root@el6vm tmp]# ./quick.sh 
start of ./quick.sh
start of /var/tmp/in-between.sh
OPID = 19096
start of /var/tmp/testsleep.sh

Út úno 11 16:12:02 CET 2014
root     19094 19009 19094  0 16:11 pts/0    00:00:00         /bin/sh ./quick.sh
root     19095 19094 19094  0 16:11 pts/0    00:00:00           sh /var/tmp/in-between.sh
root     19096 19095 19094  0 16:11 pts/0    00:00:00             su - testuser -c /var/tmp/testsleep.sh
testuser 19098 19096 19098  0 16:11 ?        00:00:00               /bin/sh /var/tmp/testsleep.sh
testuser 19115 19098 19098  0 16:11 ?        00:00:00                 sleep 30
killing testsleep.sh
after killing testsleep.sh

Session terminated, killing shell... ...killed.

Út úno 11 16:12:05 CET 2014
testuser 19115     1  0 16:11 ?        00:00:00 sleep 30
end of /var/tmp/in-between.sh
end of ./quick.sh
[root@el6vm tmp]# 

Additional info:
This regression has been introduced with fixing bug #889531, which backports this upstream commit:

https://github.com/karelzak/util-linux/commit/8960f3ae5f4d72be88ee76e50417785e836b35e8

When kill is called, all processes in the process group receive the caught signal:

https://github.com/karelzak/util-linux/commit/8960f3ae5f4d72be88ee76e50417785e836b35e8#diff-57e155f7656f0e8586081c57c729122fR397

As one can see in the output above, su is in the same process group as the parent process, which means that they are sent the caught signal.

Comment 1 Marcel Kolaja 2014-02-11 15:27:06 UTC
Created attachment 861812 [details]
part of the reproducer

Comment 2 Marcel Kolaja 2014-02-11 15:27:35 UTC
Created attachment 861813 [details]
part of the reproducer

Comment 3 Marcel Kolaja 2014-02-11 15:28:07 UTC
Created attachment 861815 [details]
part of the reproducer

Comment 5 Marcel Kolaja 2014-02-11 16:59:25 UTC
Created attachment 861885 [details]
proposed patch

Killing getpid() instead 0 fixes the issue and doesn't seem to reintroduce bug #889531. Thanks Karel Zak for the hint! Please, note that this issue seems to be present in upstream too.

Comment 7 Karel Zak 2014-02-17 14:28:55 UTC
Note that the util-linux upstream has been fixed by commit 270ab78a0c84a0d580d3dfa257813abbba385687.

Comment 19 errata-xmlrpc 2014-10-14 06:34:23 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2014-1457.html


Note You need to log in before you can comment on or make changes to this bug.