]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/log
FreeBSD/FreeBSD.git
2 years agolinux(4): Fix 039e98e6.
Dmitry Chagin [Mon, 9 May 2022 18:45:51 +0000 (21:45 +0300)]
linux(4): Fix 039e98e6.

The patch was about an year in my local queue and I still screwed up...

MFC after: 2 weeks

(cherry picked from commit bfae7fbaa2af43800589b666ac45897d513f4482)

2 years agolinux(4); Style.
Dmitry Chagin [Mon, 9 May 2022 18:16:48 +0000 (21:16 +0300)]
linux(4); Style.

MFC after: 2 weeks

(cherry picked from commit 109c2bd212574a12a472eed7f6e11196ce456e53)

2 years agolinux(4): Return native error from futex_atomic_op to avoid conversion by the caller.
Dmitry Chagin [Mon, 9 May 2022 18:16:31 +0000 (21:16 +0300)]
linux(4): Return native error from futex_atomic_op to avoid conversion by the caller.

MFC after: 2 weeks

(cherry picked from commit 07d108932ab5b5bc25221be4916ebf8874cd256f)

2 years agolinux(4): Fixed offset miscalculation in the preadv/pwritev syscalls.
Dmitry Chagin [Mon, 9 May 2022 18:11:37 +0000 (21:11 +0300)]
linux(4): Fixed offset miscalculation in the preadv/pwritev syscalls.

MFC after: 2 weeks

(cherry picked from commit b17446281d21311cc4f9d522c5d18337a9f786bc)

2 years agolinux(4): Regen for prctl syscall.
Dmitry Chagin [Fri, 17 Jun 2022 19:35:05 +0000 (22:35 +0300)]
linux(4): Regen for prctl syscall.

MFC after:              2 weeks

(cherry picked from commit e76857671873f0c9037dcc9c546b490714096c73)

2 years agolinux(4): Change prctl syscall definition to match Linux actual one.
Dmitry Chagin [Mon, 9 May 2022 18:09:39 +0000 (21:09 +0300)]
linux(4): Change prctl syscall definition to match Linux actual one.

Otherwise argX conversion leads to an unexpected behaviour.

MFC after: 2 weeks

(cherry picked from commit 039e98e60cb193fb0f8a86f23a26c049c46c27bd)

2 years agolinux(4): The futex_wait operation should restart.
Dmitry Chagin [Mon, 9 May 2022 18:08:59 +0000 (21:08 +0300)]
linux(4): The futex_wait operation should restart.

It's ok from the futex_wait perspective as umtxq_sleep method uses
absolute sleep timeout.

MFC after: 2 weeks

(cherry picked from commit 5eec19c8eb0e1afafd7290325c61611c9a13b621)

2 years agolinux(4): Use the right function to get the bit index in vdso binuptime.
Dmitry Chagin [Sun, 8 May 2022 14:20:52 +0000 (17:20 +0300)]
linux(4): Use the right function to get the bit index in vdso binuptime.

This is modeled after a1f93266 (by kib@).

MFC after: 2 weeks

(cherry picked from commit c6df21760381c3e48bcd412705de6f0ded9e4aae)

2 years agolinux(4): Implement vdso getcpu for x86.
Dmitry Chagin [Sun, 8 May 2022 14:20:52 +0000 (17:20 +0300)]
linux(4): Implement vdso getcpu for x86.

This is modeled after f2395455 (by kib@).

MFC after: 2 weeks

(cherry picked from commit 5a6a4fb284b1a9c4b4105fd6ab8143356f3ef3f7)

2 years agolinux(4): Refactor vdso_gettc_x86 includes.
Dmitry Chagin [Sun, 8 May 2022 14:20:51 +0000 (17:20 +0300)]
linux(4): Refactor vdso_gettc_x86 includes.

Factor out includes from common vdso_gettc_x86 file to the corresponding
MD files.

MFC after: 2 weeks

(cherry picked from commit 332eca05b557f4f9d108480688d9c0933f6ed06b)

2 years agolinux(4): Add a helper intended for copying timespec's from the userspace.
Dmitry Chagin [Sun, 8 May 2022 13:16:47 +0000 (16:16 +0300)]
linux(4): Add a helper intended for copying timespec's from the userspace.

There are many places where we copyin Linux timespec from the userspace
and then convert it to the kernel timespec. To avoid code duplication
add a tiny halper for doing this.

MFC after: 2 weeks

(cherry picked from commit 707e567a4061669b7643ddbe8a1ad9c4e6545a75)

