Commit graph

1448 commits

Author SHA1 Message Date
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
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
Dmitry Chagin
130e811991 linux(4): Add LINUX_RATELIMIT_MSG macro for future use.
Differential Revision:	https://reviews.freebsd.org/D31488
MFC after:		2 weeks

(cherry picked from commit 0d77f6c0c3)
2022-06-17 22:33:32 +03:00
Dmitry Chagin
3af6bc9d02 linux(4): Implement CLONE_CLEAR_SIGHAND option bit.
CLONE_CLEAR_SIGHAND is designed to reset all signal handlers of the child
not set to SIG_IGN to SIG_DFL.

Reviewed by:		kib
Differential revision:	https://reviews.freebsd.org/D31481
MFC after:		2 weeks

(cherry picked from commit c5fc9fe7f3)
2022-06-17 22:33:31 +03:00
Dmitry Chagin
b5a5c0b684 linux(4): Add CLONE_PIDFD option bit.
Differential revision:	https://reviews.freebsd.org/D31478
MFC after:		2 weeks

(cherry picked from commit a796845d6d)
2022-06-17 22:33:31 +03:00
Dmitry Chagin
b27e302329 linux(4): Implement clone3 system call.
clone3 system call is used by glibc-2.34.

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

(cherry picked from commit 17913b0b6b)
2022-06-17 22:33:30 +03:00
Dmitry Chagin
8fb3f959dc linux(4): Add struct clone_args for future clone3 system call.
In preparation for clone3 system call add struct clone_args and use it in
clone implementation.
Move all of clone related bits to the newly created linux_fork.h header.

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

(cherry picked from commit 0a4b664ae8)
2022-06-17 22:33:30 +03:00
Dmitry Chagin
b2c247a0db linux(4): Change clone syscall definition to match Linux actual one.
Differential revision:	https://reviews.freebsd.org/D31473
MFC after:		2 weeks

(cherry picked from commit f1c450492f)
2022-06-17 22:33:29 +03:00
Dmitry Chagin
5eb6549994 linux(4): Plug in aarch64 fcntl flags.
Fixes opendir() libc function.

Differential Revision:	https://reviews.freebsd.org/D31357
MFC after:		2 weeks

(cherry picked from commit fc37be2460)
2022-06-17 22:33:27 +03:00
Dmitry Chagin
15e715fe7c linux(4): Implement faccessat2 system call.
It's used by bash on arm64 with glibc-2.32.

Reviewed by:		trasz
Differential Revision:	https://reviews.freebsd.org/D31345
MFC after:		2 weeks

(cherry picked from commit 13d79be995)
2022-06-17 22:33:26 +03:00
Dmitry Chagin
7989803dba linux(4): Fix futex copyrights.
As no more NetBSD code in futexes exists replace NetBSD copyrights by
standard FreeBSD 2 clause license.
Add Roman Divacky's copyrights as an author of the robust futexes.

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

(cherry picked from commit 6e31bed646)
2022-06-17 22:33:26 +03:00
Dmitry Chagin
6ac42e4042 linux(4): Eliminate a now unused includes after futexes refactoring.
MFC after:		2 weeks

(cherry picked from commit 2411ac0b89)
2022-06-17 22:33:25 +03:00
Dmitry Chagin
fdc3cb3233 linux(4): Add a comment about wait/requeue pi operations.
MFC after:		2 weeks

(cherry picked from commit d90df8ac13)
2022-06-17 22:33:25 +03:00
Dmitry Chagin
7e8aeb42e4 linux(4): Handle incorrect FUTEX_CLOCK_REALTIME option bit.
Return ENOSYS if the FUTEX_CLOCK_REALTIME option bit is specified for an
inappropriate futex operation.

MFC after:		2 weeks

(cherry picked from commit 626cbd4648)
2022-06-17 22:33:24 +03:00
Dmitry Chagin
315b002b53 linux(4): Handle FUTEX_LOCK_PI2 oeration.
FUTEX_LOCK_PI2 was added to support clock selection as FUTEX_LOCK_PI uses a
CLOCK_REALTIME based absolute value since it was implemented, but it does not
require that the FUTEX_CLOCK_REALTIME bit is set, because that was introduced
later.

MFC after:		2 weeks

(cherry picked from commit a9bb1b1c18)
2022-06-17 22:33:24 +03:00
Dmitry Chagin
0b55f31e01 linux(4): Use variable name not type for sizeof() to calculate storage size.
MFC after:		2 weeks

(cherry picked from commit bd25bf092a)
2022-06-17 22:33:24 +03:00
Dmitry Chagin
0ea12e483d linux(4): Move len variable initialization to the appropriate place.
MFC after:		2 weeks

(cherry picked from commit 49a5c0409b)
2022-06-17 22:33:23 +03:00
Dmitry Chagin
5761cfdf77 linux(4): Use linux_tdfind() in get_robust_list.
In the Linux emulation layer linux_tdfind() has a special purpose to
handle glibc specific TID mangling and we should use it instead of tdfind().

MFC after:		2 weeks

(cherry picked from commit c8e9d2b7eb)
2022-06-17 22:33:23 +03:00
Dmitry Chagin
94f1c67b24 linux(4): Eliminate unnecessary error initialization.
MFC after:		2 weeks

