Commit Graph

59 Commits

Author SHA1 Message Date
Michael Kerrisk fc15ae54b9 tfix/wfix 2007-07-10 03:57:50 +00:00
Michael Kerrisk 682edefb1b ffix 2007-06-22 17:16:20 +00:00
Michael Kerrisk 988db66164 strip trailing white space 2007-06-21 22:55:04 +00:00
Michael Kerrisk 8bd58774dc Formatted signal names 2007-06-21 05:38:48 +00:00
Michael Kerrisk 0e1ad98ccf Updated FIXMEs 2007-06-13 21:48:16 +00:00
Michael Kerrisk 75b94dc35c Change "e.g. " to "e.g., ", or in some cases, "for example, ".
Change "i.e. " to i.e.., ", or in some cases, "that is, ".
2007-06-08 11:56:22 +00:00
Michael Kerrisk d9bfdb9c21 Convert to American spelling conventions 2007-06-08 09:56:56 +00:00
Michael Kerrisk d9343c5c13 Removed version number from .TH line 2007-05-30 05:36:26 +00:00
Michael Kerrisk d880b21c28 Small rewrite of SEE ALSO text pointing to Document/* in kernel source. 2007-05-27 12:13:11 +00:00
Michael Kerrisk a3c945b37d Added .\" comment about l_sysid. 2007-05-27 11:52:46 +00:00
Michael Kerrisk 87eca6b7b3 Remove misleading text about setting O_ASYNC when calling
open(); one must use fcntl() F_SETFL for this task.
2007-05-21 06:34:45 +00:00
Michael Kerrisk a1d5f77cc8 Reordered sections to be more consistent, in some cases renaming
sections or shifting paragraphs between sections.
2007-05-18 16:06:42 +00:00
Michael Kerrisk 7c93fec03d Wrapped source lines 2007-05-12 12:58:31 +00:00
Michael Kerrisk 0bfa087b03 Add section numbers to references to other pages 2007-05-11 23:07:02 +00:00
Michael Kerrisk c13182efa3 Wrapped long lines, wrapped at sentence boundaries; stripped trailing
white space.
2007-04-12 22:42:49 +00:00
Michael Kerrisk cf0a9ace57 ffix 2007-04-05 12:36:57 +00:00
Michael Kerrisk 75b48e9d74 Various fixes to CONFORMING TO 2006-12-17 01:34:44 +00:00
Michael Kerrisk a7fadb5558 Updated CONFOMRING TOs and/or standards references. 2006-08-04 12:39:17 +00:00
Michael Kerrisk 97c1eac86f Updated CONFORMING TO section 2006-08-03 13:57:17 +00:00
Michael Kerrisk cb1c9135d0 ffix 2006-08-03 03:02:31 +00:00
Michael Kerrisk ace17ecf07 Explicitly mention term "dnotify" in discussion of F_NOTIFY. 2006-06-05 01:51:44 +00:00
Michael Kerrisk 6883b3e731 Changed copyright commnents to add 'and' in some cases 2006-05-22 23:52:24 +00:00
Michael Kerrisk a8e7c990dc Rename ftm.7 to feature_test_macros.7 2006-05-15 09:13:10 +00:00
Michael Kerrisk 50e5322c85 Added SEE ALSO reference to ftm.7 2006-04-21 06:49:34 +00:00
Michael Kerrisk 00d7bbcfbf Expanded discussion of mandatory locking. 2006-03-31 21:14:41 +00:00
Michael Kerrisk 1130df606b Amend copyright notices, in particular those where I had significant
authorship.
2006-02-15 23:15:29 +00:00
Michael Kerrisk 3adb464791 tfix 2006-02-13 22:46:01 +00:00
Michael Kerrisk 8548d8e240 Under ERRORS: Separate out EAGAIN error for locking mmaped files. 2006-02-10 20:29:38 +00:00
Michael Kerrisk c533af9d27 Reformatted FIXMEs 2006-02-10 18:46:42 +00:00
Michael Kerrisk 92057f4dbc Updated FIXMEs 2006-02-08 09:44:13 +00:00
Michael Kerrisk 1363cf9511 Added xref under dnotify description to inotify.7. 2006-02-06 22:43:15 +00:00
Michael Kerrisk 68b93ce208 Small wording changes 2006-02-02 03:25:50 +00:00
Michael Kerrisk b2216ffee6 Clarified parts of the discussion of file leases,
noting effect of open(O_NONBLOCK), interruption
by signal handler, or termination by signal in lease breaker.
In response to Debian bug 339037.
2005-11-17 14:56:41 +00:00
Michael Kerrisk 31e9a9ec99 Change itacised function names and page xrefs to bold 2005-11-02 11:34:24 +00:00
Michael Kerrisk 35e21ba7ca Formatting fixes 2005-10-19 13:48:50 +00:00
Michael Kerrisk a7a0588842 Further improvements to recently changed leases text 2005-10-13 09:30:54 +00:00
Michael Kerrisk 1a6d974a99 Since kernel 2.6.10, a read lease can only be placed on a
file descriptor that is opened read-only.
See the following LKML thread of Aug 2005
("fcntl(F GETLEASE) semantics??"):
http://marc.theaimsgroup.com/?l=linux-kernel&m=112371777712197&w=2
http://marc.theaimsgroup.com/?l=linux-kernel&m=112374818213000&w=2
http://marc.theaimsgroup.com/?l=linux-kernel&m=112376335305284&w=2
http://marc.theaimsgroup.com/?l=linux-kernel&m=112377294030092&w=2
2005-10-12 14:54:00 +00:00
Michael Kerrisk b14d4aa5b8 Classical BSD versions are now always named x.yBSD (formerly
there was a mix of x.yBSD and BSD x.y).
2005-07-18 15:05:56 +00:00
Michael Kerrisk 880f5b4bc3 Consistent use of "set-user-ID" and "set-group-ID". 2005-07-18 14:25:42 +00:00
Michael Kerrisk 8c383102d0 hyphen/dash fixes 2005-07-07 08:27:03 +00:00
Michael Kerrisk 8c45053412 s/the the/the/ 2005-07-05 13:50:51 +00:00
Michael Kerrisk 0847872439 Minor wording changes 2005-06-27 14:42:40 +00:00
Michael Kerrisk 98740ac7a7 Formatting changes 2005-06-24 10:53:06 +00:00
Michael Kerrisk 72da38ce1d Minor wording changes 2005-06-22 10:59:21 +00:00
Michael Kerrisk 1864073923 Added FIXME 2005-06-22 10:56:11 +00:00
Michael Kerrisk cff88e99ab Consistent use of terms "open file description",
"file status flags", and "file decriptor flags"
Some rewriting of discussion of file descriptor flags
Under F_DUPFD, replaced some text duplicated in dup.2 with a cross ref to dup.2
Minor wording and formatting fixes
2005-06-22 09:53:58 +00:00
Michael Kerrisk 8729177b44 global edit s/ -1/ \\-1/g 2005-06-15 14:10:23 +00:00
Michael Kerrisk 9d2a7b1f62 Noted F_SETOWN bug for socket file descriptor in Linux 2.4 and earlier.
Added text on permissions required to send signal to owner.

====

Hello Johannes,

> Betreff: Inaccuracy of fcntl man page
> Datum: Mon, 2 May 2005 20:07:12 +0200

Thanks for yor note.

Sorry for the delay in getting back to you.  I needed to find time 
to set aside to look at the details.  Now I've finally got there.

> I have attached a simple program 

Thanks -- a little program is always helpful.

> that uses the fcntl system call in order
> to kill an arbitrary process of the same user.
> According to the fcntl man page, fcntl(fd,F_SETOWN,pid) returns zero if 
> it has success.

Yes.

> If you strace the program while killing for exampe man running in another 
> terminal, you will see that man is killed, but fcntl(fd,F_SETOWN,pid)
> will return EPERM, 

I confirm that I see this problem in 2.4, with both Unix domain 
and Internet domain sockets.

> where you can only find a very confusing explanation 
> in the fcntl man page.

I'm not sure what explanation you mean here.  As far as I can 
tell, the manual page just doesn't cover this point.

> I have looked into the kernel source of 2.4.30 and found out, that 
> net/core/socket::sock_no_fcntl is the culprit if you use fcntl on Unix 
> sockets.

Yes, looks that way to me, as well,  And the 2.2 code looks 
similar.

> If pid is not your own pid or not your own process group, 
> the system call will return EPERM but will also set the pid 
> as you wanted to.

Yes.

> In the 2.6 kernel line, fcntl will react according the specification in
> the manual page.

Yes.

> If you also think, that one should clarify the return specification of 
> fcntl(fd,F_SETOWN,pid) or 2.4.x kernels, please tell me and I will 
> provide you with a patch for the manual page.

In fact I've written some new text under BUGS, which describes
the problem:

  In Linux 2.4 and earlier, there is bug that can occur  when  an
  unprivileged  process  uses  F_SETOWN to specify the owner of a
  socket file descriptor as a  process  (group)  other  than  the
  caller.   In this case, fcntl() can return -1 with errno set to
  EPERM, even when the owner process  (group)  is  one  that  the
  caller  has  permission to send signals to.  Despite this error
  return, the file descriptor owner is set, and signals  will  be
  sent to the owner.

Does that seem okay to you?

> Furthermore, it would be interseting to write there, what permissions 
> one need in order to send signals to processes via fcntl 

Good idea.  I added the following new text:

  Sending a signal to  the  owner  process  (group)  specified  by
  F_SETOWN  is  subject  to  the  same  permissions  checks as are
  described for kill(2), where the sending process is the one that
  employs F_SETOWN (but see BUGS below).

====


#define _GNU_SOURCE		/* needed to get the defines */
#include <fcntl.h>		/* in glibc 2.2 this has the needed
				   values defined */
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>


/**
 * Funnykill kills a program with fcntl
**/
int
main (int argc, char **argv)
{
  if (argc != 2)
    {
      fprintf (stderr, "Usage: funnykill <pid>\n");
      return 1;
    }

  int sockets[2];
  socketpair (AF_UNIX, SOCK_STREAM, 0, sockets);
  if (fcntl (sockets[0], F_SETFL, O_ASYNC | O_NONBLOCK) == -1) 
      errMsg("fcntl-F_SETFL");
  if (fcntl (sockets[0], F_SETOWN, atoi (argv[1])) == -1) 
      errMsg("fcntl-F_SETOWN");
//  fcntl (sockets[0], F_SETOWN, getpid());
  if (fcntl (sockets[0], F_SETSIG, SIGKILL) == -1) 
      errMsg("fcntl-_FSETSIG");
  write (sockets[1], "good bye", 9);
}
2005-05-20 12:11:25 +00:00
Michael Kerrisk 704a18f06d Fixed typos and spelling mistakes 2005-04-18 13:35:29 +00:00
Michael Kerrisk 7502db97e2 Fix typo in 2.02 release 2005-04-14 09:24:26 +00:00