2 years agolinux(4): Prevent time_t overflows on i386.
Dmitry Chagin [Sun, 8 May 2022 12:39:09 +0000 (15:39 +0300)]
linux(4): Prevent time_t overflows on i386.

As native i386 time_t is still 32-bit, check that the user-provided 64-bit
tv_sec value fits to the kernel time_t, return EOVERFLOW if not.

MFC after: 2 weeks

(cherry picked from commit 3dc2a06752b593acd1a76e784b169f3d60e81d00)

2 years agolinux(4): Zero out high order bits of nanoseconds in the compat mode.
Dmitry Chagin [Sun, 8 May 2022 12:38:19 +0000 (15:38 +0300)]
linux(4): Zero out high order bits of nanoseconds in the compat mode.

Assuming the kernel would use random data, the 64-bit Linux kernel ignores
upper 32 bits of tv_nsec of struct timespec64 for 32-bit binaries.

MFC after: 2 weeks

(cherry picked from commit 1579b320f1a4d555250b82fa74a391d963e7ae13)

2 years agolinux(4): Add a helper intended for copying timespec's to the userspace.
Dmitry Chagin [Sun, 8 May 2022 12:37:27 +0000 (15:37 +0300)]
linux(4): Add a helper intended for copying timespec's to the userspace.

There are many places where we convert natvie timespec and copyout it to
the userspace. To avoid code duplication add a tiny halper for doing this.

MFC after: 2 weeks

(cherry picked from commit 9a9482f87490bcbb054ba1799d69fdab7cdb6dc9)

2 years agolinux(4): Regen for ppoll_time64 syscall.
Dmitry Chagin [Fri, 17 Jun 2022 19:34:58 +0000 (22:34 +0300)]
linux(4): Regen for ppoll_time64 syscall.

MFC after:              2 weeks

(cherry picked from commit 61f45f6733d7536c442d14b30b435cfa6cd2f7cc)

2 years agolinux(4): Fix ppoll_time64 syscall definition.
Dmitry Chagin [Sun, 8 May 2022 10:37:48 +0000 (13:37 +0300)]
linux(4): Fix ppoll_time64 syscall definition.

Fixed my typo in ed61e0ce1d. Here tsp is a pointer to the 64-bit timespec.

MFC after: 2 weeks

(cherry picked from commit 94f5f150ef59d8e985bd529b0a6dea52ae8a7def)

2 years agolinux(4): Implement semtimedop syscalls.
Dmitry Chagin [Fri, 6 May 2022 17:02:59 +0000 (20:02 +0300)]
linux(4): Implement semtimedop syscalls.

On i386 are two semtimedop. The old one is called via multiplexor and
uses 32-bit timespec, and new semtimedop_tim64, which is uses 64-bit
timespec.

MFC after: 2 weeks

(cherry picked from commit 3245a2ecea21ace3d97cec1266fbe29c88ba1a59)

2 years agolinux(4): Regen for semtimedop syscalls.
Dmitry Chagin [Fri, 17 Jun 2022 19:34:53 +0000 (22:34 +0300)]
linux(4): Regen for semtimedop syscalls.

MFC after:              2 weeks

(cherry picked from commit 430460d7178285a26087d294177627e6c88ad369)

2 years agolinux(4): Change semtimedop syscall definition to match Linux actual one.
Dmitry Chagin [Fri, 6 May 2022 17:01:43 +0000 (20:01 +0300)]
linux(4): Change semtimedop syscall definition to match Linux actual one.

MFC after: 2 weeks

(cherry picked from commit f19c4e23413d9e2661d09120bb5434c54593bb8e)

2 years agolinux(4): Retire linux_semop implementation.
Dmitry Chagin [Fri, 6 May 2022 17:00:13 +0000 (20:00 +0300)]
linux(4): Retire linux_semop implementation.

In i386 Linux semop called via ipc() multiplexor, so use kern_semop
directly from multiplexor.

MFC after: 2 weeks

(cherry picked from commit f48a68874bf4503a18c0c55887a028dab0a4600f)

2 years agolinux(4): Regen for semop syscall.
Dmitry Chagin [Fri, 17 Jun 2022 19:34:47 +0000 (22:34 +0300)]
linux(4): Regen for semop syscall.

MFC after:              2 weeks

(cherry picked from commit cd875998dc236eb531753bba7296a834de57d99d)

2 years agolinux(4): Call semop directly.
Dmitry Chagin [Fri, 6 May 2022 16:58:53 +0000 (19:58 +0300)]
linux(4): Call semop directly.

