shmctl man differs from kernel operation

Bug #62858 reported by Hank Dietz
4
Affects Status Importance Assigned to Milestone
manpages (Ubuntu)
Expired
Undecided
Unassigned

Bug Description

shmget() allows creation of shared memory segments with key_t key values that can be used by other processes to identify them. Traditionally, under Linux the shmctl() call could be used to caused a shared memory segment to destroy itself upon the last detachment by IPC_RMID, and this would have no other impact on the operation of the shared memory segment. This behavior of IPC_RMID is documented (in the shmctl man page) and is quite useful. However, setting IPC_RMID in recent Linux kernels has the important side effect of CHANGING the key associated with the segment to 0 (aka, IPC_PRIVATE). Ideally, this side effect should be removed from the kernel, but the kernel folks seem unlikely to do this (the new behavior was mentioned in a discussion). Thus, I suggest fixing the shmctl man page to mention this strange behavior in the discussion of IPC_RMID: after "IPC_STAT will be set." add the phrase "The segment key may be changed to IPC_PRIVATE as a side effect of IPC_RMID."

Revision history for this message
RJ Clay (rjclay) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. You reported this bug a while ago and there hasn't been any activity in it recently. We were wondering is this still an issue for you? Can you try with latest Ubuntu release? Thanks in advance.

Changed in manpages:
status: New → Incomplete
Revision history for this message
Daniel T Chen (crimsun) wrote :

Confirmed in 8.04, 8.10, and Debian unstable (3.07-1).

Changed in manpages:
status: Incomplete → Confirmed
Revision history for this message
Michael Kerrisk (mtk-manpages) wrote :

@David T Chen
David, how did you confirm this bug? The reporter talks of behavior having been changed (though as far as I can see, nothing has changed) -- did you confirm that behavior was different in an earlier kernel version?

Revision history for this message
Michael Kerrisk (mtk-manpages) wrote :

@Hans Dietz:

Hans,

I'm the upstream man-pages maintainer, and I took a look at this bug report to see if I should fix anything upstream.

You wrote:

[[
However, setting IPC_RMID in recent Linux kernels has the important side effect of CHANGING the key associated with the segment to 0 (aka, IPC_PRIVATE). Ideally, this side effect should be removed from the kernel, but the kernel folks seem unlikely to do this (the new behavior was mentioned in a discussion). Thus, I suggest fixing the shmctl man page to mention this strange behavior in the discussion of IPC_RMID: after "IPC_STAT will be set." add the phrase "The segment key may be changed to IPC_PRIVATE as a side effect of IPC_RMID."
]]

Your report suggests ("in recent kernels") that the kernel's behavior changed at some point. As far as I can see, there has been no change from 2.2 through to 2.6.31-rc with respect to this particular point. The key was always changed to IPC_PRIVATE, so that some program could not do a shmget() with the original key in order to obtain the ID of the now deleted object. As far as I know, all other Unix systems take analogous steps (to prevent a deleted object being re-used).

What is unusual about the Linux implementation (i.e., different from other systems) is this behavior described in the http://www.kernel.org/doc/man-pages/online/pages/man2/shmat.2.html man page:

       On Linux, it is possible to attach a shared memory segment even if it is
       already marked to be deleted. However, POSIX.1-2001 does not specify this
       behavior and many other implementations do not support it.

However, again, this behavior is unchanged in Linux 2.2 to 2.6.31-rc, as far as I can see.

So, at this point, it doesn't look like any change needs to be made to the man page. But, I await further input.

Thanks,

Michael

Stéphane Aulery (lkppo)
Changed in manpages (Ubuntu):
status: Confirmed → Incomplete
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for manpages (Ubuntu) because there has been no activity for 60 days.]

Changed in manpages (Ubuntu):
status: Incomplete → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

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