aboutsummaryrefslogtreecommitdiffstats
path: root/man2
AgeCommit message (Collapse)AuthorFilesLines
2021-08-09sigaction.2: Minor clean-ups to Peter Collingbourne's patchMichael Kerrisk1-7/+7
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-08-09sigaction.2: Minor tweaks to Peter's patchAlejandro Colomar1-33/+43
- Move example program to a new EXAMPLES section - Invert logic in the handler to have the failure in the conditional path, and the success out of any conditionals. - Use NULL, EXIT_SUCCESS, and EXIT_FAILURE instead of magic numbers - Separate declarations from code - Put function return type on its own line - Put function opening brace on its line Cc: Peter Collingbourne <pcc@google.com> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-08-09sigaction.2: Document SA_EXPOSE_TAGBITS and the flag support detection protocolPeter Collingbourne1-0/+123
Signed-off-by: Peter Collingbourne <pcc@google.com> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-08-09localedef.1, access.2, ioctl_console.2, ioctl_fslabel.2, openat2.2, write.2, ↵Michael Kerrisk5-7/+12
dlsym.3, getopt.3, nl_langinfo.3, termios.3, xcrypt.3, hosts.equiv.5, nsswitch.conf.5, cgroups.7, man-pages.7, netlink.7, system_data_types.7: srcfix: semantic newlines Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-08-09close_range.2: Glibc added a wrapper recentlyAlejandro Colomar1-5/+0
Fixes: c2356ba085ed4f748b81c0ceeba1811b4a549e1c Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-08-09ioctl_tty.2: Note kernel version that added TCGETS2, TCSETS2, TCSETSW2, and ↵Michael Kerrisk1-1/+4
TCSETSF2 Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-08-09ioctl_tty.2: Minor wording clean-upsMichael Kerrisk1-7/+7
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-08-09ioctl_tty.2: Document ioctls: TCGETS2, TCSETS2, TCSETSW2, TCSETSF2Pali Rohár1-0/+29
Signed-off-by: Pali Rohár <pali@kernel.org> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-08-09ioctl_tty.2: Document ioctls: TCGETS2, TCSETS2, TCSETSW2, TCSETSF2Pali Rohár1-0/+29
Signed-off-by: Pali Rohár <pali@kernel.org> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-08-09ioctl_tty.2: Update DTR examplePali Rohár1-1/+2
Do not include unused (and incompatible) header file termios.h and include required header files for puts() and close() functions. Signed-off-by: Pali Rohár <pali@kernel.org> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-08-09readv.2, pipe.7: Make text on pipe writes more general to avoid a confusion ↵Michael Kerrisk1-3/+1
in writev(2) After a patch proposal from наб triggered by concerns that, when talking about PIPE_BUF, pipe(7) explicitly mentions write(2) but not writev(2), I've concluded that the reference in writev(2) to pipe(7) is not needed (mea culpa; I added that text), and I think the text in pipe(7) could be written to be closer to the POSIX spec, which doesn't talk about "write() calls", but simply about "writes". Reported-by: наб <nabijaczleweli@nabijaczleweli.xyz> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-08-08readv.2: Minor fixes (part 2) to Will Manley's patchMichael Kerrisk1-3/+8
Mainly: I generally don't want us to be including URLs to mailing list discussions in a manual page. Either, the issue in the discussion is worth writing up in the manual page (so that the reader doesn't have to look elsewhere), or the details are less important, in which case it is sufficient to note the existence of the bug. I think this is an example of the latter. Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-08-08readv.2: Minor tweaks to Will Manley's patchAlejandro Colomar1-2/+2
Cc: Will Manley <will@williammanley.net> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-08-08readv2: Note preadv2(..., RWF_NOWAIT) bug in BUGS sectionWill Manley1-1/+10
To save the next person before they fall foul of it. See <https://lore.kernel.org/linux-fsdevel/fea8b16d-5a69-40f9-b123-e84dcd6e8f2e@www.fastmail.com/T/#u> and <https://github.com/tokio-rs/tokio/issues/3803> for more information. Signed-off-by: Will Manley <will@williammanley.net> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-08-08execve.2: The pathname given to interpreter is not necessarily absoluteMichael Kerrisk1-1/+1
As pointed out by Nora, the example shown in the manual page already demonstrates that the pathname is not absolute! Reported-by: Nora Platiel <nplatiel@gmx.us> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-08-08execve.2: SEE ALSO: getauxval(3)Michael Kerrisk1-0/+1
getauxval(3) is useful background regarding execve(2). Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-08-08seccomp_unotify.2: tfixJakub Wilk1-1/+1
Remove duplicated word. Signed-off-by: Jakub Wilk <jwilk@jwilk.net> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-08-08seccomp_unotify.2: Minor tweaks (part 2) to Rodrigo's patchMichael Kerrisk1-8/+11
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-08-08seccomp_unotify.2: Minor tweaks to Rodrigo's patchAlejandro Colomar1-15/+17
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-08-08seccomp_unotify.2: Document SECCOMP_ADDFD_FLAG_SENDRodrigo Campos1-0/+26
This flag was recently added to Linux 5.14 by a patch I wrote: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0ae71c7720e3ae3aabd2e8a072d27f7bd173d25c This patch adds documentation for the flag, the error code that the flag added and explains in the caveat when it is useful. Signed-off-by: Rodrigo Campos <rodrigo@kinvolk.io> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-08-08man2/fallocate.2: tfix documentation of shared blocksDan Robertson1-1/+1
Fix a typo in the documentation of using fallocate to allocate shared blocks. The flag FALLOC_FL_UNSHARE should instead be documented as FALLOC_FL_UNSHARE_RANGE. Fixes: 63a599c657d8 ("man2/fallocate.2: Document behavior with shared blocks") Signed-off-by: Dan Robertson <dan@dlrobertson.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-08-08time.2: wfix regarding year-2038Viet Than1-1/+1
Signed-off-by: Viet Than <thanhoangviet@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-08-08wait.2: Minor fixes to Richard Palethorpe's patchMichael Kerrisk1-1/+1
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-08-08wait.2: Add ESRCH for when pid == INT_MINRichard Palethorpe1-0/+9
Please see upstream commit: commit dd83c161fbcc5d8be637ab159c0de015cbff5ba4 Author: zhongjiang <zhongjiang@huawei.com> Date: Mon Jul 10 15:53:01 2017 -0700 kernel/exit.c: avoid undefined behaviour when calling wait4() It avoids negating INT_MIN by returning early with ESRCH. Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-08-08tkill.2: tfixSagar Patel1-1/+1
Correct function signature by adding missing parenthesis. Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-08-07recv.2: tfixkXuan1-1/+1
The recv.2 misspelled `SO_EE_OFFENDER` to `SOCK_EE_OFFENDER`. This patch fix this typo. Signed-off-by: kXuan <kxuanobj@gmail.com> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-08-07Various pages: Consistently use '*argv[]'Thomas Voss5-6/+6
Scripted change: $ find man? -type f \ | sed -i 's/int argc, char \*\*argv/int argc, char \*argv\[\]/'; Signed-off-by: Thomas Voss <thomasavoss@protonmail.com> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-07-26ioctl_tty.2: wfixMichael Kerrisk1-0/+1
Reported-by: Helge Kreutzmann <debian@helgefjell.de> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-07-26ioctl_tty.2: wfixMichael Kerrisk1-1/+1
Reported-by: Helge Kreutzmann <debian@helgefjell.de> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-07-26ioctl_tty.2: ffixMichael Kerrisk1-8/+9
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-07-26ioctl_tty.2: srcfixMichael Kerrisk1-1/+0
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-07-26ioctl_tty.2: tfixMichael Kerrisk1-1/+1
Reported-by: Helge Kreutzmann <debian@helgefjell.de> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-07-26mmap.2: wfixMichael Kerrisk1-1/+1
Reported-by: Helge Kreutzmann <debian@helgefjell.de> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-07-26rmdir.2: tfixMichael Kerrisk1-1/+1
Reported-by: Helge Kreutzmann <debian@helgefjell.de> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-07-26shmop.2: wfixMichael Kerrisk1-1/+0
Reported-by: Helge Kreutzmann <debian@helgefjell.de> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-07-26rename.2: wfixMichael Kerrisk1-1/+1
Reported-by: Helge Kreutzmann <debian@helgefjell.de> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-07-26sync.2: tfixMichael Kerrisk1-1/+1
Reported-by: Helge Kreutzmann <debian@helgefjell.de> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-07-25perf_event_open.2: tfixMichael Kerrisk1-1/+1
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-07-25chmod.2: tfixMichael Kerrisk1-1/+1
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-07-25bdflush.2: srcfixMichael Kerrisk1-1/+1
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-07-12close_range.2: Glibc 2.34 has added a close_range() wrapperMichael Kerrisk1-0/+1
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-22exit_group.2, ioprio_set.2, process_madvise.2, seccomp_unotify.2, ↵Michael Kerrisk6-6/+6
set_mempolicy.2, set_tid_address.2, bswap.3, kernel_lockdown.7: tstamp Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-20ioctl_fideduperange.2: tfixMichael Kerrisk1-2/+2
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-20mount.2: Minor fixes to Topi Miettinen's patchMichael Kerrisk1-3/+7
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-20mount.2: document SELinux use of MS_NOSUID mount flagTopi Miettinen1-1/+3
Using mount flag `MS_NOSUID` also affects SELinux domain transitions but this has not been documented well. Signed-off-by: Topi Miettinen <toiwoton@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-20wait4.2: SYNOPSIS: Remove includesAlejandro Colomar1-3/+0
Don't document includes that provide types; only those that provide prototypes and constants. Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-20wait.2: Remove <sys/types.h>Alejandro Colomar1-1/+0
The types that need <sys/types.h> are better documented in system_data_types(7). Let's keep only the includes for the prototypes and the constants. Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-20vmsplice.2: Remove unneeded includeAlejandro Colomar1-1/+0
'struct iovec' is defined in <bits/types/struct_iovec.h>, which is included by <sys/io.h>, but it is also included by <bits/fcntl-linux.h>, which is in the end included by <fcntl.h>. Given that we already include <fcntl.h>, we don't need any more includes. Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-20utimensat.2: ffixAlejandro Colomar1-1/+1
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-20utime.2: SYNOPSIS: Fix includesAlejandro Colomar1-1/+0
'struct utimbuf' is provided by <utime.h>. There's no need for <sys/types.h>. Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-20userfaultfd.2: Use syscall(SYS_...); for system calls without a wrapper; fix ↵Alejandro Colomar1-5/+8
includes too Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-20userfaultfd.2: Remove unused includesAlejandro Colomar1-2/+0
<sys/types.h> makes no sense for a function that only uses 'int'. The flags used by this function are provided by <fcntl.h> (or others), but not by <linux/userfaultfd.h>. Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-20unlink.2: ffixAlejandro Colomar1-1/+1
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-20umask.2: Remove <sys/types.h>Alejandro Colomar1-1/+0
'mode_t', which is the only reason this might have been ever needed, is provided by <sys/stat.h> since POSIX.1-2001. Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-20truncate.2: Remove <sys/types.h>Alejandro Colomar1-1/+0
'off_t', which is the only reason this might have been ever needed, is provided by <unistd.h> since POSIX.1-2001. Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-20tkill.2: Use syscall(SYS_...); for system calls without a wrapper; fix ↵Alejandro Colomar1-9/+13
includes too Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-20s390_sthyi.2: tfixAlejandro Colomar1-1/+1
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-20s390_runtime_instr.2: tfixAlejandro Colomar1-1/+1
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-20s390_guarded_storage.2: tfixAlejandro Colomar1-1/+1
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-20timer_create.2: SYNOPSIS: Document why more than one header is neededAlejandro Colomar1-1/+1
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-20syslog.2: Use syscall(SYS_...); for raw system callsAlejandro Colomar1-2/+6
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-20syscall.2: wfix + ffixAlejandro Colomar1-1/+1
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-20symlink.2: ffixAlejandro Colomar1-1/+1
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-20swapon.2: SYNOPSIS: Fix includesAlejandro Colomar1-1/+0
There seems to be no reason to include <unistd.h>. <sys/swap.h> already provides both the function prototypes and the SWAP_* constants. Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-20subpage_prot.2: Use syscall(SYS_...); for system calls without a wrapperAlejandro Colomar1-6/+9
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-20statx.2: SYNOPSIS: Fix includesAlejandro Colomar1-2/+1
<unistd.h> doesn't seem to be needed: AT_* constants come from <fcntl.h> STATX_* constants come from <sys/stat.h> 'struct statx' comes from <sys/stat.h> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-20stat.2: SYNOPSIS: Fix includesAlejandro Colomar1-2/+1
Remove <sys/types.h>; ffix too <sys/types.h> is only needed for 'struct stat'. That is better documented in system_data_types(7). Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-20spu_run.2: Use syscall(SYS_...), for system calls without a wrapperAlejandro Colomar1-5/+7
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-20pipe.2: SYNOPSIS: Fix incorrect prototypeAlejandro Colomar1-1/+1
A function declarator with empty parentheses, which is not a prototype, is an obsolescent feature of C (See C17 6.11.6.1), and doesn't mean 0 parameters, but instead that no information about the parameters is provided (See C17 6.5.2.2). Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-20spu_create.2: Use syscall(SYS_...), for system calls without a wrapperAlejandro Colomar1-8/+10
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-20spu_create.2: Remove <sys/types.h>Alejandro Colomar1-1/+0
It's only needed for getting 'mode_t'. But that type is better documented in system_data_types(7). Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-20seccomp.2: Use syscall(SYS_...); for system calls without a wrapperAlejandro Colomar1-6/+8
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-20seccomp.2: Document why each header is neededAlejandro Colomar1-5/+5
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Cc: Kees Cook <keescook@chromium.org> Cc: Tyler Hicks <tyhicks@canonical.com> Cc: Will Drewry <wad@chromium.org> Cc: Michael Kerrisk <mtk.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: Add caveats regarding emulation of blocking system callsMichael Kerrisk1-0/+46
Reported-by: Sargun Dhillon <sargun@sargun.me> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: Reformat ioctls as subsections rather than hanging listMichael Kerrisk1-61/+52
Doing so decreases the degree to which text is indented, and thus avoids short, poorly wrapped lines. Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: Document the SECCOMP_IOCTL_NOTIF_ADDFD ioctl()Michael Kerrisk1-0/+211
Starting from some notes by Sargun Dhillon. Reported-by: Sargun Dhillon <sargun@sargun.me> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: EXAMPLES: simplify logic in getTargetPathname()Michael Kerrisk1-13/+7
And reword some comments there. Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: EXAMPLES: fix a file descriptor leakMichael Kerrisk1-3/+2
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: EXAMPLES: some code modularity improvementsMichael Kerrisk1-29/+47
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: Minor cleanup fixMichael Kerrisk1-1/+1
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: Change name of SECCOMP_IOCTL_NOTIF_ID_VALID functionMichael Kerrisk1-8/+7
Give this function a shorter, slightly easier to read name. Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: Fixes after review comments from Christian BraunerMichael Kerrisk1-2/+28
Reported-by: Christian Brauner <christian.brauner@canonical.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: A cookie check is also required after reading target's memoryMichael Kerrisk1-1/+92
Quoting Jann Horn: [[ As discussed at <https://lore.kernel.org/r/CAG48ez0m4Y24ZBZCh+Tf4ORMm9_q4n7VOzpGjwGF7_Fe8EQH=Q@mail.gmail.com>, we need to re-check checkNotificationIdIsValid() after reading remote memory but before using the read value in any way. Otherwise, the syscall could in the meantime get interrupted by a signal handler, the signal handler could return, and then the function that performed the syscall could free() allocations or return (thereby freeing buffers on the stack). In essence, this pread() is (unavoidably) a potential use-after-free read; and to make that not have any security impact, we need to check whether UAF read occurred before using the read value. This should probably be called out elsewhere in the manpage, too... Now, of course, **reading** is the easy case. The difficult case is if we have to **write** to the remote process... because then we can't play games like that. If we write data to a freed pointer, we're screwed, that's it. (And for somewhat unrelated bonus fun, consider that /proc/$pid/mem is originally intended for process debugging, including installing breakpoints, and will therefore happily write over "readonly" private mappings, such as typical mappings of executable code.) So, uuuuh... I guess if anyone wants to actually write memory back to the target process, we'd better come up with some dedicated API for that, using an ioctl on the seccomp fd that magically freezes the target process inside the syscall while writing to its memory, or something like that? And until then, the manpage should have a big fat warning that writing to the target's memory is simply not possible (safely). ]] and <https://lore.kernel.org/r/CAG48ez0m4Y24ZBZCh+Tf4ORMm9_q4n7VOzpGjwGF7_Fe8EQH=Q@mail.gmail.com>: [[ The second bit of trouble is that if the supervisor is so oblivious that it doesn't realize that syscalls can be interrupted, it'll run into other problems. Let's say the target process does something like this: int func(void) { char pathbuf[4096]; sprintf(pathbuf, "/tmp/blah.%d", some_number); mount("foo", pathbuf, ...); } and mount() is handled with a notification. If the supervisor just reads the path string and immediately passes it into the real mount() syscall, something like this can happen: target: starts mount() target: receives signal, aborts mount() target: runs signal handler, returns from signal handler target: returns out of func() supervisor: receives notification supervisor: reads path from remote buffer supervisor: calls mount() but because the stack allocation has already been freed by the time the supervisor reads it, the supervisor just reads random garbage, and beautiful fireworks ensue. So the supervisor *fundamentally* has to be written to expect that at *any* time, the target can abandon a syscall. And every read of remote memory has to be separated from uses of that remote memory by a notification ID recheck. And at that point, I think it's reasonable to expect the supervisor to also be able to handle that a syscall can be aborted before the notification is delivered. ]] Reported-by: Jann Horn <jannh@google.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: wfixMichael Kerrisk1-2/+2
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: EXAMPLES: make SECCOMP_IOCTL_NOTIF_ID_VALID function ↵Michael Kerrisk1-25/+35
return bool - Rename the function that does the SECCOMP_IOCTL_NOTIF_ID_VALID check. - Make that function return a 'bool' rather than terminating the process. - Use that return value in the calling function. - Rework/improve various related comments. Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: EXAMPLES: Improve comments describing ↵Michael Kerrisk1-6/+10
checkNotificationIdIsValid() Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: EXAMPLES: make getTargetPathname() a bit more generically ↵Michael Kerrisk1-7/+11
useful Allow the caller to specify which system call argument should be looked up as a pathname. Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: SEE ALSO: add pidfd_open(2) and pidfd_getfd(2)Michael Kerrisk1-0/+2
pidfd_open(2) and pidfd_getfd(2) presumably have use cases with the user-space notification feature. Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: NOTES: describe an example use-caseMichael Kerrisk1-0/+23
The container manager use case was the original motivation for this feature. Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: Remove FIXME asking about usefulness of POLLOUT/EPOLLOUTMichael Kerrisk1-2/+0
According to Tycho Andersen, he had no particular use case in mind when building this detail into the API. Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: srcfix: Add a further FIXME relating to SA_RESTART behaviorMichael Kerrisk1-0/+9
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: Various fixes after review comments from Kees CookMichael Kerrisk1-16/+63
Reported-by: Kees Cook <keescook@chromium.org> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: Update a FIXMEMichael Kerrisk1-0/+5
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: Describe the interaction with SA_RESTART signal handlersMichael Kerrisk1-0/+38
And, as noted by Jann Horn, note how the user-space notification mechanism causes a small breakage in the user-space API with respect to nonrestartable system calls. ==== From the email discussion with Jann Horn > >> So, I partially demonstrated what you describe here, for two example > >> system calls (epoll_wait() and pause()). But I could not exactly > >> demonstrate things as I understand you to be describing them. (So, > >> I'm not sure whether I have not understood you correctly, or > >> if things are not exactly as you describe them.) > >> > >> Here's a scenario (A) that I tested: > >> > >> 1. Target installs seccomp filters for a blocking syscall > >> (epoll_wait() or pause(), both of which should never restart, > >> regardless of SA_RESTART) > >> 2. Target installs SIGINT handler with SA_RESTART > >> 3. Supervisor is sleeping (i.e., is not blocked in > >> SECCOMP_IOCTL_NOTIF_RECV operation). > >> 4. Target makes a blocking system call (epoll_wait() or pause()). > >> 5. SIGINT gets delivered to target; handler gets called; > >> ***and syscall gets restarted by the kernel*** > >> > >> That last should never happen, of course, and is a result of the > >> combination of both the user-notify filter and the SA_RESTART flag. > >> If one or other is not present, then the system call is not > >> restarted. > >> > >> So, as you note below, the UAPI gets broken a little. > >> > >> However, from your description above I had understood that > >> something like the following scenario (B) could occur: > >> > >> 1. Target installs seccomp filters for a blocking syscall > >> (epoll_wait() or pause(), both of which should never restart, > >> regardless of SA_RESTART) > >> 2. Target installs SIGINT handler with SA_RESTART > >> 3. Supervisor performs SECCOMP_IOCTL_NOTIF_RECV operation (which > >> blocks). > >> 4. Target makes a blocking system call (epoll_wait() or pause()). > >> 5. Supervisor gets seccomp user-space notification (i.e., > >> SECCOMP_IOCTL_NOTIF_RECV ioctl() returns > >> 6. SIGINT gets delivered to target; handler gets called; > >> and syscall gets restarted by the kernel > >> 7. Supervisor performs another SECCOMP_IOCTL_NOTIF_RECV operation > >> which gets another notification for the restarted system call. > >> > >> However, I don't observe such behavior. In step 6, the syscall > >> does not get restarted by the kernel, but instead returns -1/EINTR. > >> Perhaps I have misconstructed my experiment in the second case, or > >> perhaps I've misunderstood what you meant, or is it possibly the > >> case that things are not quite as you said? > > Thanks for the code, Jann (including the demo of the CLONE_FILES > technique to pass the notification FD to the supervisor). > > But I think your code just demonstrates what I described in > scenario A. So, it seems that I both understood what you > meant (because my code demonstrates the same thing) and > also misunderstood what you said (because I thought you > were meaning something more like scenario B). Ahh, sorry, I should've read your mail more carefully. Indeed, that testcase only shows scenario A. But the following shows scenario B... [Below, two pieces of code from Jann, with a lot of cosmetic changes by mtk.] ==== [And from a follow-up in the same email thread:] > If userspace relies on non-restarting behavior, it should be using > something like epoll_pwait(). And that stuff only unblocks signals > after we've already past the seccomp checks on entry. Thanks for elaborating that detail, since as soon as you talked about "enlarging a preexisting race" above, I immediately wondered sigsuspend(), pselect(), etc. (Mind you, I still wonder about the effect on system calls that are normally nonrestartable because they have timeouts. My understanding is that the kernel doesn't restart those system calls because it's impossible for the kernel to restart the call with the right timeout value. I wonder what happens when those system calls are restarted in the scenario we're discussing.) Anyway, returning to your point... So, to be clear (and to quickly remind myself in case I one day reread this thread), there is not a problem with sigsuspend(), pselect(), ppoll(), and epoll_pwait() since: * Before the syscall, signals are blocked in the target. * Inside the syscall, signals are still blocked at the time the check is made for seccomp filters. * If a seccomp user-space notification event kicks, the target is put to sleep with the signals still blocked. * The signal will only get delivered after the supervisor either triggers a spoofed success/failure return in the target or the supervisor sends a CONTINUE response to the kernel telling it to execute the target's system call. Either way, there won't be any restarting of the target's system call (and the supervisor thus won't see multiple notifications). ==== Scenario A $ ./seccomp_unotify_restart_scen_A C: installed seccomp: fd 3 C: woke 1 waiters P: child installed seccomp fd 3 C: About to call pause(): Success P: going to send SIGUSR1... C: sigusr1_handler handler invoked P: about to terminate C: got pdeath signal on parent termination C: about to terminate /* Modified version of code from Jann Horn */ #define _GNU_SOURCE #include <stdio.h> #include <signal.h> #include <err.h> #include <errno.h> #include <unistd.h> #include <stdlib.h> #include <sched.h> #include <stddef.h> #include <limits.h> #include <sys/mman.h> #include <sys/syscall.h> #include <sys/prctl.h> #include <linux/seccomp.h> #include <linux/filter.h> #include <linux/futex.h> struct { int seccomp_fd; } *shared; static void sigusr1_handler(int sig, siginfo_t * info, void *uctx) { printf("C: sigusr1_handler handler invoked\n"); } static void sigusr2_handler(int sig, siginfo_t * info, void *uctx) { printf("C: got pdeath signal on parent termination\n"); printf("C: about to terminate\n"); exit(0); } int main(void) { setbuf(stdout, NULL); /* Allocate memory that will be shared by parent and child */ shared = mmap(NULL, 0x1000, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_SHARED, -1, 0); if (shared == MAP_FAILED) err(1, "mmap"); shared->seccomp_fd = -1; /* glibc's clone() wrapper doesn't support fork()-style usage */ /* Child process and parent share file descriptor table */ pid_t child = syscall(__NR_clone, CLONE_FILES | SIGCHLD, NULL, NULL, NULL, 0); if (child == -1) err(1, "clone"); /* CHILD */ if (child == 0) { /* don't outlive the parent */ prctl(PR_SET_PDEATHSIG, SIGUSR2); if (getppid() == 1) exit(0); /* Install seccomp filter */ prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0); struct sock_filter insns[] = { BPF_STMT(BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, nr)), BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, __NR_pause, 0, 1), BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_USER_NOTIF), BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_ALLOW) }; struct sock_fprog prog = { .len = sizeof(insns) / sizeof(insns[0]), .filter = insns }; int seccomp_ret = syscall(__NR_seccomp, SECCOMP_SET_MODE_FILTER, SECCOMP_FILTER_FLAG_NEW_LISTENER, &prog); if (seccomp_ret < 0) err(1, "install"); printf("C: installed seccomp: fd %d\n", seccomp_ret); /* Place the notifier FD number into the shared memory */ __atomic_store(&shared->seccomp_fd, &seccomp_ret, __ATOMIC_RELEASE); /* Wake the parent */ int futex_ret = syscall(__NR_futex, &shared->seccomp_fd, FUTEX_WAKE, INT_MAX, NULL, NULL, 0); printf("C: woke %d waiters\n", futex_ret); /* Establish SA_RESTART handler for SIGUSR1 */ struct sigaction act = { .sa_sigaction = sigusr1_handler, .sa_flags = SA_RESTART | SA_SIGINFO }; if (sigaction(SIGUSR1, &act, NULL)) err(1, "sigaction"); struct sigaction act2 = { .sa_sigaction = sigusr2_handler, .sa_flags = 0 }; if (sigaction(SIGUSR2, &act2, NULL)) err(1, "sigaction"); /* Make a blocking system call */ perror("C: About to call pause()"); pause(); perror("C: pause returned"); exit(0); } /* PARENT */ /* Wait for futex wake-up from child */ int futex_ret = syscall(__NR_futex, &shared->seccomp_fd, FUTEX_WAIT, -1, NULL, NULL, 0); if (futex_ret == -1 && errno != EAGAIN) err(1, "futex wait"); /* Get notification FD from the child */ int fd = __atomic_load_n(&shared->seccomp_fd, __ATOMIC_ACQUIRE); printf("\tP: child installed seccomp fd %d\n", fd); sleep(1); printf("\tP: going to send SIGUSR1...\n"); kill(child, SIGUSR1); sleep(1); printf("\tP: about to terminate\n"); exit(0); } ==== Scenario B $ ./seccomp_unotify_restart_scen_B C: installed seccomp: fd 3 C: woke 1 waiters C: About to call pause() P: child installed seccomp fd 3 P: about to SECCOMP_IOCTL_NOTIF_RECV P: got notif: id=17773741941218455591 pid=25052 nr=34 P: about to send SIGUSR1 to child... P: about to SECCOMP_IOCTL_NOTIF_RECV C: sigusr1_handler handler invoked P: got notif: id=17773741941218455592 pid=25052 nr=34 P: about to send SIGUSR1 to child... P: about to SECCOMP_IOCTL_NOTIF_RECV C: sigusr1_handler handler invoked P: got notif: id=17773741941218455593 pid=25052 nr=34 P: about to send SIGUSR1 to child... P: about to SECCOMP_IOCTL_NOTIF_RECV C: sigusr1_handler handler invoked P: got notif: id=17773741941218455594 pid=25052 nr=34 P: about to send SIGUSR1 to child... C: sigusr1_handler handler invoked C: got pdeath signal on parent termination C: about to terminate /* Modified version of code from Jann Horn */ #define _GNU_SOURCE #include <stdio.h> #include <signal.h> #include <err.h> #include <errno.h> #include <unistd.h> #include <stdlib.h> #include <sched.h> #include <stddef.h> #include <string.h> #include <limits.h> #include <inttypes.h> #include <sys/mman.h> #include <sys/syscall.h> #include <sys/ioctl.h> #include <sys/prctl.h> #include <linux/seccomp.h> #include <linux/filter.h> #include <linux/futex.h> struct { int seccomp_fd; } *shared; static void sigusr1_handler(int sig, siginfo_t * info, void *uctx) { printf("C: sigusr1_handler handler invoked\n"); } static void sigusr2_handler(int sig, siginfo_t * info, void *uctx) { printf("C: got pdeath signal on parent termination\n"); printf("C: about to terminate\n"); exit(0); } static size_t max_size(size_t a, size_t b) { return (a > b) ? a : b; } int main(void) { setbuf(stdout, NULL); /* Allocate memory that will be shared by parent and child */ shared = mmap(NULL, 0x1000, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_SHARED, -1, 0); if (shared == MAP_FAILED) err(1, "mmap"); shared->seccomp_fd = -1; /* glibc's clone() wrapper doesn't support fork()-style usage */ /* Child process and parent share file descriptor table */ pid_t child = syscall(__NR_clone, CLONE_FILES | SIGCHLD, NULL, NULL, NULL, 0); if (child == -1) err(1, "clone"); /* CHILD */ if (child == 0) { /* don't outlive the parent */ prctl(PR_SET_PDEATHSIG, SIGUSR2); if (getppid() == 1) exit(0); /* Install seccomp filter */ prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0); struct sock_filter insns[] = { BPF_STMT(BPF_LD | BPF_W | BPF_ABS, offsetof(struct seccomp_data, nr)), BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, __NR_pause, 0, 1), BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_USER_NOTIF), BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_ALLOW) }; struct sock_fprog prog = { .len = sizeof(insns) / sizeof(insns[0]), .filter = insns }; int seccomp_ret = syscall(__NR_seccomp, SECCOMP_SET_MODE_FILTER, SECCOMP_FILTER_FLAG_NEW_LISTENER, &prog); if (seccomp_ret < 0) err(1, "install"); printf("C: installed seccomp: fd %d\n", seccomp_ret); /* Place the notifier FD number into the shared memory */ __atomic_store(&shared->seccomp_fd, &seccomp_ret, __ATOMIC_RELEASE); /* Wake the parent */ int futex_ret = syscall(__NR_futex, &shared->seccomp_fd, FUTEX_WAKE, INT_MAX, NULL, NULL, 0); printf("C: woke %d waiters\n", futex_ret); /* Establish SA_RESTART handler for SIGUSR1 */ struct sigaction act = { .sa_sigaction = sigusr1_handler, .sa_flags = SA_RESTART | SA_SIGINFO }; if (sigaction(SIGUSR1, &act, NULL)) err(1, "sigaction"); struct sigaction act2 = { .sa_sigaction = sigusr2_handler, .sa_flags = 0 }; if (sigaction(SIGUSR2, &act2, NULL)) err(1, "sigaction"); /* Make a blocking system call */ printf("C: About to call pause()\n"); pause(); perror("C: pause returned"); exit(0); } /* PARENT */ /* Wait for futex wake-up from child */ int futex_ret = syscall(__NR_futex, &shared->seccomp_fd, FUTEX_WAIT, -1, NULL, NULL, 0); if (futex_ret == -1 && errno != EAGAIN) err(1, "futex wait"); /* Get notification FD from the child */ int fd = __atomic_load_n(&shared->seccomp_fd, __ATOMIC_ACQUIRE); printf("\tP: child installed seccomp fd %d\n", fd); /* Discover seccomp buffer sizes and allocate notification buffer */ struct seccomp_notif_sizes sizes; if (syscall(__NR_seccomp, SECCOMP_GET_NOTIF_SIZES, 0, &sizes)) err(1, "notif_sizes"); struct seccomp_notif *notif = malloc(max_size(sizeof(struct seccomp_notif), sizes.seccomp_notif)); if (!notif) err(1, "malloc"); for (int i = 0; i < 4; i++) { printf("\tP: about to SECCOMP_IOCTL_NOTIF_RECV\n"); memset(notif, '\0', sizes.seccomp_notif); if (ioctl(fd, SECCOMP_IOCTL_NOTIF_RECV, notif)) err(1, "notif_recv"); printf("\tP: got notif: id=%llu pid=%u nr=%d\n", notif->id, notif->pid, notif->data.nr); sleep(1); printf("\tP: about to send SIGUSR1 to child...\n"); kill(child, SIGUSR1); } sleep(1); exit(0); } ==== Reported-by: Jann Horn <jannh@google.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: EXAMPLE: correct the check for NUL in buffer returned by ↵Michael Kerrisk1-7/+7
read() In the usual case, read(fd, buf, PATH_MAX) will return PATH_MAX bytes that include trailing garbage after the pathname. So the right check is to scan from the start of the buffer to see if there's a NUL, and error if there is not. Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: Better handling of invalid target pathnameMichael Kerrisk1-17/+23
After some discussions with Jann Horn, perhaps a better way of dealing with an invalid target pathname is to trigger an error for the system call. Reported-by: Jann Horn <jannh@google.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: EXAMPLE: rename a variableMichael Kerrisk1-5/+5
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: EXAMPLE: Improve allocation of response bufferMichael Kerrisk1-1/+14
From a conversation with Jann Horn: [[ >>>> struct seccomp_notif_resp *resp = malloc(sizes.seccomp_notif_resp); >>> >>> This should probably do something like max(sizes.seccomp_notif_resp, >>> sizeof(struct seccomp_notif_resp)) in case the program was built >>> against new UAPI headers that make struct seccomp_notif_resp big, but >>> is running under an old kernel where that struct is still smaller? >> >> I'm confused. Why? I mean, if the running kernel says that it expects >> a buffer of a certain size, and we allocate a buffer of that size, >> what's the problem? > > Because in userspace, we cast the result of malloc() to a "struct > seccomp_notif_resp *". If the kernel tells us that it expects a size > smaller than sizeof(struct seccomp_notif_resp), then we end up with a > pointer to a struct that consists partly of allocated memory, partly > of out-of-bounds memory, which is generally a bad idea - I'm not sure > whether the C standard permits that. And if userspace then e.g. > decides to access some member of that struct that is beyond what the > kernel thinks is the struct size, we get actual OOB memory accesses. Got it. (But gosh, this seems like a fragile API mess.) I added the following to the code: /* When allocating the response buffer, we must allow for the fact that the user-space binary may have been built with user-space headers where 'struct seccomp_notif_resp' is bigger than the response buffer expected by the (older) kernel. Therefore, we allocate a buffer that is the maximum of the two sizes. This ensures that if the supervisor places bytes into the response structure that are past the response size that the kernel expects, then the supervisor is not touching an invalid memory location. */ size_t resp_size = sizes.seccomp_notif_resp; if (sizeof(struct seccomp_notif_resp) > resp_size) resp_size = sizeof(struct seccomp_notif_resp); struct seccomp_notif_resp *resp = malloc(resp_size); ]] Reported-by: Jann Horn <jannh@google.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: EXAMPLE: ensure path read() by the supervisor is ↵Michael Kerrisk1-0/+11
null-terminated From a conversation with Jann Horn: >> We should probably make sure here that the value we read is actually >> NUL-terminated? > > So, I was curious about that point also. But, (why) are we not > guaranteed that it will be NUL-terminated? Because it's random memory filled by another process, which we don't necessarily trust. While seccomp notifiers aren't usable for applying *extra* security restrictions, the supervisor will still often be more privileged than the supervised process. Reported-by: Jann Horn <jannh@google.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: wfix in example programMichael Kerrisk1-1/+1
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: Small wording fixMichael Kerrisk1-1/+1
Change "read(2) will return 0" to "read(2) may return 0". Quoting Jann Horn: Maybe make that "may return 0" instead of "will return 0" - reading from /proc/$pid/mem can only return 0 in the following cases AFAICS: 1. task->mm was already gone at open() time 2. mm->mm_users has dropped to zero (the mm only has lazytlb users; page tables and VMAs are being blown away or have been blown away) 3. the syscall was called with length 0 When a process has gone away, normally mm->mm_users will drop to zero, but someone else could theoretically still be holding a reference to the mm (e.g. someone else in the middle of accessing /proc/$pid/mem). (Such references should normally not be very long-lived though.) Additionally, in the unlikely case that the OOM killer just chomped through the page tables of the target process, I think the read will return -EIO (same error as if the address was simply unmapped) if the address is within a non-shared mapping. (Maybe that's something procfs could do better...) Reported-by: Jann Horn <jannh@google.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: Minor wording change + add a FIXMEMichael Kerrisk1-1/+3
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: User-space notification can't be used to implement ↵Michael Kerrisk1-0/+50
security policy Add some strongly worded text warning the reader about the correct uses of seccomp user-space notification. Reported-by: Jann Horn <jannh@google.com> Cowritten-by: Christian Brauner <christian@brauner.io> Cowritten-by: Kees Cook <keescook@chromium.org> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: Fixes after review comments from Christian BraunerMichael Kerrisk1-14/+21
Reported-by: Christian Brauner <christian@brauner.io> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp.2, seccomp_unotify.2: Clarify that there can be only one ↵Michael Kerrisk2-0/+12
SECCOMP_FILTER_FLAG_NEW_LISTENER Reported-by: Christian Brauner <christian@brauner.io> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: Note when FD indicates EOF/(E)POLLHUP in (e)poll/selectMichael Kerrisk1-0/+10
Verified by experiment. Reported-by: Christian Brauner <christian.brauner@canonical.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: Note when notification FD indicates as writable by ↵Michael Kerrisk1-3/+13
select/poll/epoll Reported-by: Tycho Andersen <tycho@tycho.pizza> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: Minor fixesMichael Kerrisk1-5/+5
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: Fixes after review comments by Jann HornMichael Kerrisk1-86/+121
Reported-by: Jann Horn <jannh@google.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: Add BUGS section describing SECCOMP_IOCTL_NOTIF_RECV bugMichael Kerrisk1-0/+10
Tycho Andersen confirmed that this issue is present. Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: srcfix: remove bogus FIXMEMichael Kerrisk1-6/+0
Pathname arguments are limited to PATH_MAX bytes. Reported-by: Tycho Andersen <tycho@tycho.pizza> Reported-by: Jann Horn <jannh@google.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: Changes after feed back from Tycho AndersenMichael Kerrisk1-8/+6
Reported-by: Tycho Andersen <tycho@tycho.pizza> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp_unotify.2: Document the seccomp user-space notification mechanismMichael Kerrisk1-0/+1318
The APIs used by this mechanism comprise not only seccomp(2), but also a number of ioctl(2) operations. And any useful example demonstrating these APIs is will necessarily be rather long. Trying to cram all of this into the seccomp(2) page would make that page unmanageably long. Therefore, let's document this mechanism in a separate page. Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp.2: Note that SECCOMP_RET_USER_NOTIF can be overriddenMichael Kerrisk1-0/+4
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp.2: wfix: mention term "supervisor" in description of ↵Michael Kerrisk1-2/+2
SECCOMP_RET_USER_NOTIF Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp.2: SEE ALSO: add seccomp_unotify(2)Michael Kerrisk1-0/+1
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp.2: Rework SECCOMP_GET_NOTIF_SIZES somewhatMichael Kerrisk1-8/+5
The existing text says the structures (plural!) contain a 'struct seccomp_data'. But this is only true for the received notification structure (seccomp_notif). So, reword the sentence to be more general, noting simply that the structures may evolve over time. Add some comments to the structure definition. Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp.2: Add some details for SECCOMP_FILTER_FLAG_NEW_LISTENERMichael Kerrisk1-2/+3
Rework the description a little, and note that the close-on-exec flag is set for the returned file descriptor. Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp.2: Minor edits to Tycho's SECCOMP_FILTER_FLAG_NEW_LISTENER patchMichael Kerrisk1-5/+9
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp.2: Document SECCOMP_FILTER_FLAG_NEW_LISTENERTycho Andersen1-0/+7
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp.2: Reorder list of SECCOMP_SET_MODE_FILTER flags alphabeticallyMichael Kerrisk1-14/+14
(No content changes.) Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp.2: Some reworking of Tycho's SECCOMP_RET_USER_NOTIF patchMichael Kerrisk1-6/+11
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp.2: Document SECCOMP_RET_USER_NOTIFTycho Andersen1-0/+11
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp.2: Minor edits to Tycho Andersen's patchMichael Kerrisk1-7/+15
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10seccomp.2: Document SECCOMP_GET_NOTIF_SIZESTycho Andersen1-0/+24
Signed-off-by: Tycho Andersen <tycho@tycho.ws> CC: Kees Cook <keescook@chromium.org> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10socketcall.2: srcfixMichael Kerrisk1-1/+0
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10socketcall.2: Use syscall(SYS_...); for system calls without a wrapperAlejandro Colomar1-7/+9
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10sigprocmask.2: Use syscall(SYS_...); for raw system callsAlejandro Colomar1-2/+6
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10shmop.2: Remove unused includeAlejandro Colomar1-1/+0
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10sgetmask.2: Use syscall(SYS_...); for system calls without a wrapperAlejandro Colomar1-7/+8
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10set_tid_address.2: Use syscall(SYS_...); for system calls without a wrapperAlejandro Colomar1-6/+7
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10set_thread_area.2: Use syscall(SYS_...); for system calls without a wrapperAlejandro Colomar1-12/+12
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10rt_sigqueueinfo.2: Use syscall(SYS_...); for system calls without a wrapperAlejandro Colomar1-3/+8
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-06-10open.2: Remove unused <sys/stat.h>Alejandro Colomar1-1/+0
I can't see a reason to include it. <fcntl.h> provides O_* constants for 'flags', S_* constants for 'mode', and mode_t. Probably a long time ago, some of those weren't defined in <fcntl.h>, and both headers needed to be included, or maybe it's a historical error. Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-21setresuid.2: tfix (Oxford comma)Michael Kerrisk1-1/+1
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-20select.2: Strengthen the warning regarding the low value of FD_SETSIZEMichael Kerrisk1-9/+12
All modern code should avoid select(2) in favor of poll(2) or epoll(7). For a long history of this problem, see: https://marc.info/?l=bugtraq&m=110660879328901 List: bugtraq Subject: SECURITY.NNOV: Multiple applications fd_set structure bitmap array index overflow From: 3APA3A <3APA3A () security ! nnov ! ru> Date: 2005-01-24 20:30:08 https://sourceware.org/legacy-ml/libc-alpha/2003-05/msg00171.html User-settable FD_SETSIZE and select() From: mtk-lists at gmx dot net To: libc-alpha at sources dot redhat dot com Date: Mon, 19 May 2003 14:49:03 +0200 (MEST) Subject: User-settable FD_SETSIZE and select() https://sourceware.org/bugzilla/show_bug.cgi?id=10352 http://0pointer.net/blog/file-descriptor-limits.html https://twitter.com/pid_eins/status/1394962183033868292 Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-20select.2: Relocate sentence about the fd_set value-result arguments to BUGSMichael Kerrisk1-6/+7
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-17sched_setattr.2: Use syscall(SYS_...); for system calls without a wrapperAlejandro Colomar1-6/+10
Document also why each header is required Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-17s390_sthyi.2: Use syscall(SYS_...); for system calls without a wrapperAlejandro Colomar1-7/+9
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-17s390_sthyi.2: Replace numeric constant by its name (macro)Alejandro Colomar1-2/+5
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Eugene Syromyatnikov <evgsyr@gmail.com> Cc: QingFeng Hao <haoqf@linux.vnet.ibm.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-17s390_runtime_instr.2: Use syscall(SYS_...); for system calls without a wrapperAlejandro Colomar1-6/+8
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-17s390_pci_mmio_write.2: Use syscall(SYS_...); for system calls without a ↵Alejandro Colomar1-7/+7
wrapper; fix includes too This function doesn't use any flags or special types, so there's no reason to include <asm/unistd.h>; remove it. Add the includes needed for syscall(2) only. Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-17s390_guarded_storage.2: Use syscall(SYS_...); for system calls without a wrapperAlejandro Colomar1-6/+10
Also document why each header is needed. Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-17rename.2: ffixAlejandro Colomar1-1/+1
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-17memfd_create.2, mmap.2, shmget.2: Document the EPERM for huge page allocationsMichael Kerrisk3-1/+32
This error can occur if the caller is does not have CAP_IPC_LOCK and is not a member of the sysctl_hugetlb_shm_group. Reported-by: Yang Xu <xuyang2018.jy@fujitsu.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11getdents.2: ffixMichael Kerrisk1-1/+1
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11reboot.2: Use syscall(SYS_...); for system calls without a wrapperAlejandro Colomar1-5/+7
Explain also why headers are needed. And some ffix. Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11readlink.2: ffixAlejandro Colomar1-1/+1
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11readdir.2: Use syscall(SYS_...); for system calls without a wrapperAlejandro Colomar1-5/+7
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11quotactl.2: Better detail why <xfs/xqm.h> is includedAlejandro Colomar1-1/+3
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11process_madvise.2: Use syscall(SYS_...); for system calls without a wrapper. ↵Alejandro Colomar1-8/+12
Fix includes too. Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11poll.2: Remove <signal.h>Alejandro Colomar1-2/+1
It is only used for providing 'sigset_t'. We're only documenting (with some exceptions) the includes needed for constants and the prototype itself. And 'sigset_t' is better documented in system_data_types(7). Remove that include. Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11pivot_root.2: Use syscall(SYS_...); for system calls without a wrapperAlejandro Colomar1-5/+9
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11pipe.2: wfixAlejandro Colomar1-2/+2
For consistency with other pages. Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11pidfd_send_signal.2: Use syscall(SYS_...); for system calls without a ↵Alejandro Colomar1-6/+10
wrapper. Fix includes too Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11pidfd_open.2: Use syscall(SYS_...); for system calls without a wrapperAlejandro Colomar1-5/+8
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11pidfd_getfd.2: Use syscall(SYS_...); for system calls without a wrapperAlejandro Colomar1-5/+9
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11perf_event_open.2: Use syscall(SYS_...); for system calls without a wrapperAlejandro Colomar1-10/+11
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11openat2.2: Use syscall(SYS_...); for system calls without a wrapper; fix ↵Alejandro Colomar1-9/+11
includes too Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11alloc_hugepages.2, arch_prctl.2, capget.2, clone.2, delete_module.2, ↵Alejandro Colomar9-0/+50
exit_group.2, get_robust_list.2, getunwind.2, init_module.2: Add note about the use of syscall(2) Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11mq_getsetattr.2: Use syscall(SYS_...); for system calls without a wrapperAlejandro Colomar1-9/+6
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11modify_ldt.2: Use syscall(SYS_...); for system calls without a wrapperAlejandro Colomar1-5/+10
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11mmap2.2: Use syscall(SYS_...); for system calls without a wrapperAlejandro Colomar1-4/+6
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11mknod.2: Remove unused includesAlejandro Colomar1-2/+0
All of the constants used by mknod() are defined in <sys/stat.h>. Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11mincore.2: Remove unused includeAlejandro Colomar1-1/+0
AFAICS, there's no use for <unistd.h> here. The prototype is declared in <sys/mman.h>, and there are no constants needed. Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11membarrier.2: Use syscall(SYS_...); for system calls without a wrapperAlejandro Colomar1-6/+10
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11lookup_dcookie.2: Use syscall(SYS_...); for system calls without a wrapperAlejandro Colomar1-5/+9
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11llseek.2: Use syscall(SYS_...); for system calls without a wrapperAlejandro Colomar1-6/+7
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11link.2: ffixAlejandro Colomar1-1/+1
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11keyctl.2: Use syscall(SYS_...); for system calls without a glibc wrapperAlejandro Colomar1-10/+7
Remove the libkeyutils prototype from the synopsis, which isn't documented in the rest of the page, and as NOTES says, it's probably better to use the various library functions. Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11kexec_load.2: Use syscall(SYS_...); for system calls without a wrapperAlejandro Colomar1-11/+13
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11kcmp.2: tfixAlejandro Colomar1-1/+1
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11kcmp.2: Use syscall(SYS_...); for system calls without a wrapperAlejandro Colomar1-7/+9
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11ipc.2: Add needed includeAlejandro Colomar1-0/+1
The constants needed for using this function are defined in <linux/ipc.h>. Add the include, even when those constants are not mentioned in this manual page. Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11ipc.2: Use syscall(SYS_...); for system calls without a wrapperAlejandro Colomar1-7/+11
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11ioprio_set.2: Use syscall(SYS_...); for system calls without a wrapperAlejandro Colomar1-6/+9
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11ioperm.2: Remove obvious commentAlejandro Colomar1-1/+1
Of course that is for the glibc wrapper. As all of the other pages that don't explicitly say otherwise. Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11io_getevents.2: Use syscall(SYS_...); for system calls without a wrapperAlejandro Colomar1-10/+11
In this case there's a wrapper provided by libaio, but this page documents the raw syscall. Also remove <linux/time.h> from the includes: 'struct timespec' is already documented in system_data_types(7), where the information is more up to date. Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11io_destroy.2: Use syscall(SYS_...); for system calls without a wrapperAlejandro Colomar1-7/+9
In this case there's a wrapper provided by libaio, but this page documents the raw syscall. Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11ioctl_userfaultfd.2: SYNOPSIS: Add <linux/userfaultfd.h>Alejandro Colomar1-0/+1
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11ioctl_tty.2: Fix includesAlejandro Colomar1-3/+3
<sys/ioctl.h> is needed for the prototype of ioctl(). That header also provides most of the constants used by the function. Only a few of those constants are not provided by that header, and need <termios.h>; clarify which constants do need that include. ...... $ <man2/ioctl_tty.2 \ sed -n '/^.SH DESCRIPTION/,/^.SH/p' \ |grep -e '^\.B' -e TIOCM \ |sed 's/^\.B[^ ]* //' \ |awk '{print $1}' \ |grep '^[[:upper:]]' \ |grep -v -e '^CAP' -e '^E' -e '^SIG' -e '^O_' -e '^[TR]XD$' -e '^POLL' \ |sort \ |uniq \ |while read f; do \ find /usr/include/ -type f \ |xargs grep -l "define\s$f" \ |grep -q ioctl.*.h \ ||echo $f \ |while read ff; do \ echo "============ $ff"; \ find /usr/include/ -type f \ |xargs grep -n "define\s$ff"; \ done; \ done; ============ CLOCAL /usr/include/asm-generic/termbits.h:142:#define CLOCAL 0004000 /usr/include/gphoto2/gphoto2-port-portability.h:127:# define CLOCAL 0x00000800 /usr/include/x86_64-linux-gnu/bits/termios-c_cflag.h:34:#define CLOCAL 0004000 ============ TCIFLUSH /usr/include/asm-generic/termbits.h:191:#define TCIFLUSH 0 /usr/include/x86_64-linux-gnu/bits/termios.h:70:#define TCIFLUSH 0 ============ TCIOFF /usr/include/asm-generic/termbits.h:187:#define TCIOFF 2 /usr/include/x86_64-linux-gnu/bits/termios.h:66:#define TCIOFF 2 ============ TCIOFLUSH /usr/include/asm-generic/termbits.h:193:#define TCIOFLUSH 2 /usr/include/x86_64-linux-gnu/bits/termios.h:72:#define TCIOFLUSH 2 ============ TCION /usr/include/asm-generic/termbits.h:188:#define TCION 3 /usr/include/x86_64-linux-gnu/bits/termios.h:67:#define TCION 3 ============ TCOFLUSH /usr/include/asm-generic/termbits.h:192:#define TCOFLUSH 1 /usr/include/x86_64-linux-gnu/bits/termios.h:71:#define TCOFLUSH 1 ============ TCOOFF /usr/include/asm-generic/termbits.h:185:#define TCOOFF 0 /usr/include/x86_64-linux-gnu/bits/termios.h:64:#define TCOOFF 0 ============ TCOON /usr/include/asm-generic/termbits.h:186:#define TCOON 1 /usr/include/x86_64-linux-gnu/bits/termios.h:65:#define TCOON 1 ============ TIOCREMOTE ============ TIOCSTART ============ TIOCSTOP ============ TIOCTTYGSTRUCT ============ TIOCUCNTL Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11getdents.2: Use syscall(SYS_...); for system calls without a wrapperAlejandro Colomar1-5/+15
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11futex.2: Use syscall(SYS_...); for system calls without a wrapperAlejandro Colomar1-10/+11
At the same time, document only headers that are required for calling the function, or those that are specific to the function: <unistd.h> is required for the syscall() prototype. <sys/syscall.h> is required for the syscall name SYS_xxx. <linux/futex.h> is specific to this syscall. However, uint32_t is generic enough that it shouldn't be documented here. The system_data_types(7) page already documents it, and is more precise about it. The same goes for timespec. As a general rule a man[23] page should document the header that includes the prototype, and all of the headers that define macros that should be used with the call. However, the information about types should be restricted to system_data_types(7) (and that page should probably be improved by adding types), except for types that are very specific to the call. Otherwise, we're duplicating info and it's then harder to maintain, and probably outdated in the future. Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11execveat.2: Remove unused includeAlejandro Colomar1-1/+0
This complements commit e3eba861bd966911b38b7ebc572f0c092ca7bdee. Since we don't need syscall(2) anymore, we don't need SYS_* definitions. Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-11open.2: Fix bug in linkat(2) call exampleAlejandro Colomar1-1/+1
AT_EMPTY_PATH works with empty strings (""), but not with NULL (or at least it's not obvious). The relevant kernel code is the following: linux$ sed -n 189,198p fs/namei.c result->refcnt = 1; /* The empty path is special. */ if (unlikely(!len)) { if (empty) *empty = 1; if (!(flags & LOOKUP_EMPTY)) { putname(result); return ERR_PTR(-ENOENT); } } Reported-by: Walter Harms <wharms@bfs.de> Cc: Theodore Ts'o <tytso@mit.edu> Cc: Adam Borowski <kilobyte@angband.pl> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-10epoll_wait.2: Move subsection to NOTES from BUGSAlejandro Colomar1-12/+12
'C library/kernel differences' was added to BUGS incorrectly. Fix it Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-10sched_get_priority_max.2, open_memstream.3: tfixAlejandro Colomar1-1/+1
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-10clone.2: tfixAlejandro Colomar1-1/+1
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-10signalfd.2: tfixAkihiro Motoki1-1/+1
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-10semctl.2: ffixAkihiro Motoki1-1/+1
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-10move_pages.2: ffixAkihiro Motoki1-0/+1
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-10execve.2: tfixŠtěpán Němec1-1/+1
Signed-off-by: Štěpán Němec <stepnem@gmail.com> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-10shmop.2: tfixVishwajith K1-2/+2
Signed-off-by: Vishwajith K <vishuvikas1996@gmail.com> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-10sigwaitinfo.2: tfixAlejandro Colomar1-1/+1
Fix wording issue introduced in commit bf1298c9e5053f55dea43e74255dae5ec57f251e. Reported-by: Chris Keilbart <keilbartchris@gmail.com> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-10exit_group.2, getunwind.2: tfixJakub Wilk2-2/+2
Signed-off-by: Jakub Wilk <jwilk@jwilk.net> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-10ptrace.2: mention PTRACE_GET_SYSCALL_INFO in RETURN VALUE sectionDmitry V. Levin1-2/+5
Mirror the wording about PTRACE_GET_SYSCALL_INFO return value semantics from "DESCRIPTION" section to "RETURN VALUE" section. Reported-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Complements: fc91449cb "ptrace.2: Document PTRACE_GET_SYSCALL_INFO" Signed-off-by: Dmitry V. Levin <ldv@altlinux.org> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-10move_pages.2: ffixDmitry V. Levin1-1/+1
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-10clone.2: tfixJohannes Berg1-1/+1
Despite my mention of this spawning a hilarious discussion on IRC, this alignment restriction should be 128-bit, not 126-bit. Signed-off-by: Johannes Berg <johannes@sipsolutions.net> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-10sigaltstack.2: tfixBorislav Petkov1-1/+1
Add a missing "to" in an "in order to" formulation. Signed-off-by: Borislav Petkov <bp@suse.de> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2021-05-10flock.2: add CIFS detailsAurelien Aptel1-0/+25
CIFS flock() locks behave differently than the standard. Give overview of those differences. Here is the rendered text: CIFS details In Linux kernels up to 5.4, flock() is not propagated over SMB. A file with such locks will not appear locked for remote clients. Since Linux 5.5, flock() locks are emulated with SMB byte-range locks on the entire file. Similarly to NFS, this means that fcntl(2) and flock() locks interact with one another. Another important side-effect is that the locks are not advisory anymore: any IO on a locked file will always fail with EACCES when done from a separate file descriptor. This difference originates from the design of locks in the SMB proto- col, which provides mandatory locking semantics. Remote and mandatory locking semantics may vary with SMB protocol, mount options and server type. See mount.cifs(8) for additional infor- mation. Signed-off-by: Aurelien Aptel <aaptel@suse.com> Discussion: linux-man <https://lore.kernel.org/linux-man/20210302154831.17000-1-aaptel@suse.com/> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com> Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>