Commit graph

4159 commits

Author SHA1 Message Date
Dmitry Chagin
b2f336bb73 linux(4): Implement sched_rr_get_interval_time64 syscall.
MFC after:		2 weeks

(cherry picked from commit 8c84ca657b)
2022-06-17 22:34:15 +03:00
Dmitry Chagin
9d4b1eba0e linux(4): Add epoll_pwai2 syscall.
MFC after:	2 weeks

(cherry picked from commit e00aad1042)
2022-06-17 22:34:10 +03:00
Dmitry Chagin
92870cb499 linux(4): Add copyin_sigset() helper.
MFC after:	2 weeks

(cherry picked from commit 3923e63209)
2022-06-17 22:34:04 +03:00
Dmitry Chagin
2d05c4f018 linux(4): Add linux_epoll_pwait_ts() helper for future use.
MFC after:	2 weeks

(cherry picked from commit 27a25179c8)
2022-06-17 22:34:04 +03:00
Dmitry Chagin
c78e5c4c6a linux(4): Copyout pselect timeout.
According to pselect6 manual, on error timeout becomes undefined, by fact
Linux modifies the timeout and ignore EFAULT error if so.

MFC after:	2 weeks

(cherry picked from commit 5171ed79f6)
2022-06-17 22:34:04 +03:00
Dmitry Chagin
302cff0ef9 linux(4): Add a simple rseq syscall implementation.
To avoid annoyng messages from glibc-2.35 test suite add the simple
implementation of rseq syscall which is do nothing for now.

I plan to implement it if and when the API stabilizes.

MFC after:	2 weeks

(cherry picked from commit ee55d560e8)
2022-06-17 22:34:03 +03:00
Dmitry Chagin
7056934698 linux(4): Refactor signal send methods.
Created a couple of helpers to send signals to the specific thread or to
the whole process. Use helpers in the corresponding syscalls.
This fixes the confusion where a signal destined for a whole process
was sent to a specific thread and vice versa.
There is an exclusion for the linux_kill() syscall that takes a pid
argument and should send a signal to the whole process, but I know
at least one example where kill() takes tid.

MFC after:		2 weeks

(cherry picked from commit 6201a50d0d)
2022-06-17 22:33:55 +03:00
Dmitry Chagin
e4de536940 linux(4): Check that the thread tid in the thread group pid in linux_tdfind().
MFC after:		2 weeks

(cherry picked from commit fe894a3705)
2022-06-17 22:33:54 +03:00
Dmitry Chagin
cadaecc91e linux(4): Microoptimize bsd_to_linux_sockaddr().
Differential Revision:	https://reviews.freebsd.org/D34725
MFC after:		2 weeks

(cherry picked from commit bbddd5881d)
2022-06-17 22:33:54 +03:00
Dmitry Chagin
c5789e62ba Add timespecvalid_interval macro and use it.
Reviewed by:		jhb, imp (early rev)
Differential revision:	https://reviews.freebsd.org/D34848
MFC after:		2 weeks

(cherry picked from commit 91e7bdcdcf)
2022-06-17 22:33:53 +03:00
Dmitry Chagin
c3dfbacbe9 linux(4): Copyout actual size of addr to the user space in accept().
Differential Revision:	https://reviews.freebsd.org/D34727

(cherry picked from commit 673bce11ce)
2022-06-17 22:33:52 +03:00
Dmitry Chagin
ecf8f49968 linux(4): Limit user-supplied sockaddr length in recvfrom().
Differential Revision:	https://reviews.freebsd.org/D34726

(cherry picked from commit bb0f644cd6)
2022-06-17 22:33:52 +03:00
Dmitry Chagin
543eaf070e linux(4): Remove unnecessary PTRIN().
(cherry picked from commit 68bfaefb3d)
2022-06-17 22:33:52 +03:00
Dmitry Chagin
61337dfb34 linux(4): Handle SO_DOMAIN in getsockopt syscall.
Differential revision:	https://reviews.freebsd.org/D34714

