Commit Graph

8147 Commits

Author SHA1 Message Date
Michael Kerrisk 0ff184704f [Further notes on that F_GETOWN bug]
Hi Andries,

[Just for my own  reference, I reinclude the pointer to Philippe 
Troin's patch
http://marc.theaimsgroup.com/?l=linux-kernel&m=108380640603164&w=2
]

> > > Except of course for fcntl(fd, F_GETOWN) where the owner is a
> > > (negative) process group... If the owning process group has a "low
> > > enough" PGID, it collides with errors and glibc reports an error and
> > > sets errno to -PGID. One might argue that in this instance, that the
> > > BSD's overloading of the pid field with pgids is at fault, but the 
> > > bug
> > > still remains :-)
> > 
> > I believe that practically speaking this is a non-issue.  The 
> > lowest PID / PGID that can be allocated to a process other than 
> > init or a kernel thread is 300.  (RESERVED_PID in kernel/pid.c 
> > in 2.6, details differ, but same limit in <= 2.4.)
> 
> Hmm. RESERVED_PIDS is used as starting value after overflow,
> not as a starting value at the beginning. I think you are mistaken.

Hmm -- yes.  And I was in any case assuming the notion
of a process that might do an F_SETOWN assigning
its own PGID to the socket -- but that might not be so.

And I was overlooking a comment in the fs/fcntl.c 
sources that reiterates the point:

        case F_GETOWN:
                /*
                 * XXX If f_owner is a process group, the
                 * negative return value will get converted
                 * into an error.  Oops.  If we keep the
                 * current syscall conventions, the only way
                 * to fix this will be in libc.
                 */
                err = filp->f_owner.pid;
                force_successful_syscall_return();
                break;

And now I've actually created the error in userland code.
It seems that whenever the -PGID retrieved by F_GETOWN is 
smaller than 4096, then it is interpreted as an error.

Now I see the relevant code in 
sysdeps/unix/sysv/linux/i386/sysdep.h:

==
/* Linux uses a negative return value to indicate syscall errors,
   unlike most Unices, which use the condition codes' carry flag.

   Since version 2.1 the return value of a system call might be
   negative even if the call succeeded.  E.g., the `lseek' system call
   might return a large offset.  Therefore we must not anymore test
   for < 0, but test for a real error by making sure the value in %eax
   is a real error number.  Linus said he will make sure the no syscall
   returns a value in -1 .. -4095 as a valid result so we can savely
   test with -4095.  */

[...]
    DO_CALL (syscall_name, args);
    cmpl $-4095, %eax;          
    jae SYSCALL_ERROR_LABEL;    

==

Ugh.
2004-12-10 16:28:25 +00:00
Michael Kerrisk 7c3b0e957d noted F_GETOWN bug after suggestion from aeb. 2004-12-10 16:26:28 +00:00
Michael Kerrisk 527d993350 After a note from Vasya Pupkin, I added <errno.h> to the SYNOPSIS
of several Section 2 pages using the _syscallN() macros.  

    In addition:
        -- erroneous semicolons at the end of _syscallN() were removed
           on various pages.

	-- types such as "uint" in syscalN() declarations were changed
	   to "unsigined int", etc.

	-- various other minor breakages in the synopses were fixed.
