Commit Graph

19314 Commits

Author SHA1 Message Date
Michael Kerrisk bdf4703297 chroot.2: Mention /proc/[pid]/root
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-18 21:41:03 +02:00
Michael Kerrisk e06763febd statx.2: Library support for statx() was added in glibc 2.28
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-17 12:33:21 +02:00
Michael Kerrisk 3678dcc906 rename.2: glibc 2.28 adds library support for renameat2()
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-17 12:32:29 +02:00
Michael Kerrisk e5604914d7 cmsg.3: Remove unnecessary 'fdptr' intermediate variable in example code
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-17 12:26:29 +02:00
Michael Kerrisk 5af0f223d1 unix.7: Ancillary data forms a barrier when receiving on a stream socket
Thanks to a tip from Keith Packard:
https://keithp.com/blogs/fd-passing/
(Also verified by experiment.)

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-17 09:39:56 +02:00
Michael Kerrisk 5219daec26 unix.7: One must send at least one byte of real data with ancillary data
When sending ancillary data, at least one byte of real data should
also be sent.  This is strictly necessary for stream sockets
(verified by experiment). It is not required for datagram sockets
on Linux (verified by experiment), but portable applications
should do so.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-15 10:33:42 +02:00
Michael Kerrisk c0e56ed687 unix.7: Clarify treatment of incoming ancillary data if 'msg_control' is NULL
If no buffer is supplied for incoming ancillary data, then
the data is lost.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-15 10:33:32 +02:00
Michael Kerrisk 4564dd1fee unix.7: If the buffer to receive SCM_RIGHTS FDs is too small, FDs are closed
If the ancillary data buffer for receiving SCM_RIGHTS file
descriptors is too small, then the excess file descriptors are
automatically closed in the receiving process. Verified by
experiment.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-15 10:16:49 +02:00
Michael Kerrisk b65f4c691d unix.7: tfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-15 10:16:49 +02:00
Michael Kerrisk 879962006f unix.7: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-15 09:50:30 +02:00
Michael Kerrisk ba9fc3e1b2 send.2: tfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-15 08:59:08 +02:00
Michael Kerrisk 418dd92c03 recv.2: tfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-15 08:58:37 +02:00
Michael Kerrisk 3ef2a133bf mount.2: Mention /proc/PID/mountinfo
Many people are unaware of the /proc/PID/mountinfo file. Provide
a helpful clue here.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-13 07:14:33 +02:00
Michael Kerrisk 93f5b0f8f4 mount_namespaces.7: SEE ALSO: add findmnt(8)
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-13 07:08:28 +02:00
Michael Kerrisk ca596a72e1 dlinfo.3: tfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-12 14:44:19 +02:00
Michael Kerrisk 400388b54b seccomp.2: wfix (to make it clearer at that seccomp affects threads)
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-11 08:17:30 +02:00
Michael Kerrisk f565c3ee3e cmsg.3: Note that CMSG_FIRSTHDR can return NULL
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-10 07:14:50 +02:00
Michael Kerrisk 5b5cb19580 unix.7: When sending ancillary data, only one item of each type may be sent
Verified by experiment and reading the source code (although
the SCM_RIGHTS case is not so clear to me in the source code).

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-10 07:14:50 +02:00
Michael Kerrisk 52900faab3 unix.7: tfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-10 07:14:50 +02:00
Michael Kerrisk 311bf2f694 unix.7: Minor wording fixes
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-10 07:14:50 +02:00
Michael Kerrisk 05bf3361a6 unix.7: grfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-10 07:14:50 +02:00
Michael Kerrisk f8d958aa3d cmsg.3: wfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-10 07:14:50 +02:00
Michael Kerrisk cc94a55964 cmsg.3: Remove out of place mention of MSG_CTRUNC
This detail is covered in recvmsg(2), and now also in unix(7).

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-10 07:14:50 +02:00
Michael Kerrisk 86ce931e7c recv.2: wfix: s/data were/data was/
Majority usage in English sometime ago decided that "data" is
a singular noun.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-10 07:14:50 +02:00
Michael Kerrisk ca16e00db8 cmsg.3: Explain zero-initialization requirement for CMSG_NXTHDR()
When initializing a new buffer (e.g., that will be sent with
sendmsg(2)), that buffer must first be zero-initialized to
ensure the correct operation of CMSG_NXTHDR().