As the Linux semop syscall is not defined in i386, and as it is equal
to the native semop syscall, call it directly.
Fix semop definition to match Linux actual one - nsops is size_t type.

MFC after: 2 weeks

(cherry picked from commit f686092664ee6c2c287f77f716db4d72e451c780)

2 years agosysvsem: Add a timeout argument to the semop.
Dmitry Chagin [Fri, 6 May 2022 16:51:48 +0000 (19:51 +0300)]
sysvsem: Add a timeout argument to the semop.

For future use in the Linux emulation layer for the semtimedop syscall
split the sys_semop syscall into two counterparts and add
struct timespec *timeout argument to the last one.

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

(cherry picked from commit f04534f5c84e58009efbb7f378803da3f33585b9)

2 years agolinux(4): Implement recvmmsg_time64 syscall.
Dmitry Chagin [Wed, 4 May 2022 10:06:53 +0000 (13:06 +0300)]
linux(4): Implement recvmmsg_time64 syscall.

MFC after: 2 weeks

(cherry picked from commit 1744f14e26c99af704650922e19e6934aa9a1271)

2 years agolinux(4): Regen for recvmmsg_time64 syscall.
Dmitry Chagin [Fri, 17 Jun 2022 19:34:42 +0000 (22:34 +0300)]
linux(4): Regen for recvmmsg_time64 syscall.

MFC after:      2 weeks

(cherry picked from commit 79695e9585fafb4fd7240d8183839852f6c5d43a)

2 years agolinux(4): Change recvmmsg_time64 syscall definition to match Linux actual one.
Dmitry Chagin [Wed, 4 May 2022 10:06:52 +0000 (13:06 +0300)]
linux(4): Change recvmmsg_time64 syscall definition to match Linux actual one.

MFC after: 2 weeks

(cherry picked from commit 17ccda0039229d884b9f624815775893889d161e)

2 years agolinux(4): Implement timerfd_gettime64 syscall.
Dmitry Chagin [Wed, 4 May 2022 10:06:52 +0000 (13:06 +0300)]
linux(4): Implement timerfd_gettime64 syscall.

MFC after: 2 weeks

(cherry picked from commit ce9f8d6ab00c491f84a021b23a28a1484ef817d8)

2 years agolinux(4): Regen for timerfd_gettime64 syscall.
Dmitry Chagin [Fri, 17 Jun 2022 19:34:36 +0000 (22:34 +0300)]
linux(4): Regen for timerfd_gettime64 syscall.

MFC after:      2 weeks

(cherry picked from commit ac80ae931323411c8a034624b0369eb6c0fe0934)

2 years agolinux(4): Change timerfd_gettime64 syscall definition to match Linux actual one.
Dmitry Chagin [Wed, 4 May 2022 10:06:51 +0000 (13:06 +0300)]
linux(4): Change timerfd_gettime64 syscall definition to match Linux actual one.

MFC after: 2 weeks

(cherry picked from commit 16aefe5ba3923991088f1a46e9d493664421a0a2)

2 years agolinux(4): Implement timerfd_settime64 syscall.
Dmitry Chagin [Wed, 4 May 2022 10:06:50 +0000 (13:06 +0300)]
linux(4): Implement timerfd_settime64 syscall.

MFC after: 2weeks

(cherry picked from commit b1f0b08d932005a574411c829422e81223df14da)

2 years agolinux(4): Regen for timerfd_settime64 syscall.
Dmitry Chagin [Fri, 17 Jun 2022 19:34:31 +0000 (22:34 +0300)]
linux(4): Regen for timerfd_settime64 syscall.

MFC after:      2 weeks

(cherry picked from commit f4228fbb4eb85601e4e857446642372f7d74d6e9)

2 years agolinux(4): Change timerfd_settime64 syscall definition to match Linux actual one.
Dmitry Chagin [Wed, 4 May 2022 10:06:50 +0000 (13:06 +0300)]
linux(4): Change timerfd_settime64 syscall definition to match Linux actual one.

MFC after: 2 weeks

(cherry picked from commit 8545bcff313f39665fbb26dbc2a727fd481018b2)

2 years agolinux(4): Implement timer_settime64 syscall.
Dmitry Chagin [Wed, 4 May 2022 10:06:49 +0000 (13:06 +0300)]
linux(4): Implement timer_settime64 syscall.

MFC after: 2 weeks

(cherry picked from commit a1fd2911ddb06c1a2d23ebb636a46bc20ca498e7)

2 years agolinux(4): Regen for timer_settime64 syscall.
Dmitry Chagin [Fri, 17 Jun 2022 19:34:26 +0000 (22:34 +0300)]
linux(4): Regen for timer_settime64 syscall.

