bugSystem V style init programs - Bugs: bug #34992, pidof breaks after prelink

 
 

bug #34992: pidof breaks after prelink

Submitter:  Dave Dykstra <dwd>
Submitted:  Mon 05 Dec 2011 04:58:39 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  wfink
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Wed 28 Feb 2018 02:45:16 AM UTC, comment #10: 

This patch has been merged and should be in sysvinit 2.89. Release coming soon (hopefully).

Jesse <newguy>
Group administrator
Fri 12 Jul 2013 02:50:32 PM UTC, comment #9: 

So is there any prospect of making a new release of sysvinit anytime soon that will include this fix?

Dave

Dave Dykstra <dwd>
Fri 16 Mar 2012 09:56:35 PM UTC, comment #8: 

Werner,

That worked well for me on RHEL6.2.

Thanks,

Dave

Dave Dykstra <dwd>
Fri 16 Mar 2012 04:54:39 PM UTC, comment #7: 

Just add a modified version of your patch to svn head.
You may it give it a try.

Dr. Werner Fink <wfink>
Group administrator
Thu 15 Mar 2012 10:39:36 AM UTC, comment #6: 

Difference between rhel5 and newer systems is probably caused by this:  https://bugzilla.redhat.com/show_bug.cgi?id=803632.

Lukáš Nykrýn <lnykryn>
Tue 13 Mar 2012 06:19:03 PM UTC, comment #5: 

RHEL5.5 (actually, Scientific Linux 5.5): 2.6.18-274.17.1.el5xen
RHEL6: 2.6.32-220.el6.x86_64
FC16: 3.1.0-7.fc16.x86_64

Dave Dykstra <dwd>
Tue 13 Mar 2012 05:19:20 PM UTC, comment #4: 

Hmmm ... just to be sure: which kernel versions are used?

Dr. Werner Fink <wfink>
Group administrator
Tue 13 Mar 2012 03:32:45 PM UTC, comment #3: 

In case someone reads this someday, Redhat did decide to take an interst and there are more updates on the RHEL bug report.  That includes an explanation for why the current released sysvinit-tools code works on RHEL5 and not on RHEL6: the behavior of the kernel for overwritten running binaries has changed.  Demonstrate the difference with the following commands on RHEL6:
  # yum install squid
  # service squid start
  # /sbin/pidof /usr/sbin/squid
  ... reports two pids, call them NNN1 and NNN2 ...
  # cp /usr/sbin/squid /usr/sbin/squid.copy
  # mv -f /usr/sbin/squid.copy /usr/sbin/squid
  # /sbin/pidof /usr/sbin/squid
  ... reports only one pid ...
  # ls -l /proc/NNN1/exe /proc/NNN2/exe
  ... reports -> /usr/sbin/squid (deleted)
  ...         -> /usr/sbin/squid (deleted)

The difference is that on RHEL5, it doesn't add the " (deleted)" to the symlink targets of /proc/NNN{1,2}/exe unless you do a rm -f /usr/sbin/squid between the cp and the mv.

Also by the way, I verified the same thing happened on Fedora 16 as RHEL6.

- Dave

Dave Dykstra <dwd>
Wed 15 Feb 2012 04:33:39 PM UTC, comment #2: 

Hello, is anybody there?

The bug report on Redhat Enterprise Linux is here:
https://bugzilla.redhat.com/show_bug.cgi?id=760251

They have finally responded, but only to say they're not going to do anything about it in the next release.

- Dave

Dave Dykstra <dwd>
Fri 09 Dec 2011 04:30:55 PM UTC, comment #1: 

I made the mistake of not actually trying the patch on a RHEL6 system until now.  It turns out that the newer system adds a " (deleted)" to the end of the link name when the original executable is replaced, so it unfortunately needs a more complicated patch to strip that off.  The new patch is attached.

- Dave

(file #24557)

Dave Dykstra <dwd>
Mon 05 Dec 2011 04:58:39 PM UTC, original submission:  

I first noticed this on a RHEL6 system but duplicated it even on a RHEL5-based system when I compiled sysvinit-2.88dsf from source.  For an application like squid, which has one process starting with an arg0 of the full path of the executable (/usr/sbin/squid) and a child process that doesn't use the full path (it instead puts the name squid in parentheses, "(squid)"), then pidof lists only the parent process which has the matching full-path arg0 after prelink has run.  Prelink runs the night after a new executable is installed and modifies the executable file, such that /proc/NNNN/exe ends up pointing to an old inode and not the current inode of the executable.   This incorrect behavior of pidof causes a problem especially since the pid that squid stores in squid.pid is the one of the child process, the one that pidof doesn't show, so pidof can't be used to find the process matching the pid listed in squid.pid.

I have attached a patch that makes it work, by doing readlink on /proc/NNNN/exe and doing a stat of that file instead of the exe path if it can.

The one thing I haven't fully figured out is why /sbin/pidof doesn't break on an RHEL5-based system in the same situation.  I don't see enough of a history of the source code in the sysvinit svn repository to see if it used to be that way in the primary sysvinit repository or if somewhere along the line somebody at Redhat put in a patch for RHEL5 that got lost in RHEL6.  I did verify with strace that the RHEL5-based sysvinit (version SysVinit-2.86-17.el5) is doing two readlinks that return /usr/sbin/squid, but the unpatched sysvinit-2.88dsf is not.

- Dave

Dave Dykstra <dwd>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #24557:  pidof-prelink-2.patch added by dwd (1KiB - application/octet-stream)
file #24538:  pidof-prelink.patch added by dwd (586B - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by newguy (Posted a comment)
  • -email is unavailable- added by lnykryn (Posted a comment)
  • -email is unavailable- added by dwd (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-02-28 newguy StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2012-03-19 wfink StatusNone Ready For Test
    2012-03-16 wfink Assigned toNone wfink
    2011-12-09 dwd Attached File- Added pidof-prelink-2.patch, #24557
    2011-12-05 dwd Attached File- Added pidof-prelink.patch, #24538

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code