(cherry picked from commit cf312f799a)
2022-06-17 22:33:51 +03:00
Dmitry Chagin
d33fba34ab linux(4): Prevent an attempt to copy an uninitialized source address.
PR:			259380
MFC after:		3 days

(cherry picked from commit bb46e9b510)
2022-06-17 22:33:50 +03:00
Fernando Apesteguía
c43c6efaee [linprocfs] add sys/kernel/random/boot_id
This file holds a UUID that is invariant for every boot. In our case, it is
invariant per mount.

PR:	262369
Reported by:	sodynet1@gmail.com
Approved by:	dchagin@
Differential Revision:	https://reviews.freebsd.org/D34860

(cherry picked from commit 0f2041a5b0)
2022-06-17 22:33:50 +03:00
Dmitry Chagin
9f870e779c linux(4): Fix a typo in itimerspec conversion routine.
MFC after:	3 days

(cherry picked from commit 0938d04a2c)
2022-06-17 22:33:49 +03:00
Dmitry Chagin
6ea301ef77 linsysfs: plug set-but-not-used vars.
MFC after:	2 weeks

(cherry picked from commit bafe3b8804)
2022-06-17 22:33:49 +03:00
Dmitry Chagin
ac33f043f6 linux(4): Cleanup empty lines.
MFC after:		2 weeks

(cherry picked from commit 09d60bfae5)
2022-06-17 22:33:48 +03:00
Dmitry Chagin
c4ca1d2a27 linux(4): Fix KASSERT message.
MFC after:		2 weeks

(cherry picked from commit 4e1e83461b)
2022-06-17 22:33:48 +03:00
Dmitry Chagin
aeddbb898e linux(4): readlink should fail if bufzis <= 0.
MFC after:		2 weeks

(cherry picked from commit d6ccce0aa2)
2022-06-17 22:33:48 +03:00
Dmitry Chagin
708fc30050 linprocfs: Add /proc/self/oom_score_adj.
To avoid annoyng messages from LTP test suites add the simple
implementation of /proc/self/oom_score_adj which is do nothing.

Reviewed by:		emaste
Differential revision:  https://reviews.freebsd.org/D34710
MFC after:		2 weeks

(cherry picked from commit b7df7b987e)
2022-06-17 22:33:47 +03:00
Dmitry Chagin
82fa7c3b83 linux(4): Add compat.linux32.emulate_i386 knob.
Historically 32-bit Linuxulator under amd64 emulated the real i386
behavior. Since 3d8dd983 the old i386 Linux world can't be used under
amd64 Linuxulator as it don't know anything about amd64 machine (which
is returned now by newuname() syscall). So, add a knob to allow to swith
the behavior and use i386 Linux binaries on amd64.
Set knob to the new behavior as I think this is common to the modern
Linux distros.

Reviewed by:		Pau Amma (doc), emaste
Differential revision:	https://reviews.freebsd.org/D34708
MFC after:		2 weeks

(cherry picked from commit d5dc757e84)
2022-06-17 22:33:47 +03:00
Dmitry Chagin
71d5b525f5 linux(4): Fixup miscalculation of d_off of struct dirent in getdents() syscalls.
Avoid calculating d_off value as it is specific to the underlying filesystem
and can be used by others API, like lseek(), seekdir() as input offset.

Differential revision:  https://reviews.freebsd.org/D31551
MFC after:		2 weeks

(cherry picked from commit 099fa2feb3)
2022-06-17 22:33:46 +03:00
Dmitry Chagin
ccbef519e0 linux(4): wait4() returns ESRCH if pid is INT_MIN.
Weird and undocumented patch was added to the Linux kernel in 2017,
fixes wait403 LTP test.

MFC after:	2 weeks

(cherry picked from commit 9103c5582a)
2022-06-17 22:33:46 +03:00
Dmitry Chagin
65d3f90d13 linux(4): Rid unused defines from linux_mib.
Reviewed by:		trasz
Differential revision:  https://reviews.freebsd.org/D31591
MFC after:		2 weeks