MFC after:      2 weeks

(cherry picked from commit 9038a0b74cf74c73cea635ae2fff51706cc9ab33)

2 years agolinux(4): Change timer_settime64 syscall definition to match Linux actual one.
Dmitry Chagin [Wed, 4 May 2022 10:06:48 +0000 (13:06 +0300)]
linux(4): Change timer_settime64 syscall definition to match Linux actual one.

MFC after: 2 weeks

(cherry picked from commit 1508b1b6a022592e214a2ed2ed52e6100e84de35)

2 years agolinux(4): Implement timer_gettime64 syscall.
Dmitry Chagin [Wed, 4 May 2022 10:06:48 +0000 (13:06 +0300)]
linux(4): Implement timer_gettime64 syscall.

MFC after: 2 weeks

(cherry picked from commit 783c1bd8cb0cf02f2cfb95418b0a115ed975086a)

2 years agolinux(4): Regen for timer_gettime64 syscall.
Dmitry Chagin [Fri, 17 Jun 2022 19:34:20 +0000 (22:34 +0300)]
linux(4): Regen for timer_gettime64 syscall.

MFC after:      2 weeks

(cherry picked from commit 1cccef6dff13f4854ac75c243c36317ccd4defc1)

2 years agolinux(4): Change timer_gettime64 syscall definition to match Linux actual one.
Dmitry Chagin [Wed, 4 May 2022 10:06:47 +0000 (13:06 +0300)]
linux(4): Change timer_gettime64 syscall definition to match Linux actual one.

MFC after: 2 weeks

(cherry picked from commit ccec96033c5aa2f1dfd6c736daf3e493c2272af3)

2 years agolinux(4): Implement sched_rr_get_interval_time64 syscall.
Dmitry Chagin [Wed, 4 May 2022 10:06:47 +0000 (13:06 +0300)]
linux(4): Implement sched_rr_get_interval_time64 syscall.

MFC after: 2 weeks

(cherry picked from commit 8c84ca657bb343b73f315520ac3cabc43c5a67ec)

2 years agolinux(4): Regen for sched_rr_get_interval_time64 syscall.
Dmitry Chagin [Fri, 17 Jun 2022 19:34:15 +0000 (22:34 +0300)]
linux(4): Regen for sched_rr_get_interval_time64 syscall.

MFC after:      2 weeks

(cherry picked from commit cdddbb77c30b7f518f7ac78b113a823c3ca0cd11)

2 years agolinux(4): Change sched_rr_get_interval_time64 syscall definition to match Linux actua...
Dmitry Chagin [Wed, 4 May 2022 10:06:45 +0000 (13:06 +0300)]
linux(4): Change sched_rr_get_interval_time64 syscall definition to match Linux actual one.

MFC after: 2 weeks

(cherry picked from commit 7b520c0b3c50a1a0025ee6cdbd457a1b6e6c2a0c)

2 years agoRemove dead code.
Dmitry Chagin [Tue, 26 Apr 2022 16:40:59 +0000 (19:40 +0300)]
Remove dead code.

is_physical_memory() dead since 235a54de.

Reviewed by: markj
Differential revision: https://reviews.freebsd.org/D35056
MFC after: 2 weeks

(cherry picked from commit fe2c9f83a6dc1cc62da177a765ce8a265894b2cd)

2 years agolinux(4): Add epoll_pwai2 syscall.
Dmitry Chagin [Tue, 26 Apr 2022 16:35:59 +0000 (19:35 +0300)]
linux(4): Add epoll_pwai2 syscall.

MFC after: 2 weeks

(cherry picked from commit e00aad1042e7163865763b42d8d72137eeb9df63)

2 years agolinux(4): Regen for epoll_pwait2 syscall.
Dmitry Chagin [Fri, 17 Jun 2022 19:34:09 +0000 (22:34 +0300)]
linux(4): Regen for epoll_pwait2 syscall.

(cherry picked from commit df377f1fb8dd92a1839bc578aac46d2cdf1b5b84)

2 years agolinux(4): Change epoll_pwait2 syscall definition to match Linux actual one.
Dmitry Chagin [Tue, 26 Apr 2022 16:35:57 +0000 (19:35 +0300)]
linux(4): Change epoll_pwait2 syscall definition to match Linux actual one.

MFC after: 2 weeks

(cherry picked from commit 81b0b7dc0c624c2e086943822beda0b08a12e252)

2 years agolinux(4): Add copyin_sigset() helper.
Dmitry Chagin [Tue, 26 Apr 2022 16:35:57 +0000 (19:35 +0300)]
linux(4): Add copyin_sigset() helper.

