Commit graph

2010 commits

Author SHA1 Message Date
Konstantin Belousov
9de9a33050 fexecve(2): allow O_PATH file descriptors opened without O_EXEC
(cherry picked from commit be10c0a910)
2021-11-06 04:12:33 +02:00
Konstantin Belousov
c802b970a5 procctl: actually require debug privileges over target
(cherry picked from commit f5bb6e5a6d)
2021-10-26 05:26:27 +03:00
Konstantin Belousov
2e69ba48b9 procctl(2): add consistent shortcut P_ID:0 as curproc
(cherry picked from commit f833ab9dd1)
2021-10-26 05:26:26 +03:00
Greg V
1625e2db22 O_PATH: allow vfs_extattr syscalls
(cherry picked from commit 98dae405de)
2021-10-16 16:01:47 +03:00
Jessica Clarke
d7b3f3c84e libc: Fix build on case-insensitive file systems
On case-insensitive file systems (most likely to be seen on macOS, where
it is the default), _Fork.o for the new POSIX _Fork function conflicts
with _fork.o for the PSEUDO file. This results in non-determinsitic
behaviour in terms of which ends up being present; if _Fork.o wins then
the build fails to link libc.so due to missing __sys_fork, and if
_fork.o wins then libc silently fails to include the implementation of
_Fork. A similar issue occurred in the past for C99's _Exit conflicting
with exit(2) and was fixed in cb1cb6a2a8, so this adds a fix based on
that.

As a longer-term solution it might be better to instead make the
generated files use a different prefix that's less likely to conflict
with other things (such as __sys_foo.o given they always contain that)
but that's a rather more invasive change.

Fixes:	49ad342cc1 ("Add _Fork()")
Reviewed by:	kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D31895

(cherry picked from commit 877175a17a)
2021-10-10 14:33:52 +01:00
Konstantin Belousov
156db35573 readlinkat(2): allow O_PATH fd
PR:	258856

(cherry picked from commit 5fb54d2fc8)
2021-10-10 12:22:58 +03:00
Konstantin Belousov
8c384596a8 Fix mistakes in link(2) and shm_open(2)
PR:	258957

(cherry picked from commit 8d3cd7767a)
2021-10-10 12:21:18 +03:00
Kyle Evans
b7e90b290a kqueue: document how timers with low/past timeouts are handled
(cherry picked from commit 4b5554cebb)
2021-10-06 02:04:00 -05:00
Konstantin Belousov
d4a478c270 procctl(2): Add PROC_WXMAP_CTL/STATUS
(cherry picked from commit 796a8e1ad1)
2021-09-24 03:26:59 +03:00
Edward Tomasz Napierala
e79a18dadf procctl(2): add PROC_NO_NEW_PRIVS_CTL, PROC_NO_NEW_PRIVS_STATUS
(cherry picked from commit db8d680ebe)
2021-09-24 03:26:59 +03:00
Mark Johnston
603c9bb029 kqueue.2: Document the fact that EVFILT_READ can be used on kqueues
Reviewed by:	bcr, kib
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit f756c91168)
2021-09-14 08:50:31 -04:00
Warner Losh
5918f48652 clock_gettime: Add Linux aliases for CLOCK_*
Linux standardized what we call CLOCK_{REALTIME,MONOTONIC}_FAST as
CLOCK_{REALTIME,MONOTONIC}_COARSE. In addition, Linux spells
CLOCK_UPTIME as CLOCK_BOOTTIME.

Add aliases to time.h and document these new aliases in
clock_gettime(2).

Reviewed by:		vangyzen, kib (prior), dchagin (prior)
Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D30988

(cherry picked from commit 155f15118a)
2021-09-12 09:56:16 -06:00
Kyle Evans
d511b903b9 kenv: allow listing of static kernel environments
The early environment is typically cleared, so these new options
need the PRESERVE_EARLY_KENV kernel config(8) option. These environments
are reported as missing by kenv(1) if the option is not present in the
running kernel.

(cherry picked from commit db0f264393)
2021-08-26 01:35:33 -05:00
Mark Johnston
acabc20906 kevent: Prohibit negative change and event list lengths
Previously, a negative change list length would be treated the same as
an empty change list.  A negative event list length would result in
bogus copyouts.  Make kevent(2) return EINVAL for both cases so that
application bugs are more easily found, and to be more robust against
future changes to kevent internals.