(cherry picked from commit f88d3c522f)
2022-06-17 22:33:23 +03:00
Dmitry Chagin
552c32b989 linux(4): Eliminate unnecessary head initialization.
MFC after:		2 weeks

(cherry picked from commit 6b68e8af1f)
2022-06-17 22:33:22 +03:00
Dmitry Chagin
1735342c90 linux(4): style, wrap too long line.
MFC after:		2 weeks

(cherry picked from commit 971b53fa04)
2022-06-17 22:33:22 +03:00
Dmitry Chagin
0783310f4d linux(4): Eliminating remnants of futex sdt.
MFC after:		2 weeks

(cherry picked from commit edd44176aa)
2022-06-17 22:33:22 +03:00
Dmitry Chagin
14f6f3bdcf linux(4): Handle special case for regular futex in handle_futex_death().
Handle some races in handle_futex_death() which can prevents a wakeup of
potential waiters which can cause these waiters to block forever.

Differential Revision:	https://reviews.freebsd.org/D31280
MFC after:		2 weeks

(cherry picked from commit b59cf25eac)
2022-06-17 22:33:21 +03:00
Dmitry Chagin
df49edfec8 linux(4): Futex address must be 32-bit aligned.
Linux futex documentation explicitly states that EINVAL is returned if
the futex is not 4-byte aligned. Check futex alignment as a Linux do
and return EINVAL.

Differential Revision:	https://reviews.freebsd.org/D31279
MFC after:		2 weeks

(cherry picked from commit dad1077056)
2022-06-17 22:33:21 +03:00
Dmitry Chagin
f1a621bee3 linux(4): Finish cf8d74e3fe.
Add forgotten val3_compare initialization in case of time64 futex.

MFC after:		2 weeks

(cherry picked from commit b33e469027)
2022-06-17 22:33:20 +03:00
Dmitry Chagin
696c311172 linux(4): Replace casuword32 by casueword32.
Follow the r349951 (30b3018d), add check to react to stops and requests
to terminate between retries.

Reviewed by:		kib
Differential Revision:	https://reviews.freebsd.org/D31254
MFC after:		2 weeks

(cherry picked from commit 4f34dc6453)
2022-06-17 22:33:20 +03:00
Dmitry Chagin
fbd982e09f linux(4): Implement pi futexes using umtx.
Differential Revision:	https://reviews.freebsd.org/D31240
MFC after:		2 weeks

(cherry picked from commit 7a718f293a)
2022-06-17 22:33:20 +03:00
Dmitry Chagin
b6b070eed2 linux(4): Replace copyin() by fueword32() in handle_futex_death().
According to fetch(9) fueword facility designed to fetch atomically
small amount of data from user space.

Reviewed by:		kib
Differential Revision:	https://reviews.freebsd.org/D31239
MFC after:		2 weeks

(cherry picked from commit cb01cc4a10)
2022-06-17 22:33:19 +03:00
Dmitry Chagin
71c876b6c1 linux(4): Eliminate unused includes.
MFC after:		2 weeks

(cherry picked from commit b9c89fa39e)
2022-06-17 22:33:18 +03:00
Dmitry Chagin
02d2ef1dd7 linux(4): Reimplement futexes using umtx.
Differential Revision:	https://reviews.freebsd.org/D31236
MFC after:		2 weeks

(cherry picked from commit 0dc38e3303)
2022-06-17 22:33:17 +03:00
Dmitry Chagin
f51368016d umtx: Split umtx.h on two counterparts.
To prevent umtx.h polluting by future changes split it on two headers:
umtx.h - ABI header for userspace;
umtxvar.h - the kernel staff.

While here fix umtx_key_match style.

Reviewed by:		kib
Differential Revision:	https://reviews.freebsd.org/D31248
MFC after:		2 weeks

(cherry picked from commit af29f39958)
2022-06-17 22:33:15 +03:00
Dmitry Chagin
85b2ff6496 linux(4): Fix gcc buld.
gcc failed as it didn't inlined the builtins and generates calls to
the libgcc, ld can't find libgcc as cross-toolchain libgcc is not installed.
To avoid this add internal vDSO ffs functions without optimized builtins.

Reported by:		jhb
MFC after:		2 weeks

(cherry picked from commit f337940144)
2022-06-17 22:33:14 +03:00
Dmitry Chagin
e6a169af5c linux(4): Factor out the futex_wait() op into linux_futex_wait().
MFC after:		2 weeks

(cherry picked from commit 75cb2382b8)
2022-06-17 22:33:13 +03:00
Dmitry Chagin
acb45ac680 linux(4): Prevent an endless loop.
In the futex_atomic_op() the encoded_op is a user-supplied parameter.
If the user specifies an incorrect value for this parameter paired with a valid
*uaddr parameter the caller will go into the endless loop. To prevent this check
futex_atomic_op() result and break the loop in case of ENOSYS.

MFC after:		2 weeks

(cherry picked from commit ef4251e271)
2022-06-17 22:33:12 +03:00
Dmitry Chagin
ee847258e3 linux(4): Eliminate bogus comment.
For the caller is no need for access checking here, as the caller must take care
of EFAULT handling. Moreover, this check would be superfluous, since EFAULT is
extremily rare, and we prefer the fast path.

MFC after:		2 weeks

(cherry picked from commit 80b8d6b144)
2022-06-17 22:33:12 +03:00