Commit Graph

8147 Commits

Author SHA1 Message Date
Michael Kerrisk 459fe99546 mount.2: Describe the concept of "parent mounts"
Reported-by: Reid Priedhorsky <reidpr@lanl.gov>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-10-08 17:26:51 +02:00
Michael Kerrisk e0e0ba7d01 mount.2: tfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-10-08 17:23:20 +02:00
Michael Kerrisk dd858bfd5e mount.2: Rework the text on mount namespaces a little
Eliminate the term "Per-process namespaces" and add a reference
to mount_namespaces(7).

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-10-08 16:44:58 +02:00
Michael Kerrisk 5d3bcce72d mount.2: wfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-10-08 16:44:58 +02:00
Michael Kerrisk 632940d96d mount.2: NOTES: add subsection heading for /proc/[pid]/{mounts,mountinfo}
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-10-08 16:44:58 +02:00
Michael Kerrisk 93cc3b3827 pivot_root.2: Simplify pivot_root(".", ".") example
Eric Biederman notes that the change in commit f646ac88ef was
not strictly necessary for this example, since one of the already
documented requirements is that various mount points must not have
shared propagation, or else pivot_root() will fail. So, simplify
the example.

Reported-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-10-07 14:02:42 +03:00
Michael Kerrisk c6ed23c5da perf_event_open.2: SEE ALSO: add Documentation/admin-guide/perf-security.rst
Reported-by: Alexey Budankov <alexey.budankov@linux.intel.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-10-05 11:30:42 +03:00
Michael Kerrisk 1ff5960b23 prctl.2: Clarify that PR_MCE_KILL_GET returns value via function result
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-10-02 07:20:45 +03:00
Michael Kerrisk 035a7bf179 prctl.2: wfix (for consistency)
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-10-02 07:19:53 +03:00
Michael Kerrisk 7f5d84426c prctl.2: RETURN VALUE: add some missing entries
Note success return for PR_GET_SPECULATION_CTRL and PR_GET_FP_MODE.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-10-02 07:09:38 +03:00
Michael Kerrisk 1cea09b38b prctl.2: Clarify that PR_GET_SPECULATION_CTRL returns value as function result
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-10-02 06:56:50 +03:00
Michael Kerrisk f1bb579885 prctl.2: grfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-10-02 06:11:02 +03:00
Michael Kerrisk f1ba3ad272 prctl.2: wfix (for consistency with usage in rest of this page)
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-10-02 06:07:52 +03:00
Michael Kerrisk 3946602978 prctl.2: Clarify that PR_GET_FP_MODE returns value as function result
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-10-02 06:05:50 +03:00
Michael Kerrisk 27f942adbc sched_setparam.2, pthread_mutexattr_init.3, pthread_mutexattr_setrobust.3, pthread_mutex_consistent.3, strtol.3, sched.7, uts_namespaces.7: SEE ALSO: correct list order
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-27 14:18:46 +02:00
Michael Kerrisk 549597a85f close.2, execve.2, io_submit.2, prctl.2, write.2: Remove section number from references to function in its own page
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-27 14:18:46 +02:00
Michael Kerrisk 49a2a1052b copy_file_range.2, fanotify_mark.2, inotify_add_watch.2, ioctl_fideduperange.2, kcmp.2, prctl.2, get_robust_list.2, tkill.2, ttyname.3: ERRORS: correct alphabetical order
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-27 14:18:08 +02:00
Amir Goldstein 88e75e2c56 copy_file_range.2: Kernel v5.3 updates
Update with all the missing errors the syscall can return, the
behaviour the syscall should have w.r.t. to copies within single
files, etc.

[Amir] updates for final released version.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-27 13:26:03 +02:00
Michael Kerrisk 4985364098 epoll_wait.2: tfix
Reported-by: nilsocket <nilsocket@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-27 08:36:52 +02:00
Michael Kerrisk 362310a7bd signalfd.2: tfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-25 23:20:08 +02:00
Jakub Wilk bf421740d4 pivot_root.2: tfix
Remove duplicated words.

Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-25 20:41:48 +02:00
Michael Kerrisk d703afe9a6 sched_setaffinity.2: RETURN VALUE: sched_getaffinity() syscall differs from the wrapper
In RETURN VALUE, point reader at subsection noting that the return
value of the raw sched_setaffinity() system call differs from the
wrapper function in glibc.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-25 14:35:27 +02:00
Michael Kerrisk f3fdbe2812 open.2: tfix
Reported-by: Дилян Палаузов <dilyan.palauzov@aegee.org>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-24 12:16:07 +02:00
Michael Kerrisk b892d64f4f signalfd.2: Rewrite the text on epoll semantics
I also verified the behavior reported by Andrew Clayton
with the program below.

$ ./epoll_signalfd
PID of parent: 5661
PID of child:  5662
epoll_wait() returned 0
PID 5662: got signal 10
Successfully read signal, even though epoll_wait() didn't say FD was ready!

8x----8x----8x----8x----8x----8x----8x----8x----8x----8x----8x----8x----
/* epoll_signalfd.c */

#include <sys/signalfd.h>
#include <signal.h>
#include <sys/epoll.h>
#include <sys/wait.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#define errExit(msg)    do { perror(msg); exit(EXIT_FAILURE); \
                        } while (0)

static void
signalTest(int sfd, int epfd)
{
    struct signalfd_siginfo fdsi;
    struct epoll_event rev;
    int ready;
    ssize_t s;

    usleep(50000);
    ready = epoll_wait(epfd, &rev, 1, 0);
    if (ready == -1)
        errExit("epoll_wait");

    printf("epoll_wait() returned %d\n", ready);

    s = read(sfd, &fdsi, sizeof(struct signalfd_siginfo));
    if (s != sizeof(struct signalfd_siginfo))
        errExit("read");

    printf("PID %ld: got signal %d\n", (long) getpid(), fdsi.ssi_signo);

    if (ready == 0 && s > 0)
        printf("Successfully read signal, even though epoll_wait() "
                "didn't say FD was ready!\n");
}

