Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
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.
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.
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.
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.
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