MFC after: 2 weeks

(cherry picked from commit 3923e632094a7e4cc66cd8e68964b9cb495119e2)

2 years agolinux(4): Add linux_epoll_pwait_ts() helper for future use.
Dmitry Chagin [Tue, 26 Apr 2022 16:35:56 +0000 (19:35 +0300)]
linux(4): Add linux_epoll_pwait_ts() helper for future use.

MFC after: 2 weeks

(cherry picked from commit 27a25179c8356d58b5df6303d850050122f020c6)

2 years agolinux(4): Copyout pselect timeout.
Dmitry Chagin [Tue, 26 Apr 2022 16:35:56 +0000 (19:35 +0300)]
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 5171ed79f6d1fc3948a7ebfb32b02d698224c29b)

2 years agolinux(4): Add a simple rseq syscall implementation.
Dmitry Chagin [Tue, 26 Apr 2022 16:35:56 +0000 (19:35 +0300)]
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 ee55d560e89ac8de37def993a13d2582638273b7)

2 years agolinux(4): Regen for rseq syscall.
Dmitry Chagin [Fri, 17 Jun 2022 19:34:03 +0000 (22:34 +0300)]
linux(4): Regen for rseq syscall.

(cherry picked from commit 75e409495f67a39114e09224b8915cb0ecc481c4)

2 years agolinux(4): Change rseq syscall definition to match Linux actual one.
Dmitry Chagin [Tue, 26 Apr 2022 16:35:54 +0000 (19:35 +0300)]
linux(4): Change rseq syscall definition to match Linux actual one.

MFC after: 2 weeks

(cherry picked from commit f202f35db00cb9908b143a5a67f58ee95310f419)

2 years agoFix build after 128b9bf9
Dmitry Chagin [Mon, 25 Apr 2022 11:45:05 +0000 (14:45 +0300)]
Fix build after 128b9bf9

MFC after: 2 weeks

(cherry picked from commit 0ced2aef06760bfc57248482045c997be718b207)

2 years agoAdd tests for sigwait family syscalls.
Dmitry Chagin [Fri, 17 Jun 2022 19:33:56 +0000 (22:33 +0300)]
Add tests for sigwait family syscalls.

MFC after:              2 weeks

(cherry picked from commit 128b9bf96cae36c33b45a4d418ff502497bbb834)

2 years agosigtimedwait: Prevent timeout math overflows.
Dmitry Chagin [Mon, 25 Apr 2022 07:23:15 +0000 (10:23 +0300)]
sigtimedwait: Prevent timeout math overflows.

Our kern_sigtimedwait() calculates absolute sleep timo value as 'uptime+timeout'.
So, when the user specifies a big timeout value (LONG_MAX), the calculated
timo can be less the the current uptime value.
In that case kern_sigtimedwait() returns EAGAIN instead of EINTR, if
unblocked signal was caught.

While here switch to a high-precision sleep method.

Reviewed by: mav, kib
In collaboration with: mav
Differential revision: https://reviews.freebsd.org/D34981
MFC after: 2 weeks

(cherry picked from commit 4a700f3c329a48f3a20fd576900820e293c8cad7)

2 years agolinux(4): Refactor signal send methods.
Dmitry Chagin [Mon, 25 Apr 2022 07:22:51 +0000 (10:22 +0300)]
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 6201a50d0d6d98633dba3db12dea2dfe95295e0e)

2 years agolinux(4): Check that the thread tid in the thread group pid in linux_tdfind().
Dmitry Chagin [Mon, 25 Apr 2022 07:21:51 +0000 (10:21 +0300)]
linux(4): Check that the thread tid in the thread group pid in linux_tdfind().

MFC after: 2 weeks

(cherry picked from commit fe894a370556e5b173a8893cdcde6323ff79cc57)

2 years agolinux(4): Microoptimize bsd_to_linux_sockaddr().
Dmitry Chagin [Mon, 25 Apr 2022 07:21:20 +0000 (10:21 +0300)]
linux(4): Microoptimize bsd_to_linux_sockaddr().

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

(cherry picked from commit bbddd5881d1826a366d09d1e156ec6b64d3715e5)

2 years agoAdd timespecvalid_interval macro and use it.
Dmitry Chagin [Mon, 25 Apr 2022 07:20:54 +0000 (10:20 +0300)]
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 91e7bdcdcf10684098e213e311cdafcd7a0ac983)

