Commit graph

2032 commits

Author SHA1 Message Date
Thomas Munro
5fac6f1687 poll(2): Add POLLRDHUP.
Teach poll(2) to support Linux-style POLLRDHUP events for sockets, if
requested.  Triggered when the remote peer shuts down writing or closes
its end.

Reviewed by:	kib
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D29757

(cherry picked from commit 3aaaa2efde)
2022-06-17 22:22:13 +03:00
Gordon Bergling
2699604d8e libc: Add HISTORY sections to the manual pages
There are some sections which could be improved
and work to do so is on going. The work will be
covered via 'X-MFC-WITH' commits.

Obtained from:	OpenBSD
Differential Revision: https://reviews.freebsd.org/D34759

(cherry picked from commit 4b7f35db44)
2022-06-04 07:59:43 +02:00
Andrew Turner
658631a37d Add PT_GETREGSET
This adds the PT_GETREGSET and PT_SETREGSET ptrace types. These can be
used to access all the registers from a specified core dump note type.
The NT_PRSTATUS and NT_FPREGSET notes are initially supported. Other
machine-dependant types are expected to be added in the future.

The ptrace addr points to a struct iovec pointing at memory to hold the
registers along with its length. On success the length in the iovec is
updated to tell userspace the actual length the kernel wrote or, if the
base address is NULL, the length the kernel would have written.

Because the data field is an int the arguments are backwards when
compared to the Linux PTRACE_GETREGSET call.

Reviewed by:	kib
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D19831

(cherry picked from commit 548a2ec49b)
2022-05-12 15:12:59 -07:00
Alex Richardson
afab9d5ffe Export _mmap and __sys_mmap from libc.so
Unlike the other syscalls these two symbols were missing from the
version script. I noticed this while looking into the compiler-rt
runtime libraries for CHERI.

Reviewed by:	brooks
Obtained from:	https://github.com/CTSRD-CHERI/cheribsd/pull/1063
MFC after:	3 days

(cherry picked from commit 395db99f32)
2022-05-07 12:55:00 +01:00
Konstantin Belousov
6daddc54de Mostly revert a5970a529c: Make files opened with O_PATH to not block non-forced unmount
(cherry picked from commit bf13db086b)
2022-04-19 23:22:54 +03:00
Greg Lehey
01f095a355 chroot.2: Correct grammar errors.
No functional change.

MFC after:	1 week

(cherry picked from commit 4044083079)
2022-04-14 10:03:36 +10:00
Piotr Pawel Stefaniak
6018f775ce Mention kern.timecounter.alloweddeviation in nanosleep.2
PR:		224837
Reported by:	Aleksander Derevianko

(cherry picked from commit bf8f6ffcb6)
(cherry picked from commit 4f556830de)
2022-03-26 14:34:20 +01:00
Mateusz Guzik
8891979494 fd: add close_range(..., CLOSE_RANGE_CLOEXEC)
For compatibility with Linux.

MFC after:	3 days
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D34424

(cherry picked from commit f3f3e3c44d)
2022-03-07 12:15:47 +00:00
Konstantin Belousov
d0199f27c0 libc binuptime(): use the right function to get the most significant bit index
PR:	261781

(cherry picked from commit a1f9326607)
2022-02-15 02:36:51 +02:00
Kyle Evans
7393eedb03 execve: disallow argc == 0
The manpage has contained the following verbiage on the matter for just
under 31 years:

"At least one argument must be present in the array"

Previous to this version, it had been prefaced with the weakening phrase
"By convention."

Carry through and document it the rest of the way.  Allowing argc == 0
has been a source of security issues in the past, and it's hard to
imagine a valid use-case for allowing it.  Toss back EINVAL if we ended
up not copying in any args for *execve().

The manpage change can be considered "Obtained from: OpenBSD"

(cherry picked from commit 773fa8cd13)
(cherry picked from commit c9afc7680f)
2022-02-10 14:21:59 -06:00
Konstantin Belousov
5775b8b392 ptrace(2): document policies affecting access to the facility
(cherry picked from commit a393644ecb)
2022-01-29 03:10:45 +02:00
Konstantin Belousov
7a6364ac77 kqueue(2): Add note about format of the data for NOTE_EXIT
PR:	261346

(cherry picked from commit 7406ec4ea9)
2022-01-22 02:50:23 +02:00
Konstantin Belousov
a48d9f1900 Add sched_getcpu()
(cherry picked from commit 77b2c2f814)
2022-01-14 18:17:29 +02:00
Ed Maste
c56c2f0fe2 getfh: clarify that it is a privileged operation
Reviewed by:	kib
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D33629

(cherry picked from commit 5bc2e6e227)
2021-12-29 19:27:34 -05:00
Konstantin Belousov
0a50e517cd Document new variant of swapoff(2)
(cherry picked from commit 9f0fea5d03)
2021-12-20 02:29:11 +02:00
Konstantin Belousov
1791debf4a swapoff: add one more variant of the syscall
For MFC, COMPAT_FREEBSD13 braces were removed.

(cherry picked from commit 5346570276)
2021-12-20 02:29:11 +02:00
Konstantin Belousov
0c747a70c8 swapoff(2): document extended syscall arguments
(cherry picked from commit 79d650f262)
2021-12-20 02:29:11 +02:00
Florian Walpen
30c3a5f248 Add idle priority scheduling privilege group to MAC/priority
(cherry picked from commit a9545eede4)
2021-12-19 04:42:51 +02:00
Florian Walpen
984b9d89f8 MAC/priority module for realtime privilege group
PR:	239125

(cherry picked from commit bf2fa8d9d1)
2021-12-19 04:42:51 +02:00
Mark Johnston
a5659943e3 libc: Add pdfork to the list of interposed system calls
Otherwise the asm stub is used and libthr interposition does not work.

Reviewed by:	kib
Fixes:		21f749da82 ("libthr: wrap pdfork(2), same as fork(2).")
Sponsored by:	The FreeBSD Foundation

(cherry picked from commit cbdec8db18)
2021-12-13 08:26:58 -05:00
Konstantin Belousov
ba6f5ed72e fcntl(2): be more precise about third arg type
(cherry picked from commit 97722455cc)
2021-12-13 02:58:22 +02:00
Konstantin Belousov
9258e9e3a8 fcntl(2): add F_KINFO operation
(cherry picked from commit 794d3e8e63)
2021-12-13 02:58:22 +02:00
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