(cherry picked from commit 5bcf0f7cd7)
2022-06-17 22:33:46 +03:00
Dmitry Chagin
cbb2112dca linux(4): Fixup waitid handling P_PGID idtype.
Since Linux 5.4, if id is zero, then wait for any child that is in the same
process grop as the caller's process group.

Differential revision:  https://reviews.freebsd.org/D31567
MFC after:		2 weeks

(cherry picked from commit 4e3aefb923)
2022-06-17 22:33:45 +03:00
Dmitry Chagin
2c029214d3 linux(4): Return ENOSYS for unsupported P_PIDFD waitid idtype.
Reviewed by:		emaste
Differential revision:  https://reviews.freebsd.org/D31559
MFC after:		2 weeks

(cherry picked from commit be1e4a0bdf)
2022-06-17 22:33:45 +03:00
Dmitry Chagin
638a0649cf linux(4): Add support for __WALL wait option bit.
As FreeBSD does not have __WALL option bit analogue explicitly set all
possible option bits to emulate Linux __WALL wait option bit.

Reviewed by:		emaste
Differential revision:  https://reviews.freebsd.org/D31555
MFC after:		2 weeks

(cherry picked from commit c7ef7c3fac)
2022-06-17 22:33:45 +03:00
Dmitry Chagin
7df3421cb6 linux(4): Fixup options value validation in linux_waitid().
Reviewed by:		emaste
Differential revision:  https://reviews.freebsd.org/D31554
MFC after:		2 weeks

(cherry picked from commit d7e1e138ec)
2022-06-17 22:33:44 +03:00
Dmitry Chagin
de1382dc4b linux(4): Eliminate bogus options value check validation.
The kernel do it for us.

Reviewed by:		emaste
Differential revision:  https://reviews.freebsd.org/D31553
MFC after:		2 weeks

(cherry picked from commit 2fd480b318)
2022-06-17 22:33:44 +03:00
Dmitry Chagin
721dcd87ab linux(4): Consolidate wait* facility into linux_common_wait().
Also fix bug in waitid() implementation, use wru_self not wru_children.

Differential revision:  https://reviews.freebsd.org/D31552
MFC after:		2 weeks

(cherry picked from commit 0c6b1ff7de)
2022-06-17 22:33:44 +03:00
Mateusz Guzik
6a8133e329 linux: plug set-but-not-unused vars
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 74a0e24f07)
2022-06-17 22:33:43 +03:00
Dmitry Chagin
221d908864 linux(4): Add AT_NO_AUTOMOUNT to statx.
Specific to Linux AT_NO_AUTOMOUNT flag tells the kernel to not automount the
terminal component of pathname if it is a directory that is an automount point.
As it is the default for FreeBSD silencly ignore this flag.

glibc-2.34 uses this flag in the stat64 system calls which is used by i386.

Reviewed by:		trasz
Differential revision:  https://reviews.freebsd.org/D31524
MFC after:		2 weeks

(cherry picked from commit ff39d74aa9)
2022-06-17 22:33:43 +03:00
Dmitry Chagin
a55eb1bdbf linprocfs: Eliminate bogus comment (KSE).
Reviewed by:		trasz, emaste
Differential revision:	https://reviews.freebsd.org/D31525
MFC after:		2 weeks

(cherry picked from commit aae8ae5ea5)
2022-06-17 22:33:42 +03:00
Mateusz Guzik
e09814f1f2 linprocfs: plug set-but-not-unused vars
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit ae3d955404)
2022-06-17 22:33:42 +03:00
Dmitry Chagin
d239c3416d linux(4): Improve comment.
Reported by:	pfg
MFC after:	2 weeks

(cherry picked from commit d4da692862)
2022-06-17 22:33:41 +03:00
Edward Tomasz Napierala
d005a6f2c8 linux: Provide dummy seccomp(2)
Don't emit messages; this isn't any different from a Linux kernel
built without OPTIONS_SECCOMP, so the userspace already needs to know
how to deal with it.  This is also similar with how we handle seccomp
in linux_prctl().

