Commit Graph

5998 Commits

Author SHA1 Message Date
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 ca596a72e1 dlinfo.3: tfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-12 14:44:19 +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 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 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 e78f6e739b cmsg.3: tfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-07-06 15:33:17 +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 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
Lucas Werkmeister 28131cd994 usleep.3: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-06-21 19:18:12 +02:00
Matthew Kilgore 85bbb2a253 strcpy.3: Fix example code for strncpy, which could pass an incorrect length
The example code currently passes `buflen - 1` to `strncpy`,
however the length parameter to `strncpy` is `size_t`, which is
unsigned.  This means that when `buflen` is zero, the cast of `-1`
to unsigned will result in passing `UINT_MAX` as the length.
Obviously, that would be incorrect and could cause `strncpy` to
write well beyond the buffer passed.

The easy solution is to wrap the whole code in the `buflen > 0`
check, rather then just the part of the code that applies the null
terminator.

Signed-off-by: Matthew Kilgore <mattkilgore12@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-06-10 13:36:46 +02:00
Mike Frysinger 946bdf7207 exit.3: Note wider sysexits.h availability
Since the BSD header has been imported to other C libraries (including
glibc), note that here so people know it isn't BSD-specific.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-05-31 21:34:32 +02:00
Michael Kerrisk 65c3312c6d putenv.3: wfix
Reported-by: James Weigle <jtweigle@uchicago.edu>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-05-28 10:58:45 +02:00
Michael Kerrisk ff2c46188e termios.3: Minor tweaks to Eugene's text
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-05-02 12:46:09 +02:00
Eugene Syromyatnikov 499eb81f26 termios.3: Note an XTABS alpha issue
* man3/termios.3 (.B TABDLY): Reference to the BUGS section.
(.SH BUGS): New section.  Describe an issue on alpha where the XTABS
macro was defined to a value outside TABDLY mask.

Signed-off-by: Eugene Syromyatnikov <evgsyr@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-05-02 12:40:49 +02:00
Michael Kerrisk a706f0e022 Removed trailing white space at end of lines 2018-04-30 17:54:16 +02:00
Michael Kerrisk 09b8afdc04 execve.2, fallocate.2, getrlimit.2, io_submit.2, membarrier.2, mmap.2, msgget.2, open.2, ptrace.2, readv.2, semget.2, shmget.2, shutdown.2, syscall.2, wait.2, wait4.2, crypt.3, encrypt.3, fseek.3, getcwd.3, makedev.3, pthread_create.3, puts.3, tsearch.3, elf.5, filesystems.5, group.5, passwd.5, sysfs.5, mount_namespaces.7, posixoptions.7, time.7, unix.7, vdso.7, xattr.7, ld.so.8: tstamp
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-30 17:41:31 +02:00
Michael Kerrisk ebd10b39cb keyctl.2, sincos.3: spfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-27 14:48:33 +02:00
Michael Kerrisk 29c0586f51 bpf.2, sched_setattr.2, crypt.3, elf.5, proc.5, fanotify.7, feature_test_macros.7, sched.7: spfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-27 14:48:33 +02:00
Michael Kerrisk d2cb1ef1ac fallocate.2, keyctl.2, bzero.3: spfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-27 14:48:33 +02:00
Michael Kerrisk f019faae04 fseek.3: Improve EPIPE error text
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-19 15:00:04 +02:00
Michael Kerrisk f2e2bdc0eb fseek.3: ERRORS: EBADF should be ESPIPE
Reported-by: Andy Owen <andrew.owen@dolby.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-19 14:57:17 +02:00
Michael Kerrisk 924f766741 encrypt.3: Replace text that is duplicated in crypt(3) with a cross reference
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-13 21:23:28 +02:00
Michael Kerrisk 3f3eeb9ca0 crypt.3: tfix
Reported-by: Nikos Mavrogiannopoulos <nmavrogi@redhat.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-13 21:23:28 +02:00
Michael Kerrisk 8291a17bd6 crypt.3: Tweaks to Carlos O'Donell's patch
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-13 21:07:22 +02:00
Michael Kerrisk b2ca119e1a encrypt.3: srcfix: rewrap source lines
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-13 17:02:28 +02:00
Michael Kerrisk 419b9d89e6 crypt.3: srcfix: rewrap source lines
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-13 17:02:28 +02:00
Carlos O'Donell 629a86ecb7 crypt.3, encrypt.3: Add notes about _XOPEN_CRYPT
The distribution may choose not to support _XOPEN_CRYPT in the
case that the distribution has transitioned from glibc crypt to
libxcrypt.