Reviewed by:	imp, kib
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit e00bae5c18)
2021-08-21 12:08:58 -04:00
Konstantin Belousov
5d7b612949 fork(2): comment about doubtful use of stdio and exit(3) in example
(cherry picked from commit 2a51e8823a)
2021-08-12 15:37:54 +03:00
Ceri Davies
f59374b69a fork.2: correct minor typo in manpage.
(cherry picked from commit 383dbdb2eb)
2021-08-12 15:37:54 +03:00
Konstantin Belousov
1c54a109d7 Add _Fork()
(cherry picked from commit 49ad342cc1)
2021-08-12 15:37:54 +03:00
Mateusz Piotrowski
3248a03c1a fork.2: Fix a typo in an example
(cherry picked from commit ca904beafd)
2021-08-12 15:37:54 +03:00
Mateusz Piotrowski
a9c0baa1d0 fork.2: Add a simple use pattern
(cherry picked from commit c4207d867c)
2021-08-12 15:37:54 +03:00
Roy Marples
f452713408 socket: Implement SO_RERROR
SO_RERROR indicates that receive buffer overflows should be handled as
errors. Historically receive buffer overflows have been ignored and
programs could not tell if they missed messages or messages had been
truncated because of overflows. Since programs historically do not
expect to get receive overflow errors, this behavior is not the
default.

This is really really important for programs that use route(4) to keep
in sync with the system. If we loose a message then we need to reload
the full system state, otherwise the behaviour from that point is
undefined and can lead to chasing bogus bug reports.

Reviewed by:	philip (network), kbowling (transport), gbe (manpages)
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D26652

(cherry picked from commit 7045b1603b)
2021-08-10 18:54:00 -07:00
Konstantin Belousov
f027b4f41f vdso: lower precision of vdso implementation of CLOCK_MONOTONIC_FAST and CLOCK_UPTIME_FAST
(cherry picked from commit 60b0ad10dd)
2021-06-30 07:42:06 +03:00
Konstantin Belousov
af9521f635 vdso gettimeofday: minor restructuring
(cherry picked from commit e912fbe167)
2021-06-30 07:41:58 +03:00
Konstantin Belousov
9c74a20681 ptrace: add an option to not kill debuggees on debugger exit
(cherry picked from commit fd3ac06f45)
2021-06-01 03:38:54 +03:00
Konstantin Belousov
824cca5934 openat(2): add O_EMPTY_PATH
(cherry picked from commit 5e7cdf1817)
2021-05-19 06:13:14 +03:00
Konstantin Belousov
51af250608 Add ptrace(PT_COREDUMP)
(cherry picked from commit 87a64872cd)
2021-05-10 04:03:06 +03:00
Piotr Pawel Stefaniak
c69775749f getdirentries.2: remove unnecessary space
(cherry picked from commit 1fdd6934d5)
2021-05-05 13:04:58 +02:00
Konstantin Belousov
46ec1227e7 connectat(2): clarify that the s argument is socket
(cherry picked from commit 07f229d20c)
2021-05-03 04:26:50 +03:00
Konstantin Belousov
f1d1021fde O_PATH: allow vnode kevent filter on such files
(cherry picked from commit bbf7a4e878)
2021-04-23 14:14:10 +03:00
Konstantin Belousov
7a24523086 Make files opened with O_PATH to not block non-forced unmount
(cherry picked from commit a5970a529c)
2021-04-23 14:14:10 +03:00
Konstantin Belousov
b0c1b3827e open(2): Implement O_PATH
(cherry picked from commit 8d9ed174f3)
2021-04-23 14:14:10 +03:00
Konstantin Belousov
73a642c479 Add AT_EMPTY_PATH for several *at(2) syscalls
(cherry picked from commit 509124b626)
2021-04-23 14:14:10 +03:00
Konstantin Belousov
8bffc9b492 link(2): correct descriptor name in AT_RESOLVE_BENEATH description
(cherry picked from commit c78e124535)
2021-04-23 14:14:09 +03:00
Konstantin Belousov
6da53183f9 open(2): Remove O_BENEATH and AT_BENEATH
(cherry picked from commit 20e91ca36a)
2021-03-04 21:10:44 +02:00
Konstantin Belousov
efc5f3d454 fhlink(2): the syscalls do not take flag
(cherry picked from commit 600756afb5)
2021-03-04 21:10:39 +02:00
Rick Macklem
b96e66349e getdirentries.2: fix for NFS mounts
It was reported that getdirentries(2) was
returning dirents with d_off set to 0 for an NFS
mount.

This is believed to be correct behaviour at
this time (it may change for some NFS mounts
in the future), but is inconsistent with what the
getdirentries(2) man page says.

This patch fixes the man page.

This is a content change.

PR:	253428

(cherry picked from commit a0698341cd)
2021-03-01 13:00:38 -08:00
Guangyuan Yang
12c2780888 pwrite(2): add a BUGS section
Add a BUGS section about using pwrite(2) when O_APPEND is set on the fd.

Submitted by:	Ka Ho Ng <khng300@gmail.com>
Reviewed by:	gbe, yuripv
Differential Revision:	https://reviews.freebsd.org/D28372

(cherry picked from commit 504e64af32)
2021-02-25 06:57:35 +00:00
Jamie Gritton
5dbb407145 MFC jail: Change both root and working directories in jail_attach(2)
jail_attach(2) performs an internal chroot operation, leaving it up to
the calling process to assure the working directory is inside the jail.