Sponsored By:	EPSRC
Differential Revision:	https://reviews.freebsd.org/D33808

(cherry picked from commit 99454d3e98)
2022-06-17 22:33:40 +03:00
Mateusz Guzik
0506fe6d3c linux: plug set-but-not-used vars
Sponsored by:	Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 0c8d7eebfd)
2022-06-17 22:33:40 +03:00
Mateusz Guzik
753605353d linux: remove the always curthread argument from lconvpath
(cherry picked from commit af4051d250)
2022-06-17 22:33:39 +03:00
John Baldwin
86bcdd9d34 linux_name_to_handle_at: Support AT_EMPTY_PATH.
Reviewed by:	kib
Sponsored by:	The University of Cambridge, Google Inc.
Differential Revision:	https://reviews.freebsd.org/D33050

(cherry picked from commit 8b2ce7a3bb)
2022-06-17 22:33:39 +03:00
John Baldwin
fd1b7d2519 linux_linkat: Don't invert AT_* flags.
Reviewed by:	kib
Sponsored by:	The University of Cambridge, Google Inc.
Differential Revision:	https://reviews.freebsd.org/D33048

(cherry picked from commit a8d885296a)
2022-06-17 22:33:38 +03:00
Edward Tomasz Napierala
5bce15eb9e linux(4): Fix "set but not used" warnings
No functional changes.

Sponsored By:	EPSRC

(cherry picked from commit a089c17d32)
2022-06-17 22:33:38 +03:00
Dmitry Chagin
862add4358 linux: Drop some unnecessary includes
Drop some unnecessary includes from Linuxulator ptrace
and coredump code.  No functional changes.

Sponsored By:   EPSRC
Differential Revision:  https://reviews.freebsd.org/D32925

(cherry picked from commit 06d5ef0aad)
2022-06-17 22:33:38 +03:00
Edward Tomasz Napierala
ca5426f938 linux: Replace ifdefs in ptrace with per-architecture callbacks
It's a cleanup; no (intended) functional changes.

Sponsored By:	EPSRC
Reviewed By:	kib
Differential Revision:	https://reviews.freebsd.org/D32888

(cherry picked from commit 0bf8d5d5f4)
2022-06-17 22:33:37 +03:00
Edward Tomasz Napierala
99950e8beb linux: Add ptrace(2) support on arm64
This moves linux_ptrace.c from sys/amd64/linux/ to sys/compat/linux/,
making it possible to use it on architectures other than amd64.
It also enables Linux ptrace(2) on arm64.

Relnotes:	yes
Sponsored By:	EPSRC
Differential Revision:	https://reviews.freebsd.org/D32868

(cherry picked from commit a90ff3c4bc)
2022-06-17 22:33:37 +03:00
Dmitry Chagin
177c7036e2 linux(4): Remove clone3 and faccessat2 from dummy.
MFC after:		2 weeks

(cherry picked from commit aecd31a8a3)
2022-06-17 22:33:34 +03:00
Dmitry Chagin
77032a9900 linux(4): Move ff variable initialization from declaration.
Modern style(9) allows variables initialization where they are declared,
but in this case initialization obfuscate the code.

MFC after:		2 weeks

(cherry picked from commit 1af0780b5f)
2022-06-17 22:33:33 +03:00
Dmitry Chagin
56d1afc72d linux(4): Verify that higher 32bits of exit_signal in clone3 are unset.
MFC after:		2 weeks

(cherry picked from commit c2cc5345b8)
2022-06-17 22:33:32 +03:00
Dmitry Chagin
59034620c4 linux(4): Return ENOSYS for unsupported clone3 option bits.
Differential Revision:	https://reviews.freebsd.org/D31483
MFC after:		2 weeks

(cherry picked from commit 4385147547)
2022-06-17 22:33:32 +03:00