Signed-off-by: Carlos O'Donell <carlos@redhat.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-13 17:02:28 +02:00
Michael Kerrisk 40b7acf14d getcwd.3: Minor tweaks to Carlos O'Donell's patch
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-12 13:49:40 +02:00
Michael Kerrisk c26d16c8de getcwd.3: srcfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-12 13:47:03 +02:00
Carlos O'Donell 294851f3fa getcwd.3: Mention that "(unreachable)" is no longer returned for glibc >= 2.27.
With glibc fix 52a713fdd0a30e1bd79818e2e3c4ab44ddca1a94 for
CVE-2018-1000001 (Sourceware BZ #22679) the implementation in the
just released glibc 2.27 has been changed such that instead of
returning "(unreachable)" the implementation now returns ENOENT
as it would have if the current directory had been unlinked.

I see that in 2015 the quirk was documented in commit
a2ac97c78b, and this is no longer
true with glibc 2.27, but may continue to be true in other C libraries,
so I reference NOTES from the paragraph in the central text.

Signed-off-by: Carlos O'Donell <carlos@redhat.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-12 13:44:51 +02:00
Michael Kerrisk 169d728330 pthread_create.3: Minor fix: reorder table items
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-05 20:12:18 +02:00
Michael Kerrisk 8efada9938 pthread_create.3: Minor tweaks to Frederic Brault's patch
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-05 20:12:18 +02:00
Frederic Brault af6e958b58 pthread_create.3: Note default thread stack size for several architectures
I am trying to fix a FIXME in the pthread_create.3 manpage.
It says info about default thread stack size should be put in
pthread_attr_setstacksize.3.

And pthread_attr_setstacksize.3 says "For details on the default
stack size of new threads, see pthread_create(3)".

So I list the default values for several architectures, starting
from glibc 2.12 (and still valid on current git glibc).

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-04-05 20:12:07 +02:00
Jann Horn f23ba9ce98 tsearch.3: tdelete() can return dangling pointers
POSIX says that deleting the root node must cause tdelete() to
return some unspecified non-NULL pointer. Glibc implements it by
returning a dangling pointer to the (freed) root node:

$ cat bogus_tdelete.c

static void *root = NULL;

static void *xmalloc(unsigned n) {
    void *p;
    p = malloc(n);
    if (!p)
        err(1, "malloc");
    return p;
}

static int compare(const void *pa, const void *pb) {
    if (*(int *) pa < *(int *) pb)
        return -1;
    if (*(int *) pa > *(int *) pb)
        return 1;
    return 0;
}

int main(void) {
    int *ptr;
    void *val, *parent;

    ptr = xmalloc(sizeof(int));
    *ptr = 1234;
    val = tsearch((void*)ptr, &root, compare);
    assert(*(int**)val == ptr);
    printf("root: %p\n", root);

    parent = tdelete((void*)ptr, &root, compare);
    printf("tdelete return value: %p; new root: %p\n", parent, root);

    return 0;
}
$ gcc -o bogus_tdelete bogus_tdelete.c -std=gnu99 -Wall
$ gdb ./bogus_tdelete
GNU gdb (GDB) 7.9-gg19
[...]
(gdb) break free
Function "free" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 1 (free) pending.
(gdb) run
Starting program: /usr/local/google/home/jannh/tmp/bogus_tdelete
[...]
root: 0x555555756030

Breakpoint 1, 0x00007ffff7ab54e0 in free () from [...]
(gdb) print (void*)$rdi
$1 = (void *) 0x555555756030
(gdb) cont
Continuing.
tdelete return value: 0x555555756030; new root: (nil)
[Inferior 1 (process 56564) exited normally]
(gdb) quit

Therefore, explicitly note that tdelete() may return bad pointers
that must not be accessed.

Signed-off-by: Jann Horn <jannh@google.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-03-27 22:29:10 +02:00
Jann Horn f119ba87ea tsearch.3: Clarify items vs nodes
The manpage claimed that tsearch() returns a pointer to a data
item. This is incorrect; tsearch() returns a pointer to the
corresponding tree node, which can also be interpreted as a
pointer to a pointer to the data item.

Since this API is quite unintuitive, also add a clarifying
sentence.

Signed-off-by: Jann Horn <jannh@google.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-03-27 22:25:29 +02:00
Michael Kerrisk 517b7ac44a makedev.3: Since glibc 2.28, <sys/types.h> no longer defines these macroa
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-02-19 18:39:15 +01:00
Michael Kerrisk 0512f57cea atexit.3: wfix
Reported-by: Robin Kuzmin <kuzmin.robin@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-02-09 07:00:17 +01:00
Mike Frysinger 724127aa2d put(3): fix formatting of trailing period
The period after the function call is incorrectly marked with bold.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-02-04 07:32:04 +01:00
Michael Kerrisk 8538a62b4c iconv.1, bpf.2, copy_file_range.2, fcntl.2, memfd_create.2, mlock.2, mount.2, mprotect.2, perf_event_open.2, pkey_alloc.2, prctl.2, read.2, recvmmsg.2, s390_sthyi.2, seccomp.2, sendmmsg.2, syscalls.2, unshare.2, write.2, errno.3, fgetpwent.3, fts.3, pthread_rwlockattr_setkind_np.3, fuse.4, veth.4, capabilities.7, cgroups.7, ip.7, man-pages.7, namespaces.7, network_namespaces.7, sched.7, socket.7, user_namespaces.7, iconvconfig.8: tstamp
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-02-02 07:38:54 +01:00
Michael Kerrisk a25748e649 pthread_mutexattr_setrobust.3: wfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-01-06 23:20:46 +01:00
Michael Kerrisk 41a64b30fc dl_iterate_phdr.3: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-01-06 23:16:04 +01:00
Michael Kerrisk 7de982f8af basename.3: wfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-01-06 23:15:08 +01:00
Michael Kerrisk 7ebb909a80 getnameinfo.3: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-01-06 23:03:46 +01:00
Michael Kerrisk 0335565faa resolver.3: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2018-01-06 22:51:26 +01:00