Add a matching internal chdir operation to the jail's root.  Also
ignore kern.chroot_allow_open_directories, and always disallow the
operation if there are any directory descriptors open.

Reported by:    mjg
Approved by:    markj, kib

(cherry picked from commit d4380c0cdd)
2021-02-21 21:49:40 -08:00
Alan Somers
ff1a307801 lio_listio: validate aio_lio_opcode
Previously, we would accept any kind of LIO_* opcode, including ones
that were intended for in-kernel use only like LIO_SYNC (which is not
defined in userland).  The situation became more serious with
022ca2fc7f.  After that revision, setting
aio_lio_opcode to LIO_WRITEV or LIO_READV would trigger an assertion.

Note that POSIX does not specify what should happen if aio_lio_opcode is
invalid.

MFC-with:	022ca2fc7f
Reviewed by:	jhb, tmunro, 0mp
Differential Revision:	<https://reviews.freebsd.org/D28078
2021-01-11 19:53:01 -07:00
Konstantin Belousov
21f749da82 libthr: wrap pdfork(2), same as fork(2).
Without wrapping, rtld services and malloc(3) are not guaranteed
to operate correctly in the forked child.

Reviewed by:	markj
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D28088
2021-01-11 22:59:52 +02:00
Thomas Munro
801ac943ea aio_fsync(2): Support O_DSYNC.
aio_fsync(O_DSYNC, ...) is the asynchronous version of fdatasync(2).

Reviewed by: kib, asomers, jhb
Differential Review: https://reviews.freebsd.org/D25071
2021-01-08 13:15:56 +13:00
Thomas Munro
a5e284038e open(2): Add O_DSYNC flag.
POSIX O_DSYNC means that writes include an implicit fdatasync(2), just
as O_SYNC implies fsync(2).

VOP_WRITE() functions that understand the new IO_DATASYNC flag can act
accordingly, but we'll still pass down IO_SYNC so that file systems that
don't understand it will continue to provide the stronger O_SYNC
behaviour.

Flag also applies to fcntl(2).

Reviewed by: kib, delphij
Differential Revision: https://reviews.freebsd.org/D25090
2021-01-08 13:15:56 +13:00
Alan Somers
022ca2fc7f Add aio_writev and aio_readv
POSIX AIO is great, but it lacks vectored I/O functions. This commit
fixes that shortcoming by adding aio_writev and aio_readv. They aren't
part of the standard, but they're an obvious extension. They work just
like their synchronous equivalents pwritev and preadv.

It isn't yet possible to use vectored aiocbs with lio_listio, but that
could be added in the future.

Reviewed by:    jhb, kib, bcr
Relnotes:       yes
Differential Revision: https://reviews.freebsd.org/D27743
2021-01-02 19:57:58 -07:00
Rick Macklem
d189a74dfd copy_file_range(2): add recommendation to use large "len"
PR#252358 reported a serious performance problem w.r.t.
cp(1) when copying large non-sparse files.
This problem appears to have been caused by cp(1)
calling copy_file_range(2) with a small "len" argument.

This patch adds a recommendation to use a large "len"
value where possible, for performance reasons.

Reviewed by:	asomers
Differential Revision:	https://reviews.freebsd.org/D27935
2021-01-02 17:21:21 -08:00
Konstantin Belousov
58b2ed4672 eventfd.2: Add the mail address of the submitter into copyright.
Requested by:	rgrimes
MFC after:	13 days
2020-12-28 21:03:16 +02:00
Konstantin Belousov
6d075fd9a5 Document eventfd().
Submitted by:   greg@unrelenting.technology
Reviewed by:    bcr, markj (previous version)
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D26668
2020-12-27 12:57:26 +02:00
Konstantin Belousov
0ef405eee9 kqueue(2): Use .Fo instead .Ft
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
2020-12-27 12:57:26 +02:00
Konstantin Belousov
44c5db52e2 Add eventfd(3) wrappers to libc.
eventfd_read/write one-liners are from musl libc.

Submitted by:   greg@unrelenting.technology
Reviewed by:    markj (previous version)
MFC after:      2 weeks
Differential Revision:  https://reviews.freebsd.org/D26668
2020-12-27 12:57:26 +02:00
Guangyuan Yang
a1d7836752 mmap(2): Update .Dd missed in the last commit
PR:		252097
MFC after:	1 week
2020-12-24 14:14:56 +00:00
Guangyuan Yang
81720dbab2 mmap(2): Fix a typo
PR:             252097
MFC after:      1 week
Reported by:    Nick Frampton <nick.frampton@akips.com>
2020-12-24 14:08:34 +00:00
Gordon Bergling
f6d234d870 libc: Fix most issues reported by mandoc
- varios "new sentence, new line" warnings
- varios "sections out of conventional order" warnings
- varios "unusual Xr order" warnings
- varios "missing section argument" warnings
- varios "no blank before trailing delimiter" warnings
- varios "normalizing date format" warnings

MFC after:	1 month
2020-12-19 14:54:28 +00:00