int
main(int argc, char *argv[])
{
    struct epoll_event ev;
    sigset_t mask;
    int sfd, epfd;

    sigfillset(&mask);
    sigdelset(&mask, SIGINT);

    if (sigprocmask(SIG_BLOCK, &mask, NULL) == -1)
        errExit("sigprocmask");

    sfd = signalfd(-1, &mask, SFD_NONBLOCK);
    if (sfd == -1)
        errExit("signalfd");

    epfd = epoll_create(5);
    if (epfd == -1)
        errExit("epoll_create");

    ev.data.fd = sfd;
    ev.events = EPOLLIN;
    if (epoll_ctl(epfd, EPOLL_CTL_ADD, sfd, &ev) == -1)
        errExit("epoll_ctl");

    switch (fork()) {
    case -1:
        errExit("fork");
    case 0:
        printf("PID of child:  %ld\n", (long) getpid());
        raise(SIGUSR1);
        signalTest(sfd, epfd);
        break;
    default:
        printf("PID of parent: %ld\n", (long) getpid());
        wait(NULL);
        break;
    }

    exit(EXIT_SUCCESS);
}
8x----8x----8x----8x----8x----8x----8x----8x----8x----8x----8x----8x----

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-23 16:48:36 +02:00
Andrew Clayton e95f6bf482 signalfd.2: Note about interactions with epoll & fork
Using signalfd(2) with epoll(7) and fork(2) can lead to some head
scratching.

It seems that when a signalfd file descriptor is added to epoll
you will only get notifications for signals sent to the process
that added the file descriptor to epoll.

So if you have a signalfd fd registered with epoll and then call
fork(2), perhaps by way of daemon(3) for example. Then you will
find that you no longer get notifications for signals sent to the
newly forked process.

User kentonv on ycombinator[0] explained it thus

    "One place where the inconsistency gets weird is when you
     use signalfd with epoll. The epoll will flag events on the
     signalfd based on the process where the signalfd was
     registered with epoll, not the process where the epoll is
     being used. One case where this can be surprising is if you
     set up a signalfd and an epoll and then fork() for the
     purpose of daemonizing -- now you will find that your epoll
     mysteriously doesn't deliver any events for the signalfd
     despite the signalfd otherwise appearing to function as
     expected."

And another post from the same person[1].

And then there is this snippet from this kernel commit message[2]

    "If you share epoll fd which contains our sigfd with another
     process you should blame yourself. signalfd is "really
     special"."

So add a note to the man page that points this out where people
will hopefully find it sooner rather than later!

[0]: https://news.ycombinator.com/item?id=9564975
[1]: https://stackoverflow.com/questions/26701159/sending-signalfd-to-another-process/29751604#29751604
[2]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=d80e731ecab420ddcb79ee9d0ac427acbc187b4b

Signed-off-by: Andrew Clayton <andrew@digital-domain.net>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-23 15:57:21 +02:00
Michael Kerrisk 9d33e03b95 pivot_root.2: Explain why various mount points can't have shared propagation
Reported-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-23 13:11:19 +02:00
Michael Kerrisk d4b2104ae5 pivot_root.2: Correct the list of mount points that can't be MS_SHARED
Eric Biederman noted that my list of directories that could not
have shared propagation was incorrect.  I had written that
new_root could not be shared; rather it should be: the parent of
the current root mount point.

Reported-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-23 13:11:19 +02:00
Michael Kerrisk f646ac88ef pivot_root.2: Tweak pivot_root(".", ".") example
Quoting Eric Biederman:

    The concern from our conversation at the container
    mini-summit was that there is a pathology if in your initial
    mount namespace all of the mounts are marked MS_SHARED like
    systemd does (and is almost necessary if you are going to
    use mount propagation), that if new_root itself is MS_SHARED
    then unmounting the old_root could propagate.

    So I believe the desired sequence is:

    >>>            chdir(new_root);
    +++            mount("", ".", MS_SLAVE | MS_REC, NULL);
    >>>            pivot_root(".", ".");
    >>>            umount2(".", MNT_DETACH);

    The change to new new_root could be either MS_SLAVE or
    MS_PRIVATE.  So long as it is not MS_SHARED the mount won't
    propagate back to the parent mount namespace.

Reported-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-23 13:11:19 +02:00
Michael Kerrisk 57bab66a92 pivot_root.2: pivot_root(".", ".") really is a thing
LXC uses this [1]. I tested, to double-check, and it works.

The fchdir() dance done by LXC is not needed though:

fchdir(old_root); umount(".", MNT_DETACH); fchdir(new_root);

As far as I can see, just the umount() is sufficient, since,
after pivot_root(), oldi_root is at the top of the stack
of mounts at "/" and thus (so long as CWD is at "/")
the umount will remove the mount at the top of the stack.
Eric Biederman confirmed my understanding by mail, and
Philipp Wendler verified my results by experiment.

[1] See the following commit in LXC:

    commit 2d489f9e87fa0cccd8a1762680a43eeff2fe1b6e
    Author: Serge Hallyn <serge.hallyn@ubuntu.com>
    Date:   Sat Sep 20 03:15:44 2014 +0000

        pivot_root: switch to a new mechanism (v2)