Verified by experiment, and also by inspection of the glibc
source code:

  _EXTERN_INLINE struct cmsghdr *
  __NTH (__cmsg_nxthdr (struct msghdr *__mhdr, struct cmsghdr *__cmsg))
  {
    if ((size_t) __cmsg->cmsg_len < sizeof (struct cmsghdr))
      /* The kernel header does this so there may be a reason.  */
      return (struct cmsghdr *) 0;

[1] __cmsg = (struct cmsghdr *) ((unsigned char *) __cmsg
                                   + CMSG_ALIGN (__cmsg->cmsg_len));
    if ((unsigned char *) (__cmsg + 1) > ((unsigned char *) __mhdr->msg_control
                                          + __mhdr->msg_controllen)
[2]     || ((unsigned char *) __cmsg + CMSG_ALIGN (__cmsg->cmsg_len)  // <---
            > ((unsigned char *) __mhdr->msg_control + __mhdr->msg_controllen)))
      /* No more entries.  */
      return (struct cmsghdr *) 0;
    return __cmsg;
  }

At point [1], __cmsg has been updated to point to the next
cmsghdr. The subsequent check at [2] relies on 'cmsg_len'
in the next cmsghdr having some "sensible" value (e.g., 0).
See also https://stackoverflow.com/questions/27601849/cmsg-nxthdr-returns-null-even-though-there-are-more-cmsghdr-objects

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-10 07:14:50 +02:00
Michael Kerrisk c87721467e unix.7: Note behavior if buffer to receive ancillary data is too small
If the buffer supplied to recvmsg() to receive ancillary data is
too small, then the data is truncated and the MSG_CTRUNC flag is
set.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-08 21:13:08 +02:00
Michael Kerrisk 13600496d3 unix.7: Enhance the description of SCM_RIGHTS
The existing description is rather thin. More can be said.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-08 10:57:27 +02:00
Michael Kerrisk 8bdcf4bf81 unix.7: There is a limit on the size of the file descriptor array for SCM_RIGHTS
The limit is defined in the kernel as SCM_MAX_FD (253).

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-08 10:38:44 +02:00
Michael Kerrisk f1081bdc42 unix.7: Fix a minor imprecision in description of SCM_CREDENTIALS
To spoof credentials requires privilege (i.e., capabilities),
not UID 0.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-08 10:21:43 +02:00
Michael Kerrisk b66d5714b1 unix.7: grfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-08 10:20:52 +02:00
Michael Kerrisk bdef802116 unix.7: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-08 10:20:32 +02:00
Michael Kerrisk e78f6e739b cmsg.3: tfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-06 15:33:17 +02:00
Michael Kerrisk ae636827e6 proc.5: Fix description of /proc/PID/* ownership to account for user namespaces
Starting in Linux 4.11, if the process dumpable attribute is
not 1 and the process resides in a noninitial namespaces that
has valid mappings for UID 0 and GID 0, then the ownership of
/proc/PID/* is made the same as the root IDs of the namespace.

Determined by inspection of fs/proc/base.c
See also the following kernel commit:

    commit 68eb94f16227336a5773b83ecfa8290f1d6b78ce
    Author: Eric W. Biederman <ebiederm@xmission.com>
    Date:   Tue Jan 3 10:23:11 2017 +1300

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-05 18:38:14 +02:00
Michael Kerrisk e96ad1fd45 proc.5: Minor rewording
In preparation for next change

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-05 18:38:14 +02:00
Michael Kerrisk eada5570b0 proc.5: Setting dumpable to 1 reverts ownership of /proc/PID/* to effective IDs
The statement that resetting the dumpable attribute of a process
to 1 causes the ownership of files to revert the process's real
IDs looked suspect. And indeed it is at odds with the code in
fs/proc/base.c::task_dump_owner() (Linux 4.16 sources).
Further verified with a quick test that resetting dumpable to 1
causes the ownership of /proc/PID/* files to revert to the
process's effective IDs. Mea culpa for the original mistake.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-05 18:37:54 +02:00
Michael Kerrisk fb49322d22 proc.5: Minor rewording
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-05 11:35:48 +02:00
Michael Kerrisk b7b0f18926 malloc.3: Note that calloc() detects overflow when multiplying its arguments
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-04 10:03:01 +02:00
Michael Kerrisk d4f4d3f63f reallocarray.3: New link to malloc(3)
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-04 09:46:06 +02:00
Michael Kerrisk 422c110ccb keyctl.2: srcfix: add FIXME
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-02 15:05:12 +02:00
Michael Kerrisk 2c77e8de08 capabilities.7: Note that v3 security.attributes are transparently created/retrieved
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-02 09:59:21 +02:00
Michael Kerrisk 00ae99b028 capabilities.7: Fix some imprecisions in discussion of namespaced file capabilities
The file UID does not come into play when creating a v3
security.capability extended attribute.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-01 11:42:13 +02:00
Michael Kerrisk 9b2c207a33 capabilities.7: wfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-01 11:42:13 +02:00
Michael Kerrisk c281d0505d capabilities.7: wfix
Fix some confusion between "mask" and "extended attribute"

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-01 11:42:13 +02:00
Michael Kerrisk 54254ef33a capabilities.7: srcfix: Removed FIXME
No credential match of file UID and namespace creator UID
is needed to create a v3 security extended attribute.

Verified by experiment using my userns_child_exec.c and
show_creds.c programs (available on http://man7.org/tlpi/code):

    $ sudo setcap cap_setuid,cap_dac_override=pe \
            ./userns_child_exec
    $ ./userns_child_exec -U -r setcap cap_kill=pe show_creds
    $ ./userns_child_exec -U -M '0 1000 10' -G '0 1000 1' \
            -s 1 ./show_creds
    eUID = 1;  eGID = 0;  capabilities: = cap_kill+ep

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-01 11:42:07 +02:00
Michael Kerrisk 737002259f putenv.3: Note a glibc extension: putenv("NAME") removes an environment variable
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-06-27 09:53:55 +02:00
Michael Kerrisk 590ba7e5d0 open_by_handle_at.2, ctermid.3, getcwd.3, proc.5: Wording fix: prefer "pathname" over "path" 2018-06-26 06:47:26 +02:00
Michael Kerrisk 4b18e69ccb getcwd.3: Add details on the getcwd() syscall and how it used by libc functions
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-06-26 06:47:26 +02:00
Michael Kerrisk 12e5ca8bea getcwd.3: Rework text on use of getcwd() system call
Make it cleared that all of the library functions
described on this page will use the getcwd() system call
if it is present. (The text previously implied that only
the getcwd() library function made use of the system call,
but looking in the glibc source code shows that all of the
functions make use of a generic implementation (__getcwd())
that uses the system call if it is present.)

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-06-26 06:12:38 +02:00
Michael Kerrisk 27681259e9 getcwd.3: Reorder the text describing "(unreachable)" being returned by getcwd()
The existing text on some of the oddities of the Linux getcwd()
implementation was placed somewhat obtrusively in the DESCRIPTION.
Shift the text to NOTES, and at the same time move the related
discussion of glibc nonconformance to POSIX into BUGS.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-06-26 06:05:55 +02:00
Michael Kerrisk ffea2c14f2 capabilities.7: wfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-06-24 08:54:17 +02:00