2 years agoFix sigtimedwait manpage.
Dmitry Chagin [Thu, 21 Apr 2022 07:52:29 +0000 (10:52 +0300)]
Fix sigtimedwait manpage.

Historically, sigtimedwait() blocks indefinitely if timeout is NULL.

Reviewed by: jilles, imp
Differential Revision: https://reviews.freebsd.org/D34985
MFC after: 2 weeks

(cherry picked from commit 89ecdff2c32c4e8975f8652c5cb913eba8642204)

2 years agoBump Dd in getdirentries.2 after c6487446.
Dmitry Chagin [Wed, 20 Apr 2022 14:55:32 +0000 (17:55 +0300)]
Bump Dd in getdirentries.2 after c6487446.

MFC after: 1 week

(cherry picked from commit 45a4c442996edafbe49caecb33a6e1226ab51a8e)

2 years agolinux(4): Copyout actual size of addr to the user space in accept().
Dmitry Chagin [Mon, 11 Apr 2022 20:33:27 +0000 (23:33 +0300)]
linux(4): Copyout actual size of addr to the user space in accept().

Differential Revision: https://reviews.freebsd.org/D34727

(cherry picked from commit 673bce11cedde3cc33c154d2b8e2d41139dcef72)

2 years agolinux(4): Limit user-supplied sockaddr length in recvfrom().
Dmitry Chagin [Mon, 11 Apr 2022 20:32:28 +0000 (23:32 +0300)]
linux(4): Limit user-supplied sockaddr length in recvfrom().

Differential Revision: https://reviews.freebsd.org/D34726

(cherry picked from commit bb0f644cd680d20b3112f6c14dc853171f497a88)

2 years agolinux(4): Remove unnecessary PTRIN().
Dmitry Chagin [Mon, 11 Apr 2022 20:32:02 +0000 (23:32 +0300)]
linux(4): Remove unnecessary PTRIN().

(cherry picked from commit 68bfaefb3d93781730ebc63956538154173b77c8)

2 years agolinux(4): Handle SO_DOMAIN in getsockopt syscall.
Dmitry Chagin [Mon, 11 Apr 2022 20:31:28 +0000 (23:31 +0300)]
linux(4): Handle SO_DOMAIN in getsockopt syscall.

Differential revision: https://reviews.freebsd.org/D34714

(cherry picked from commit cf312f799a867b4b1beef0536a162062659659a6)

2 years agogetdirentries: return ENOENT for unlinked but still open directory.
Dmitry Chagin [Fri, 17 Jun 2022 19:33:51 +0000 (22:33 +0300)]
getdirentries: return ENOENT for unlinked but still open directory.

To be more compatible to IEEE Std 1003.1-2008 (“POSIX.1”).

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

(cherry picked from commit c6487446d7e99537551d2e51a2f6c6569fcb89fc)

2 years agolinux(4): Prevent an attempt to copy an uninitialized source address.
Dmitry Chagin [Mon, 11 Apr 2022 20:29:45 +0000 (23:29 +0300)]
linux(4): Prevent an attempt to copy an uninitialized source address.

PR: 259380
MFC after: 3 days

(cherry picked from commit bb46e9b5107fd8763742f7e55b66ea2e574f5815)

2 years ago[linprocfs] add sys/kernel/random/boot_id
Fernando Apesteguía [Tue, 8 Mar 2022 14:19:53 +0000 (15:19 +0100)]
[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 0f2041a5b03259a8a7b20ffc98e34884cc5590b3)

2 years agoi386 linux: Remove unused variables.
John Baldwin [Sat, 9 Apr 2022 00:25:14 +0000 (17:25 -0700)]
i386 linux: Remove unused variables.

(cherry picked from commit 9e70163017ff929a36926ddbc5bd6e8b6b19cfeb)

2 years agolinux(4): Fix a typo in itimerspec conversion routine.
Dmitry Chagin [Wed, 6 Apr 2022 14:40:00 +0000 (17:40 +0300)]
linux(4): Fix a typo in itimerspec conversion routine.

MFC after: 3 days

(cherry picked from commit 0938d04a2c513122127c4a1552542ab617f567a8)

2 years agolinsysfs: plug set-but-not-used vars.
Dmitry Chagin [Thu, 31 Mar 2022 20:49:26 +0000 (23:49 +0300)]
linsysfs: plug set-but-not-used vars.

MFC after: 2 weeks

(cherry picked from commit bafe3b8804ca1450584191ae8689c1c0abeea68d)

2 years agolinux(4): Cleanup empty lines.
Dmitry Chagin [Thu, 31 Mar 2022 18:23:12 +0000 (21:23 +0300)]
linux(4): Cleanup empty lines.