Helped-by: Eric W. Biederman <ebiederm@xmission.com>
Helped-by: Philipp Wendler <ml@philippwendler.de>
Helped-by: Aleksa Sarai <asarai@suse.de>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-23 13:11:19 +02:00
Michael Kerrisk 682e1329f9 pivot_root.2: Eliminate text suggesting that behavior may change in the future
After around 19 years, the behavior of pivot_root() has not been
changed, and will almost certainly not change in the future.
So, reword to remove the suggestion that the behavior may change.
Also, more clearly document the effect of pivot_root() on
the calling process's current working directory.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-23 13:11:19 +02:00
Michael Kerrisk 4a8b7d7b13 pivot_root.2: Rework a "hanging" description into an earlier paragraph
The reference of "Note that this also applies" was vague. So
combine this paragraph with an earlier one to make the linkage
clearer.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-23 13:11:19 +02:00
Michael Kerrisk aff78c76f7 pivot_root.2: Remove a note about a historical idea/expectation
The idea that there might one day be a mechanism for kernel
threads to explicitly relinquish access to the filesystem never
came to pass (after 20 years), and the presence of text
describing this idea is, IMO, a distraction. So, remove it.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-23 13:11:19 +02:00
Michael Kerrisk c4bf33331b pivot_root.2: ffix (break up a paragraph)
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-23 13:11:19 +02:00
Michael Kerrisk eb9078a7a9 pivot_root.2: Remove text describing case where current root is not a mount point
One kernel printk() later, my suspicions seem confirmed: the text
describing the situation where the current root is not a mount
point (because of a chroot()) seems to be bogus. (Perhaps it was
true once upon a time.) In my testing, if the current root is not
a mount point, an EINVAL error results.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-23 13:11:19 +02:00
Michael Kerrisk fc17fc6502 pivot_root.2: srcfix: FIXME
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-23 13:11:19 +02:00
Michael Kerrisk d761305516 pivot_root.2: Fix a technical detail
In this text:

        If the current root is not a mount point (e.g., after an
        earlier chroot(2) or pivot_root())...

mention of pivot_root() makes no sense, since (as noted in an
earlier commit message for this page) 'new_root' in a previous
pivot_root() must (since Linux 2.4.5) have been a mount point.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-23 13:11:19 +02:00
Michael Kerrisk 14caaed2c1 pivot_root.2: Minor change: rewrite the reference to pivot_root(8)
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-23 13:11:19 +02:00
Michael Kerrisk bbae63c580 pivot_root.2: Remove BUGS section
One of these "bugs" is a philosophical point already covered
elsewhere in the page, while the other is a somewhat obscure joke.
Both pieces are a bit of a distraction, really.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-23 13:11:19 +02:00
Michael Kerrisk 41d4557c09 pivot_root.2: Minor wording fix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-23 13:11:19 +02:00
Michael Kerrisk fc2f474d77 pivot_root.2: Relocate details about kernel threads to NOTES
This text is a side point that somewhat distracts from the
flow in DESCRIPTION.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-23 13:11:19 +02:00
Michael Kerrisk b647c4c93a pivot_root.2: Add some more detail to the remaining EBUSY error
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-23 13:11:19 +02:00
Michael Kerrisk 071505e9fb pivot_root.2: Remove bogus a bogus EBUSY error case
The note that EBUSY is given if a filesystem is already mounted
on 'Iput_old' was never really true. That restriction was in
Linux 2.3.14, but removed in Linux 2.3.99-pre6 so it never made
it to mainline.

The relevant diff in pivot_root() was:

        error = -EBUSY;
-       if (d_new_root->d_sb == root->d_sb || d_put_old->d_sb == root->d_sb)
+       if (new_nd.mnt == root_mnt || old_nd.mnt == root_mnt)
                goto out2; /* loop */