2004-12-10 09:03:08 +00:00
Michael Kerrisk 25743dd704 Removed erroneous semicolons at the end of _syscall() instances in
SYNOPSIS of several section 2 man pages.
2004-12-10 07:49:56 +00:00
Michael Kerrisk e1c77b3901 added SI_TKILL + other minor changes 2004-12-09 10:26:18 +00:00
Michael Kerrisk 1c1e15ed85 Martin Pool (and mtk) -- added O_NOATIME 2004-12-08 16:41:10 +00:00
Michael Kerrisk 1a956089b0 Eric Estievenart <eric.estievenart@free.fr>
Note that MAP_FIXED replaces existing mappings
2004-12-08 13:47:41 +00:00
Michael Kerrisk e263839c06 In Linux 2.6, the return value of times() changed 2004-12-08 09:26:32 +00:00
Michael Kerrisk 8b6aacb004 tweak RLIMIT_SIGPENDING details 2004-12-07 17:57:48 +00:00
Michael Kerrisk 4bdd9f775b tweak RLIMIT_SIGPENDING details 2004-12-07 17:30:27 +00:00
Michael Kerrisk 1c287bbf01 fix typo 2004-12-06 13:39:28 +00:00
Michael Kerrisk e6c5832f19 Rewrote discussion on RLIMIT_MEMLOCK to incorporate kernel 2.6.9 changes.
Added note on RLIMIT_CPU error in older kernels.
Added RLIMIT_SIGPENDING
2004-12-03 16:06:22 +00:00
Michael Kerrisk 93e4c37f65 more fixes to synopsis 2004-12-02 09:25:55 +00:00
Michael Kerrisk b4c0e1cb44 Fixed headers listed in synopsis, after message from Vasya Pupkin 2004-12-01 15:19:22 +00:00
Michael Kerrisk 3aadaa6594 noted buggy mlock() half RAM check in 2.4.x; some rewording of discussion of MCL_FUTURE 2004-12-01 09:43:35 +00:00
Michael Kerrisk 7f3256956e Changed wording of sentence under NOTES describing when signals can be sent to init. 2004-11-30 17:47:32 +00:00
Michael Kerrisk 8ce20bf7ba These are now just links; their content has been consoldiated intomlock.2 2004-11-25 14:40:17 +00:00
Michael Kerrisk 8176b81ab6 Consolidated mlock.2, munlock.2, mlockall.2, and munlockall.2 material into single page to eliminate duplicated material; updated notes for 2.6.9 changes in permissions and limist on memory locking 2004-11-25 14:39:43 +00:00
Michael Kerrisk 583d5fd39a Notes on 2.6.9 RLIMIT_MEMLOCK changes 2004-11-25 13:38:17 +00:00
Michael Kerrisk 83cd3686ed Added cross-ref to setrlimit(2) concerning memory locking limits 2004-11-25 13:36:04 +00:00
Michael Kerrisk 102f39b88e 2.4 limits locks to half of physical mem; MCL_FUTURE bug note 2004-11-25 13:34:08 +00:00
Michael Kerrisk c1832fd1eb 2.4 limits locks to half of physical me 2004-11-25 13:33:38 +00:00
Michael Kerrisk 3b85198195 removed stray #endif; formatting fix 2004-11-25 07:50:05 +00:00
Michael Kerrisk 3d3886497f CAP_IPC_LOCK is not required for SHM_UNLOCK since kernel 2.6.9 2004-11-23 10:06:02 +00:00
Michael Kerrisk f8c31d602c CLD_CONTINUED is supported since Linux 2.6.9 2004-11-19 17:35:57 +00:00
Michael Kerrisk 197362df19 Removed text on ignoring SIGCHL; replaced with pointer to sigaction.2 2004-11-19 17:34:32 +00:00
Michael Kerrisk b7769f32c5 Updated discussion for POSIX.1-2001 and SIGCHLD and sa_flags; formatting fixes 2004-11-18 13:37:14 +00:00
Michael Kerrisk 5775745fa4 Added FIXME -- the return value of times() has changed in Linux 2.6 -- what is it? 2004-11-16 19:38:07 +00:00
Michael Kerrisk 4c926acf03 Minor formatting changes 2004-11-16 17:08:25 +00:00
Michael Kerrisk 81841f39af SIGCHLD non-conformance was fixed in 2.6.9 2004-11-16 16:59:09 +00:00
Michael Kerrisk e3a887db90 split out from getrlimit.2; noted that SIGCHLD non-conformance was fixed in 2.6.9 2004-11-16 16:58:54 +00:00
Michael Kerrisk 0fc46b5a65 split getrusage(2) into own page; other minor changes 2004-11-16 16:57:47 +00:00
Michael Kerrisk d3b2ef5de2 Added waitid(); added SA_NOCLDSTOP; updated SA_NOCLDWAIT; much other text rewritten 2004-11-11 14:40:35 +00:00
Michael Kerrisk fe4992a761 Major rewrite; removed duplicated text, replacing with pointers to wait.2 2004-11-11 14:39:29 +00:00
Michael Kerrisk f2351505cb Rewrote this page, removing much duplicated information
and replacing with pointers to wait.2
2004-11-11 14:17:30 +00:00
Michael Kerrisk 84b13f1e40 Minor changes to SEE ALSO 2004-11-11 14:13:28 +00:00
Michael Kerrisk 1cbdceb181 Added SIGCONT under SA_NOCLDSTOP; added SA_NOCLDWAID; other minor changes 2004-11-11 14:09:54 +00:00
Michael Kerrisk 5d4a590c7d new link to wait.2 2004-11-11 14:08:30 +00:00
Michael Kerrisk 2c8d1c7d5e changed spelling of "super-user" to "superuser" 2004-11-10 18:17:26 +00:00
Michael Kerrisk 9907019a39 Formatting & lang clean-ups; added data structure defns; added SHM_LOCKED & SHM_DEST test 2004-11-10 17:27:34 +00:00
Michael Kerrisk 70d0e5ef63 Formatting & lang clean-ups; added data structure defns 2004-11-10 17:27:07 +00:00
Michael Kerrisk f998edca67 Formatting & lag clean-ups; changed sentence regarding attachment of segments marked for destruction 2004-11-10 17:25:44 +00:00
Michael Kerrisk fe1c5199cc Formatting & lag clean-ups; added /proc file notes 2004-11-10 17:24:20 +00:00
Michael Kerrisk c952e22670 Formatting & lag clean-ups; added /proc file notes 2004-11-10 17:23:19 +00:00
Michael Kerrisk 6891999e31 Patches from Martin Schulze <joey@infodeom.org> 2004-11-03 15:32:55 +00:00
Michael Kerrisk 305a0578bf Global change of email address for MTK (now: mtk-manpages@gmx.net) 2004-11-03 14:43:40 +00:00
Michael Kerrisk fea681dafb Import of man-pages 1.70 2004-11-03 13:51:07 +00:00