MFC after: 2 weeks

(cherry picked from commit 09d60bfae58f10a24c8fc7c06bd3d90b86d40e07)

2 years agolinux(4): Fix KASSERT message.
Dmitry Chagin [Thu, 31 Mar 2022 18:22:31 +0000 (21:22 +0300)]
linux(4): Fix KASSERT message.

MFC after: 2 weeks

(cherry picked from commit 4e1e83461bdc9b8c3ab96dc82e7342d4ea1e69b9)

2 years agolinux(4): readlink should fail if bufzis <= 0.
Dmitry Chagin [Thu, 31 Mar 2022 18:21:41 +0000 (21:21 +0300)]
linux(4): readlink should fail if bufzis <= 0.

MFC after: 2 weeks

(cherry picked from commit d6ccce0aa267db8ee57736e944520e2967896340)

2 years agolinprocfs: Add /proc/self/oom_score_adj.
Dmitry Chagin [Thu, 31 Mar 2022 18:04:44 +0000 (21:04 +0300)]
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 b7df7b987e8fac05006aa5f132c424e2b2bcf156)

2 years agolinux(4): Add compat.linux32.emulate_i386 knob.
Dmitry Chagin [Thu, 31 Mar 2022 18:01:09 +0000 (21:01 +0300)]
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 d5dc757e84d8dc1db987f3a17052e32621d6ea87)

2 years agolinux(4): Fixup miscalculation of d_off of struct dirent in getdents() syscalls.
Dmitry Chagin [Thu, 31 Mar 2022 17:50:09 +0000 (20:50 +0300)]
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 099fa2feb36fe6a68a87dfdb0f290b882139a88d)

2 years agolinux(4): wait4() returns ESRCH if pid is INT_MIN.
Dmitry Chagin [Thu, 31 Mar 2022 17:49:39 +0000 (20:49 +0300)]
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 9103c5582a2d271fa8f4df136ae511da572c660f)

2 years agolinux(4): Rid unused defines from linux_mib.
Dmitry Chagin [Thu, 31 Mar 2022 17:45:12 +0000 (20:45 +0300)]
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 5bcf0f7cd7441a1f88383545fec6c370b934f1a1)

2 years agolinux(4): Fixup waitid handling P_PGID idtype.
Dmitry Chagin [Thu, 31 Mar 2022 17:44:00 +0000 (20:44 +0300)]
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 4e3aefb923ac1bd8e2a707b00239f171eab1231b)

2 years agolinux(4): Return ENOSYS for unsupported P_PIDFD waitid idtype.
Dmitry Chagin [Thu, 31 Mar 2022 17:42:42 +0000 (20:42 +0300)]
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 be1e4a0bdf45da4bbdce996d2146eba3e32b3766)

2 years agolinux(4): Add support for __WALL wait option bit.
Dmitry Chagin [Thu, 31 Mar 2022 17:42:03 +0000 (20:42 +0300)]
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 c7ef7c3facaf663c3da2d91916bcb2f162fc300e)

2 years agolinux(4): Fixup options value validation in linux_waitid().
Dmitry Chagin [Thu, 31 Mar 2022 17:41:19 +0000 (20:41 +0300)]
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 d7e1e138ec66e410f525413b0caed089139f3cc0)

2 years agolinux(4): Eliminate bogus options value check validation.
Dmitry Chagin [Thu, 31 Mar 2022 17:41:02 +0000 (20:41 +0300)]
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 2fd480b3182f52ebf23abdcacab04520224e90b7)

2 years agolinux(4): Consolidate wait* facility into linux_common_wait().
Dmitry Chagin [Thu, 31 Mar 2022 17:40:22 +0000 (20:40 +0300)]
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 0c6b1ff7de56ccaef9bb22bacfd69b07ab4aeb8a)

2 years agolinux: plug set-but-not-unused vars
Mateusz Guzik [Wed, 24 Nov 2021 21:16:03 +0000 (21:16 +0000)]
linux: plug set-but-not-unused vars

Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 74a0e24f07974b4d51c57afa7525b5f88574ad31)

2 years agolinux(4): Add AT_NO_AUTOMOUNT to statx.
Dmitry Chagin [Fri, 25 Mar 2022 14:54:23 +0000 (17:54 +0300)]
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 ff39d74aa99a49749d1de26dc1f6b1e1bfebceb0)

2 years agolinprocfs: Eliminate bogus comment (KSE).
Dmitry Chagin [Fri, 25 Mar 2022 14:53:08 +0000 (17:53 +0300)]
linprocfs: Eliminate bogus comment (KSE).

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