-       if (d_put_old != d_put_old->d_covers)
-               goto out2; /* mount point is busy */
        error = -EINVAL;

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-23 13:11:19 +02:00
Michael Kerrisk 2f2e1a2296 pivot_root.2: Add an example program
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-23 13:11:19 +02:00
Michael Kerrisk 0c2329cdbe pivot_root.2: Minor fix: add a reference to a relevant piece in NOTES
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-23 13:11:19 +02:00
Michael Kerrisk 422e36b7f2 pivot_root.2: Relocate text on use cases and add text on purpose of pivot_root(2)
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-23 13:11:19 +02:00
Michael Kerrisk a94f69d6db pivot_root.2: Rework the text on "future changes" to reflect that 20 years have passed
Some of the text was written long ago, and hinted that things
might change in the future. However, 20 years have passed
and these details have not changed, so rework the text to
hint at that fact.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-23 13:11:19 +02:00
Michael Kerrisk 3afc97b20b pivot_root.2: Mention containers as a use case for pivot_root()
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-23 13:11:19 +02:00
Michael Kerrisk 0ac6f9008e pivot_root.2: srcfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-23 13:11:19 +02:00
Michael Kerrisk b16dd3037d pivot_root.2: There is no restriction against 'put_old' being a mount point
As far as I can see from the source code, the statement that
"No other filesystem may be mounted on 'put_old'" is incorrect.
Even looking at the 2.4.0 source code, there I can't see such
a restriction. In addition, some testing on a 5.0 kernel
(mounting 'put_old' in the new mount namespace just before
pivot_root()) did not result in an error for this case when
calling pivot_root().

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-23 13:11:19 +02:00
Michael Kerrisk 83cc245d6d pivot_root.2: srcfix: add self to copyright
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-23 13:11:18 +02:00
Michael Kerrisk ac2eb791b3 pivot_root.2: pivot_root() affects only other processes in the same mount namespace
pivot_root() only affects the current working directory and root
directory of other processes in the same mount namespace as the
caller.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-23 13:11:18 +02:00
Michael Kerrisk 7cc1a16df6 pivot_root.2: Introduce mount namespaces in the very first sentence
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-23 13:11:18 +02:00
Michael Kerrisk fdc558bda9 pivot_root.2: Note capability requirements
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-23 13:11:18 +02:00
Michael Kerrisk 81b24320d8 pivot_root.2: Mention mount namespaces
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-23 13:11:18 +02:00
Michael Kerrisk f42778c4e5 pivot_root.2: SEE ALSO: add mount_namespaces(7)
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-23 13:11:18 +02:00
Michael Kerrisk 78f662e1c7 pivot_root.2: wfix
"At the time of writing" was ~20 years ago. Things
have not so far changed.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-23 13:11:18 +02:00
Michael Kerrisk 93dc6336f3 pivot_root.2: Reword some text that is currently rather hard to parse
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-23 13:11:18 +02:00
Michael Kerrisk 5f5751d37f pivot_root.2: Minor tweak
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-23 13:11:18 +02:00
Michael Kerrisk 14e47dbe60 pivot_root.2: Minor fix: place some text at a more logical location in the page
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-23 13:11:18 +02:00
Michael Kerrisk e5f5563cba kill.2: Minor clarification
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-19 21:34:26 +02:00
Michael Kerrisk a24fc082d0 rt_sigqueueinfo.2: Rename 'uinfo' argument to 'info'
This is more consistent with the naming in other pages
that refer to a 'siginfo_t' structure.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-19 21:27:44 +02:00
Michael Kerrisk 8637b7a635 rt_sigqueueinfo.2: The rules for 'si_code' don't apply when sending a signal to oneself
The restriction on what values may be specified in 'si_code'
apply only when sending a signal to a process other than the
caller itself.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-19 21:26:04 +02:00
Michael Kerrisk 1573536578 rt_sigqueueinfo.2: Note that 'si_code' can't be specified as SI_KERNEL
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-19 20:55:00 +02:00
Michael Kerrisk debedd946c rt_sigqueueinfo.2: Minor restructuring in preparation for next patch
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-19 20:51:15 +02:00
Mike Frysinger 5dd76c4449 setns.2: Fix CLONE_NEWNS restriction info
Threads are allowed to switch mount namespaces if the filesystem
details aren't being shared.  That's the purpose of the check in
the kernel quoted by the comment:

    if (fs->users != 1)
        return -EINVAL;

It's been this way since the code was originally merged in v3.8.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-19 08:37:45 +02:00
Michael Kerrisk 9914d8bdb8 ptrace.2: Fix description of 'is_error' field in 'struct ptrace_syscall_info'
Reported-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-13 20:48:34 +02:00
Nikola Forró c4f0c33fb6 mmap.2: Fix EINVAL conditions
Since introduction of MAP_SHARED_VALIDATE, in case flags contain
both MAP_PRIVATE and MAP_SHARED, mmap() doesn't fail with EINVAL,
it succeeds.

The reason for that is that MAP_SHARED_VALIDATE is in fact equal
to MAP_PRIVATE | MAP_SHARED.

This is intended behavior, see:
https://lwn.net/Articles/758594/
https://lwn.net/Articles/758598/

