Bug 1477907

Summary: Configuration reload (SIGHUP) opens two (never closed) new pipes in subprocess [rhel-7.3.z]
Product: Red Hat Enterprise Linux 7 Reporter: Oneata Mircea Teodor <toneata>
Component: keepalivedAssignee: Ryan O'Hara <rohara>
Status: CLOSED ERRATA QA Contact: Brandon Perkins <bperkins>
Severity: urgent Docs Contact:
Priority: urgent    
Version: 7.3CC: cfeist, cluster-maint, igkioka, rohara, salmy, toneata, yann.morice
Target Milestone: rcKeywords: Regression, ZStream
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: keepalived-1.2.13-9.el7_3.1 Doc Type: Bug Fix
Doc Text:
Previously, open pipes were not closed properly when the keepalived process received the SIGHUP signal. As a consequence, every time keepalived received SIGHUP, two new pipes were created while the existing pipes were not closed. This bug has been fixed by using the pipe2() system call with the O_CLOEXEC flag. As a result, the number of open pipes no longer grows with every SIGHUP signal.
Story Points: ---
Clone Of: 1464869 Environment:
Last Closed: 2018-01-25 12:58:25 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1464869    
Bug Blocks:    

Description Oneata Mircea Teodor 2017-08-03 07:51:44 UTC
This bug has been copied from bug #1464869 and has been proposed to be backported to 7.3 z-stream (EUS).

Comment 3 Oneata Mircea Teodor 2017-08-03 07:52:53 UTC
*** Bug 1477883 has been marked as a duplicate of this bug. ***

Comment 4 Ryan O'Hara 2017-08-03 15:20:53 UTC
The fix here is two-part:

1. Add "@DEFS@" to the DEFS in lib/Makefile.in such that the HAVE_PIPE2 is used correctly at build time.

2. Add back a few lines of code that were removed in #1429880. Specifically, the code in signal_handler_destroy():

--      close(signal_pipe[1]);
--      close(signal_pipe[0]);
--      signal_pipe[1] = -1;
--      signal_pipe[0] = -1;

Comment 5 Ryan O'Hara 2017-08-03 15:36:42 UTC
Test results:

# rpm -q keepalived
keepalived-1.2.13-9.el7_3.1.x86_64

# keepalived -f /etc/keepalived/keepalived.conf 
# pstree -p $( cat /var/run/keepalived.pid )
keepalived(34937)─┬─keepalived(34938)
                                 └─keepalived(34939)

# lsof | grep 34937 | grep pipe | wc -l
2
# lsof | grep 34938 | grep pipe | wc -l
2
# lsof | grep 34939 | grep pipe | wc -l
2

# kill -HUP $( cat /var/run/keepalived.pid )

# lsof | grep 34937 | grep pipe | wc -l
2
# lsof | grep 34938 | grep pipe | wc -l
2
# lsof | grep 34939 | grep pipe | wc -l
2

Note that after SIGHUP each process should have exactly 2 pipes open. This is correct.

Comment 12 errata-xmlrpc 2018-01-25 12:58:25 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.

https://access.redhat.com/errata/RHBA-2018:0183