(cherry picked from commit aae8ae5ea5a67feb83a30e7c09553ab416d6830a)

2 years agolinux_copyout_strings: Use PROC_PS_STRINGS().
John Baldwin [Fri, 4 Feb 2022 23:57:57 +0000 (15:57 -0800)]
linux_copyout_strings: Use PROC_PS_STRINGS().

Reviewed by: markj
Obtained from: CheriBSD
Differential Revision: https://reviews.freebsd.org/D34173

(cherry picked from commit 6bea696af25c606452515bc812c23b9f2614344a)

2 years agolinprocfs: plug set-but-not-unused vars
Mateusz Guzik [Wed, 24 Nov 2021 21:18:36 +0000 (21:18 +0000)]
linprocfs: plug set-but-not-unused vars

Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit ae3d955404dac5c22fdbbc9bd1a3583b4c7d8637)

2 years agopseudofs: Destroy vncache hashtbl on pseudofs module unload.
Dmitry Chagin [Thu, 9 Dec 2021 21:41:08 +0000 (21:41 +0000)]
pseudofs: Destroy vncache hashtbl on pseudofs module unload.

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

(cherry picked from commit 0f74021fb6a5c3fb6e031892cc159b1e7e325bd6)

2 years agolinux(4): Improve comment.
Dmitry Chagin [Fri, 13 Aug 2021 08:36:42 +0000 (11:36 +0300)]
linux(4): Improve comment.

Reported by: pfg
MFC after: 2 weeks

(cherry picked from commit d4da692862f195b8e98cbaeadbd97eb003cda92a)

2 years agolinux(4): Reduce diffs between linux_rt_sendsig() and sendsig()
Edward Tomasz Napierala [Tue, 4 Jan 2022 14:13:03 +0000 (14:13 +0000)]
linux(4): Reduce diffs between linux_rt_sendsig() and sendsig()

No functional changes (except for the uprintf).

Discussed With: kib
Sponsored By: EPSRC

(cherry picked from commit f7b04c53de46b18785a153d9812e64ca1a9a8c8d)

2 years agolinux: Provide dummy seccomp(2)
Edward Tomasz Napierala [Fri, 28 Jan 2022 10:55:11 +0000 (10:55 +0000)]
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 99454d3e98ff205881aa7abef39234c9afc7600c)

2 years agolinux(4): Remove unused arm64 SDT declarations
Edward Tomasz Napierala [Tue, 21 Dec 2021 06:07:15 +0000 (06:07 +0000)]
linux(4): Remove unused arm64 SDT declarations

Those tracepoints have been removed somewhere in the past.

Sponsored By: EPSRC

(cherry picked from commit a15c591899663c30f2cbe13a4b350ad508b5e4bb)

2 years agolinux: plug set-but-not-used vars
Mateusz Guzik [Sat, 18 Dec 2021 13:12:15 +0000 (13:12 +0000)]
linux: plug set-but-not-used vars

Sponsored by: Rubicon Communications, LLC ("Netgate")

(cherry picked from commit 0c8d7eebfdce5045bf3b8669ce954ca2cf553d9a)

2 years agolinux: remove the always curthread argument from lconvpath
Mateusz Guzik [Thu, 25 Nov 2021 21:42:13 +0000 (21:42 +0000)]
linux: remove the always curthread argument from lconvpath

(cherry picked from commit af4051d25055fee086c0f78421e68fec20640f17)

2 years agolinux_name_to_handle_at: Support AT_EMPTY_PATH.
John Baldwin [Wed, 17 Nov 2021 23:51:18 +0000 (15:51 -0800)]
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 8b2ce7a3bbd0a754d31ff3943d918b4c84c831a3)

2 years agolinux_linkat: Don't invert AT_* flags.
John Baldwin [Wed, 17 Nov 2021 23:51:06 +0000 (15:51 -0800)]
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 a8d885296a9dc517e731723081c83d97d2aa598f)

2 years agolinux(4): Fix "set but not used" warnings
Edward Tomasz Napierala [Mon, 29 Nov 2021 16:44:40 +0000 (16:44 +0000)]
linux(4): Fix "set but not used" warnings

No functional changes.

Sponsored By: EPSRC

(cherry picked from commit a089c17d320684e6eb36556fa131a8286e6a821d)

2 years agolinux: Drop some unnecessary includes
Dmitry Chagin [Fri, 17 Jun 2022 19:33:38 +0000 (22:33 +0300)]
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 06d5ef0aad20f703c15350663ce2600bae2fe189)