Signed-off-by: Nikola Forró <nforro@redhat.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-13 16:26:22 +02:00
Matti Moell 17ea6db2d6 io_submit.2: Fix kernel version numbers for 'aio_rw_flags' flags
Even though the RFW_* flags were first introduced in Linux 4.6,
they could not be used with aio until 4.13 where the aio_rw_flags
field was added to struct iocb (9830f4be159b "fs: Use RWF_* flags
for AIO operations"). Correct the stated version for each flag.

Fixes: 2f72816f86 ("io_submit.2: Add kernel version numbers for various 'aio_rw_flags' flags")

Signed-off-by: Matti Möll <Matti.Moell@opensynergy.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-13 14:57:53 +02:00
Michael Kerrisk 6812112d03 move_pages.2: Some reworking of Yang Xu's text
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-13 14:57:53 +02:00
Yang Xu b5874806cb move_pages.2: Mark E2BIG as deprecated
E2BIG was removed in 2.6.29, we should mark it as deprecated.

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-13 13:48:18 +02:00
Shawn Anastasio 6e164fba7e syscall.2: Add information for powerpc64
Add powerpc64 to the calling convention tables.

Signed-off-by: Shawn Anastasio <shawn@anastas.io>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-13 11:54:11 +02:00
Michael Kerrisk 227a368231 ptrace.2: Clarify meaning of ptrace_syscall_info 'is_error' field
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-12 10:50:02 +02:00
Michael Kerrisk 9d8f542d1f ptrace.2: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-12 10:50:02 +02:00
Michael Kerrisk f04534d22c ptrace.2: Describe the PTRACE_GET_SYSCALL_INFO 'op' value in more detail
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-12 10:49:56 +02:00
Michael Kerrisk 93c37f08be ptrace.2: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-12 10:49:56 +02:00
Michael Kerrisk 1c0955b15a ptrace.2: Minor tweaks to Dmitry Levin's patch
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-12 10:49:51 +02:00
Dmitry V. Levin a60e8f1bb3 ptrace.2: Document struct ptrace_syscall_info
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-12 08:48:26 +02:00
Christopher M. Riedl 5f0922e7a0 mprotect.2: wfix
Signed-off-by: Christopher M. Riedl <cmr@informatik.wtf>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-11 15:00:19 +02:00
Michael Kerrisk 7fd5cf65c4 syscalls.2: Add clone3() and pidfd_open()
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-10 13:43:56 +02:00
Michael Kerrisk 519f86ca43 syscalls.2: Add fsconfig(), fsmount(), fsopen(), fspick(), move_mount(), open_tree()
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-10 13:43:56 +02:00
Michael Kerrisk 6d2c81ea36 syscalls.2: Add new syscalls in 5.1
Add io_uring_enter(), io_uring_register(), io_uring_setup(), and
pidfd_send_signal().

Signed-off-by:(), Michael(), Kerrisk(), <mtk.manpages@gmail.com>
2019-09-10 13:33:08 +02:00
Michael Kerrisk c3543fab53 ptrace.2: Minor tweaks to Dmitry Levin's patch
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-10 12:49:01 +02:00
Dmitry V. Levin fc91449cb5 ptrace.2: Document PTRACE_GET_SYSCALL_INFO
PTRACE_GET_SYSCALL_INFO request was introduced by Linux kernel
commit 201766a20e30f982ccfe36bebfad9602c3ff574a aka
v5.3-rc1~65^2~23.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-10 12:45:14 +02:00
Michael Kerrisk fec82988e7 syscall.2: Update name of syscall instruction for riscv
As reported by Florin:

    In the first table, for the riscv Arch/ABI, the instruction
    should be ecall instead of scall.

    According the official manual, the instruction has been
    renamed.
    https://content.riscv.org/wp-content/uploads/2017/05/riscv-spec-v2.2.pdf

    "The SCALL and SBREAK instructions have been renamed to
    ECALL and EBREAK, respectively. Their encoding and
    functionality are unchanged."

Reported-by: Florin Blanaru <florin.blanaru96@gmail.com>
Reviewed-by: Adam Borowski <kilobyte@angband.pl>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-10 12:45:14 +02:00
Jakub Wilk b5e1b804f9 fanotify_mark.2: Document FAN_MOVE_SELF
Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-10 12:45:14 +02:00
Jakub Wilk 10fa1da2a3 fanotify_mark.2: Add kernel version numbers for some FAN_* constants
Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-10 12:45:14 +02:00
Jakub Wilk bbd7edea6e fanotify_mark.2: ffix
Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-09-10 12:45:14 +02:00
Michael Kerrisk b6088873ae prctl.2: tfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-08-27 13:56:13 +02:00
Eric Biggers ff085a5e44 socket.2: tfix
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-08-26 23:14:49 +02:00
Michael Kerrisk d837569d1e uname.2: Replace reference to namespaces(7) with reference to uts_namespaces(7)
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-08-26 23:14:49 +02:00
Michael Kerrisk 16ea6936c7 getdomainname.2: Add mention of UTS namespaces
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-08-26 23:14:49 +02:00
Michael Kerrisk 79ea68831f gethostname.2: Mention UTS namespaces
Reported-by: Jakub Wilk <jwilk@jwilk.net>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-08-26 23:14:49 +02:00
Michael Kerrisk ed4f87f0c8 clone.2: tfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-08-26 21:54:16 +02:00
Michael Kerrisk c031ffcc56 statx.2: Clarify details of a case where an invalid 'mask' value may be rejected
As reported by Simone:

    I was looking at version from 2017-09-15 but it's the same
    on: http://man7.org/linux/man-pages/man2/statx.2.html
    (2019-03-06)

    There is reported (about the mask argument) after the list
    of constants:

    > Note that the kernel does not reject values in mask other
    > than the above.  Instead, it simply informs the caller which
    > values are sup‐ ported by this kernel and filesystem via the
    > statx.stx_mask field.

    But as reported in the error values, there can be EINVAL if
    mask has a reserved valued, and I found a check against
    STATX__RESERVED in fs/stat.c for this. So if you use a that
    bit (0x80000000U) the kernel will reject the value.

    Probably is better to say that the kernel do not enforce the
    use of only the listed values, but there are anyway reserved
    values so and so you cannot put whatever you want on mask
    (that apply to more values than UINT_MAX).

Reported-by: Simone Piccardi <piccardi@truelite.it>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-08-20 09:29:49 +02:00
Michael Kerrisk 0b9a799587 prctl.2: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-08-02 08:35:43 +02:00
Michael Kerrisk 63121bd499 pldd.1, bpf.2, chdir.2, clone.2, fanotify_init.2, fanotify_mark.2, intro.2, ipc.2, mount.2, mprotect.2, msgctl.2, msgget.2, msgop.2, pivot_root.2, pkey_alloc.2, poll.2, prctl.2, semctl.2, semget.2, semop.2, setxattr.2, shmctl.2, shmget.2, shmop.2, tkill.2, dlopen.3, exec.3, ftok.3, getutent.3, on_exit.3, strcat.3, cpuid.4, proc.5, capabilities.7, cgroup_namespaces.7, credentials.7, fanotify.7, mount_namespaces.7, namespaces.7, sched.7, signal.7, socket.7, unix.7, user_namespaces.7, vdso.7, xattr.7, ld.so.8: tstamp
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-08-02 08:34:32 +02:00
Michael Kerrisk 8d7dde9f9c setxattr.2: Place new ERANGE error in correct alphabetical order
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-08-01 19:33:38 +02:00
Michael Kerrisk cada754ad1 setxattr.2: Tweaks to Finn O'Leary's text
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-08-01 19:33:38 +02:00
Finn O'Leary acea950099 setxattr.2: Add ERANGE to 'ERRORS' section
Hi,

Both the Ext2 filesystem handler and the Ext4 filesystem handler will
return the ERANGE error code. Ext2 will return it if the name or value is
too long to be able to be stored, Ext4 will return it if the name is too
long. For reference, the relevant files/lines (with excerpts) are:

fs/ext2/xattr.c: lines 394 to 396 in ext2_xattr_set
>  394         name_len = strlen(name);
>  395         if (name_len > 255 || value_len > sb->s_blocksize)
>  396                 return -ERANGE;

fs/ext4/xattr.c: lines 2317 to 2318 in ext4_xattr_set_handle
> 2317         if (strlen(name) > 255)
> 2318                 return -ERANGE;

Other filesystems also return this code:

xfs/libxfs/xfs_attr.h: lines 53 to 55
> * The maximum size (into the kernel or returned from the kernel) of an
> * attribute value or the buffer used for an attr_list() call.  Larger
> * sizes will result in an ERANGE return code.

It's possible that more filesystem handlers do this, a cursory grep shows
that most of the filesystem xattr handler files mention ERANGE in some
form. A suggested patch is below (I'm not 100% sure on the wording through).

Thanks

--
- Finn

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-08-01 19:33:38 +02:00
Yang Xu c14f79303f prctl.2: Correct some details for PR_SET_TIMERSLACK
In kernel/sys.c, arg2 is an unsigned long value and it will never
less than 0. Also, since kernel commit id da8b44d5a9f8 (Linux
4.6), timer_slack_ns and default timer_slack_ns have been
converted into u64, the return value of PR_GET_TIMERSLACK has been
limited under ULONG_MAX.

The timer slack value also can be inherited by a child created via
fork(2).

Reviewed-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-07-30 08:25:37 +02:00
Michael Kerrisk 0bdda5d08e poll.2: Note that poll() equivalent code for ppoll() is not quite equivalent
As reported by Alan Stern:

Here are two extracts from the man page for ppoll(2):

     Specifying a negative value in timeout means an infinite
     timeout.

     Other than the difference in the precision of the timeout
     argument, the following ppoll() call:

       ready = ppoll(&fds, nfds, tmo_p, &sigmask);

     is equivalent to atomically executing the following calls:

       sigset_t origmask;
       int timeout;

       timeout = (tmo_p == NULL) ? -1 :
                 (tmo_p->tv_sec * 1000 + tmo_p->tv_nsec / 1000000);
       pthread_sigmask(SIG_SETMASK, &sigmask, &origmask);
       ready = poll(&fds, nfds, timeout);
       pthread_sigmask(SIG_SETMASK, &origmask, NULL);

But if tmo_p->tv_sec is negative, the ppoll() call is not
equivalent to the corresponding poll() call.  The kernel rejects
negative values of tv_sec with an EINVAL error; it does not
interpret the value as meaning an infinite timeout.

(Yes, the kernel interprets tmo_p == NULL as an infinite timeout,
but the man page is still wrong for the case tmo_p->tv_sec < 0.)

Suggested fix: Following the end of the second extract above, add:

    except that negative time values in tmo_p are not
    interpreted as an infinite timeout.

Also, in the ERRORS section, change the text for EINVAL to:

    EINVAL The nfds value exceeds the RLIMIT_NOFILE value or
    *tmo_p contains an invalid (negative) time value.

Reported-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-07-30 08:25:27 +02:00
Michael Kerrisk 6f4a00d62f mount.2: ERRORS: Add a couple of EINVAL errors for MS_MOVE
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-07-28 09:17:06 +02:00
Michael Kerrisk 0610c6f1f8 mount.2: tfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-07-26 23:28:08 +02:00
Michael Kerrisk a68bb0b38d mount.2: SEE ALSO: add chroot(2) and pivot_root(2)
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-07-26 23:27:18 +02:00
Michael Kerrisk a39e880f67 pivot_root.2: 'put_old' can't be a mount point with MS_SHARED propagation
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-07-26 23:22:59 +02:00
Michael Kerrisk 34a0f19c76 pivot_root.2: SEE ALSO: add mount(2)
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-07-26 17:10:58 +02:00
Michael Kerrisk 1a0b1fd76b pivot_root.2: ERRORS: EINVAL occurs if 'new_root' or its parent has shared propagation
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-07-26 17:10:06 +02:00
Michael Kerrisk 37704bfc8f pivot_root.2: 'new_root' must be a mount point
It appears that 'new_root' may not have needed to be a mount
point on ancient kernels, but already in Linux 2.4.5, there
was the diff shown below. Verified also by testing.

@@ -1631,8 +1605,9 @@
  *  - we don't move root/cwd if they are not at the root (reason: if something
  *    cared enough to change them, it's probably wrong to force them elsewhere)
  *  - it's okay to pick a root that isn't the root of a file system, e.g.
- *    /nfs/my_root where /nfs is the mount point. Better avoid creating
- *    unreachable mount points this way, though.
+ *    /nfs/my_root where /nfs is the mount point. It must be a mountpoint,
+ *    though, so you may need to say mount --bind /nfs/my_root /nfs/my_root
+ *    first.
  */

 asmlinkage long sys_pivot_root(const char *new_root, const char *put_old)
@@ -1640,7 +1615,7 @@
        struct dentry *root;
        struct vfsmount *root_mnt;
        struct vfsmount *tmp;
-       struct nameidata new_nd, old_nd;
+       struct nameidata new_nd, old_nd, parent_nd, root_parent;
        char *name;
        int error;

@@ -1688,6 +1663,10 @@
        if (new_nd.mnt == root_mnt || old_nd.mnt == root_mnt)
                goto out2; /* loop */
        error = -EINVAL;
+       if (root_mnt->mnt_root != root)
+               goto out2;
+       if (new_nd.mnt->mnt_root != new_nd.dentry)
+               goto out2; /* not a mountpoint */
        tmp = old_nd.mnt; /* make sure we can reach put_old from new_root */
        spin_lock(&dcache_lock);
        if (tmp != new_nd.mnt) {

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-07-26 16:54:16 +02:00
Michael Kerrisk 4d4708bfd2 getgroups.2: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-07-16 13:50:05 +02:00
Jakub Wilk ed386413f8 execve.2: tfix
Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-07-13 10:15:48 -06:00
Michael Kerrisk 069be4fd22 bpf.2: Correct kernel version for JIT support on s390
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-07-13 18:05:50 +02:00
Michael Kerrisk 4c63ee20b0 tkill.2: glibc 2.30 provides a wrapper for tgkill()
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-07-08 12:23:55 +02:00
Michael Kerrisk 343cdc5ac9 clone.2, intro.2, ipc.2, msgctl.2, msgget.2, msgop.2, semctl.2, semget.2, semop.2, shmctl.2, shmget.2, shmop.2, ftok.3, proc.5, namespaces.7: Change reference to svipc(7) to sysvipc(7)
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-06-25 06:38:01 +02:00
Michael Kerrisk 173eb06cd8 ptrace.2: wfix: s/proper superset/superset/ in "Ptrace access mode checking"
Reported-by: Alexey Izbyshev <izbyshev@ispras.ru>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-06-21 08:04:58 +02:00
Michael Kerrisk 63059c4b52 execve.2: Some tweaks to Shawn Landden's patch
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-06-21 08:02:38 +02:00
Shawn Landden 60f16bf2fe execve.2: Add more detail about Shebangs
Signed-off-by: Shawn Landden <shawn@git.icu>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-06-21 08:02:37 +02:00
Michael Kerrisk 44dceef0cd execve.2: Since Linux 5.1, the limit on the #! line is 255 chars (rather than 127)
Reported-by: Eugene Syromyatnikov <evgsyr@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-06-19 21:06:11 +02:00
Michael Kerrisk 815d0561d0 execve.2: ffix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-06-19 20:47:10 +02:00
Michael Kerrisk 8fa1a0223e execve.2: ffix: remove spaces that suggest a space is needed after #!
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-06-19 20:45:00 +02:00
Michael Kerrisk fc894c8f55 execve.2: Linux is not alone in ignoring the set-UID and set-GID bits for scripts
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-06-19 20:42:10 +02:00
Michael Kerrisk 283db6f607 chdir.2: Add ENOTDIR error for fchdir()
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-06-17 20:36:37 +02:00
Mark Wielaard f92ea96bab pkey_alloc.2, mprotect.2: _GNU_SOURCE is required for the pkey functions.
To get the pkey_alloc, pkey_free and pkey_mprotect functions
_GNU_SOURCE needs to be defined before including sys/mman.h.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
Signed-off-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-06-14 17:09:00 +02:00
Mark Wielaard a4a0b74234 mprotect.2: pkey_mprotect() acts like mprotect() if pkey is set to -1, not 0
The mprotect.2 NOTES say:

    On systems that do not support protection keys in
    hardware, pkey_mprotect() may still be used, but pkey must
    be set to 0.  When called this way, the operation of
    pkey_mprotect() is equivalent to mprotect().

But this is not what the glibc manual says:

    It is also possible to call pkey_mprotect with a key value
    of -1, in which case it will behave in the same way as
    mprotect.

Which is correct. Both the glibc implementation and the
kernel check whether pkey is -1. 0 is not a valid pkey when
memory protection keys are not supported in hardware.

Signed-off-by: Mark Wielaard <mark@klomp.org>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-06-14 17:06:50 +02:00
Michael Kerrisk eae836e071 fanotify_init.2, fanotify_mark.2, fanotify.7: Minor tweak: s/object/filesystem object/
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-06-08 11:45:06 +02:00
Michael Kerrisk 817c8240f3 fanotify_init.2, fanotify_mark.2, fanotify.7: Minor fixes to Matthew Bobrowski's patch
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-06-08 11:45:06 +02:00
Matthew Bobrowski 0a4db6dc74 fanotify.7, fanotify_init.2, fanotify_mark.2: Document FAN_REPORT_FID and directory modification events
Details relating to the new initialization flag FAN_REPORT_FID has been
added. As part of the FAN_REPORT_FID feature, a new set of event masks are
available and have been documented accordingly.

A simple example program has been added to also support the understanding
and use of FAN_REPORT_FID and directory modification events.

Signed-off-by: Matthew Bobrowski <mbobrowski@mbobrowski.org>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-06-08 08:37:54 +02:00
Petr Vaněk 59a4d9b398 syscalls.2: tfix
Signed-off-by: Petr Vaněk <arkamar@atlas.cz>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-06-08 08:22:36 +02:00
Michael Kerrisk cb7c96bfdd prctl.2: tfix
Reported-by: Tomas Skäre <tomas.skare@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-05-16 12:22:32 -05:00
Michael Kerrisk 2e3023c413 execve.2, setfsgid.2, setfsuid.2, splice.2, fopen.3, malloc_trim.3, posix_memalign.3, stdarg.3, sysconf.3, tsearch.3, elf.5, hostname.7, inode.7: tstamp
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-05-09 09:43:09 +02:00
Jakub Wilk 60ae21db4c intro.1, execve.2, getcontext.3, passwd.5, bpf-helpers.7: wfix
Use gender-neutral pronouns.

Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-05-06 14:49:18 -05:00
Michael Kerrisk 14a848f0f1 sched_setaffinity.2: Correct details of return value of sched_getaffinity() syscall
Things changed a little with:

    commit cd3d8031eb4311e516329aee03c79a08333141f1
    Author: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
    Date:   Fri Mar 12 16:15:36 2010 +0900

Reported-by: Brice Goglin <Brice.Goglin@inria.fr>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-05-05 13:02:30 -05:00
Michael Kerrisk 3a66e3293d execve.2: wfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-05-05 07:36:37 -05:00
Michael Kerrisk 4a696f5ebd execve.2: Note that stack+environ size is also limited to 3/4 of _STK_LIM
In fs/exec.c::prepare_arg_pages(), we have:

        limit = _STK_LIM / 4 * 3;
        limit = min(limit, bprm->rlim_stack.rlim_cur / 4);

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-05-05 07:34:13 -05:00
Michael Kerrisk c7dc46d0a2 close.2: srcfix (comment on EINTR error)
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-05-05 06:14:45 -05:00
Slavomir Kaslev 5ca397fa3e tee.2: EAGAIN can occur when called on nonblocking file descriptors
Signed-off-by: Slavomir Kaslev <kaslevs@vmware.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-05-05 05:28:17 -05:00
Slavomir Kaslev 4b5e751062 splice.2: EAGAIN can occur when called on nonblocking file descriptors
Signed-off-by: Slavomir Kaslev <kaslevs@vmware.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-05-05 05:27:55 -05:00
Michael Kerrisk 4727b7b062 setfsuid.2: wfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-04-25 16:06:50 -05:00
Michael Kerrisk 6ab62ed869 clone.2: CLONE_CHILD_SETTID has effect before clone() returns *in the child*
CLONE_CHILD_SETTID may not have had effect by the time clone()
returns in the parent, which could bre relevant if the
CLONE_VM flag is employed. The relevant kernel code is in
schedule_tail(), which is called in ret_from_fork()
in the child.

See https://bugzilla.kernel.org/show_bug.cgi?id=203105

Demonstration using the program shown below (inspired by a simpler
example from Jakub):

$ ./a.out
parent start: ctid =     0    ptid =  6212
child start:  ctid =  6212    ptid =  6212
child later:  ctid =  6212    ptid =  6212
cat parent later: ctid =  6212    ptid =  6212
f.child -- bye

$ cat prog.c

static volatile pid_t ctid, ptid;

static int
child_fn(void *arg)
{
    printf("child start:  ctid = %5d    ptid = %5d\n", ctid, ptid);
    sleep(1);
    printf("child later:  ctid = %5d    ptid = %5d\n", ctid, ptid);
    sleep(2);
    printf("child -- bye\n");
    return 0;
}

int
main(void)
{
    void *stack = malloc(0x1000);
    char *stack_top = (char *) stack + 0x1000;
    int flags =  SIGCHLD | CLONE_VM |
                 // CLONE_VFORK |
                 CLONE_PARENT_SETTID | CLONE_CHILD_SETTID;

    if (clone(child_fn, stack_top, flags, NULL, &ptid, NULL, &ctid) == -1) {
        perror("clone");
        exit(EXIT_SUCCESS);
    }

    fprintf(stderr, "parent start: ctid = %5d    ptid = %5d\n", ctid, ptid);
    sleep(2);
    fprintf(stderr, "parent later: ctid = %5d    ptid = %5d\n", ctid, ptid);

    if (wait(NULL) == -1) {
        perror("wait");
        exit(EXIT_FAILURE);
    }

    exit(EXIT_SUCCESS);
}

Reported-by: Jakub Nowak <jakub.jakub.nowak@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-04-15 14:17:39 +02:00
Lucas Werkmeister 001c282788 io_getevents.2: wsfix: fix stray tab
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-04-14 19:12:34 +02:00
Michael Kerrisk 5ea5bb212b syscalls.2: Remove crufty text about i386 syscall dispatch table
The removed text long ago ceased to be accurate. Nowadays, the
dispatch table is autogenerated when building the kernel (via
the kernel makefile, arch/x86/entry/syscalls/Makefile).

Reported-by: Andreas Korb <andreas.d.korb@gmail.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-04-12 10:56:59 +02:00
Michael Kerrisk 2ef9216b22 bpf.2: Update kernel version info for JIT compiler
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-04-04 11:53:38 +02:00
Michael Kerrisk d478d0defe setfsgid.2: Rewrite for improved clarity and defer to setfsuid() for details
Rewrite for improved clarity and defer to setfsuid(2) for the
rationale of the fsGID rather than repeating the same details
in this page.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-03-26 06:11:58 +01:00
Michael Kerrisk 5d3b92e534 setfsuid.2: Rewrite for improved clarity and to hint history more explicitly
The current text reads somewhat clumsily. Rewrite it to introduce
the eUID and fsUID in parallel, and more clearly hint at the the
historical rationale for the fsUID, which is detailed lower in
the page.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-03-26 05:58:54 +01:00
Abhinav Upadhyay 96ed2f3ff4 bpf.2: tfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-03-20 08:57:56 +01:00
Michael Kerrisk 03349e33f9 accept.2: Note that 'addrlen' is left unchanged in the event of an error
See http://austingroupbugs.net/view.php?id=836.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-03-18 17:30:23 +01:00
Michael Kerrisk 1a29a70ded pipe.2: Note that 'pipefd' is left unchanged in the event of an error
See http://austingroupbugs.net/view.php?id=467.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-03-18 17:30:23 +01:00
Michael Kerrisk 1548a03a6b socketpair.2: Clarify that 'sv' is left unchanged in the event of an error
See also http://austingroupbugs.net/view.php?id=483.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-03-18 17:30:23 +01:00
Michael Kerrisk f77c624f27 execve.2: SEE ALSO: refer to exec(3) (rather than execl(3))
Reported-by: Dr. Jürgen Sauermann <mail@xn--jrgen-sauermann-zvb.de>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-03-08 17:56:13 +01:00
Michael Kerrisk 3f5755f6ef execve.2, exec.3: Consistently use the term 'pathname' (not 'path')
Reported-by: Dr. Jürgen Sauermann <mail@xn--jrgen-sauermann-zvb.de>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-03-08 17:52:17 +01:00
Michael Kerrisk c49cdd1ce0 execve.2: wfix
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2019-03-08 17:50:06 +01:00