We are supposed to check the result of bsd_to_linux_sockopt_level here
rather than its input.
(cherry picked from commit 9f55630b8d72602f6ec86b15b607f5fc5fde911e)
This seems like a natural complement to umtxq_unbusy_unlocked(). No
functional change intended.
Reviewed by: olce, kib
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D49124
(cherry picked from commit b01495caac2eca73463f4a889936a19e4c1c5909)
This is intended to clean state of a thread at the end of its
lifecycle during wait(), not the beginning of its life cycle.
Reviewed by: kib
Sponsored by: AFRL, DARPA
Differential Revision: https://reviews.freebsd.org/D48023
(cherry picked from commit 0e742cc77454d0872ac2f6e7fd755b6d0322b711)
systrace.c fails to build if we're using a common compiler.h for both
openzfs and linuxkpi. The issue is easy enough to fix: don't redefined
lower_32_bits if it's already defined in linux.h, since it's the least
'standardized'. This will allow systrace.c to build using an equivalent
macro.
MFC After: 3 days
Sponsored by: Netflix
(cherry picked from commit 481d5a4891648f0a6979a48689cc16fca80d4ab6)
FreeBSD sendfile() may perform a partial transfer and return EAGAIN if
the socket is non-blocking. Linux sendfile() expects no error in this
case, so squash EAGAIN.
PR: 282495
Tested by: pieter@krikkit.xyz
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D47447
(cherry picked from commit a43b745aaf4f5bbc96875d2ab3ec9bea8024eda4)
Commit ff39d74aa9 ignored AT_NO_AUTOMOUNT for statx(), but did not
change fstat64() or newfstatat(), which also take an equivalent flags
argument. Add a linux_to_bsd_stat_flags() helper and use it in all
three places.
PR: 281526
Reviewed by: trasz
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D46711
(cherry picked from commit 3cf834d069d1dcdbe464ea74624930eaf916715d)
Make the system call honor `AT_SYMLINK_NOFOLLOW`.
Also enable this from `linux_faccessat2` where the issue arised the first time.
Update manual pages accordingly.
PR: 275295
Reported by: kenrap@kennethraplee.com
Approved by: kib@
Differential Revision: https://reviews.freebsd.org/D46267
(cherry picked from commit 5ab6ed93cd3680f8b69dd4d05823f4740a2bdef9)
When we enable checking for BTI on arm64 we need to include an ELF
note in all object files linked into a module.
As using objcopy from a binary to an ELF object file doesn't add the
note switch to using .incbin from an assembly file. This allows us to
add the needed note without affecting the included object.
Reviewed by: imp, kib, emaste
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D45468
(cherry picked from commit bed65d85c631c3a8e60a81a15a5a745c8ef92fbe)
(cherry picked from commit ec69d230933f82c7c142b053882255aa57475463)
The content that `value` point to is not going to be altered by function
handle_string().
MFC after: 1 week
(cherry picked from commit 68c890b4433d3655c7df91cc43f89f4d6a8b35e4)
Under Linux, the socket options IP_RECVERR and IPV6_RECVERR are used to
receive socket errors via a dedicated 'error queue' which can be
retrieved via recvmsg(). FreeBSD does not support this functionality.
For IPv4, the sysctl compat.linux.ignore_ip_recverr can be set to 1 to
silently ignore attempts to set IP_RECVERR and return success to the
application, which is wrong, but is required for (among other things)
a functional DNS client in recent versions of glibc.
Add support for ignoring IPV6_RECVERR, controlled by the same sysctl.
This fixes DNS in Linux when using IPv6 resolvers.
Reviewed by: imp, Jose Luis Duran
Pull Request: https://github.com/freebsd/freebsd-src/pull/1118
(cherry picked from commit ca63710d3668cf6f3cb4faf065d8b4eeffa028ad)
This function is used by netlink(9) only. The netlink(9) taskqueue thread
runs in the vnet of the socket whose request the thread is processing
right now. This is a correct vnet and resetting it to vnet0 is incorrect.
If the function is to be used by any other caller in addition to
netlink(9), it would be caller's responsiblity to provide correct vnet(9).
Reviewed by: melifaro, dchagin
Differential Revision: https://reviews.freebsd.org/D44191
PR: 277286
(cherry picked from commit 2f5a315b307447f91891c96fb23c7333fa406f2f)
Introduce the allocuio() and freeuio() functions to allocate and
deallocate struct uio. This hides the actual allocator interface, so it
is easier to modify the sub-allocation layout of struct uio and the
corresponding iovec array.
Obtained from: CheriBSD
Reviewed by: kib, markj
MFC after: 2 weeks
Sponsored by: CHaOS, EPSRC grant EP/V000292/1
Differential Revision: https://reviews.freebsd.org/D43711
(cherry picked from commit 61cc4830a7b16400efade3d884a59fda6d80d651)
In preparation for annotating copyin() and friends with
__result_use_check.
Reviewed by: dchagin
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D43199
(cherry picked from commit b9924c202fc34004d4164cdc50f88d8fcef26279)
Move the NETLINK define into opt_global.h so we can rely on it being
set correctly, without having to remember to include opt_netlink.h.
This ensures that the NETLINK define is correctly set. If not we
may end up with unloadable modules, due to missing symbols (such as
nlmsg_get_group_writer).
PR: 274306
Reviewed by: imp, markj
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D42179
(cherry picked from commit ab393e9548f8cc0ee28499c411963b798ebb38a5)
Unlike x86_64, other 64-bit architectures do not have paddings
for the time fields.
MFC after: 1 week
(cherry picked from commit 1ee29160c5e5d8fa70173445b4a6de6742af74dc)
It's not used outside of linux_signal.c
While here fix the indentation.
MFC after: 1 week
(cherry picked from commit 794328fbc174360a09b6ad341624e9bce46f0d2e)
To help porting the Linux emulation layer to a new platforms start using
Linux names for conditional builds instead of architecture-specific ifdefs.
MFC after: 1 week
(cherry picked from commit 2a1cf1b6b55c8326bbe85d0fdf17b0f2fb9b34ce)
The timerfd is introduced in FreeBSD 14, and the Linux ABI timerfd is
also moved to FreeBSD native timerfd, but it can't work well as Linux
TFD_CLOEXEC and TFD_NONBLOCK haven't been converted to FreeBSD
TFD_CLOEXEC and TFD_NONBLOCK.
Reviewed by: dchagin, jfree
PR: 273662
Differential revision: https://reviews.freebsd.org/D41708
MFC after: 1 week
(cherry picked from commit aadc14bceb4e94f5b75a05de96cd9619b877b030)
FreeBSD does not permits manipulating extended attributes in the system
namespace by unprivileged accounts, even if account has appropriate
privileges to access filesystem object.
In Linux the system namespace is used to preserve posix acls. Some Gnu
coreutils binaries uses posix acls, eg, install, ls, cp. And fails if
we unexpectedly return EPERM error from xattr system calls.
In the other hands, in Linux read and write access to the system
namespace depend on the policy implemented for each filesystem, so we'll
mimics we're a filesystem that prohibits this for unpriveleged accounts.
Reported by: zirias
Tested by: zirias
MFC after: 1 week
(cherry picked from commit 11e37048db35d7fcfc285b867965de1aeefec2c8)
If size is specified as zero, these calls return the current size
of the list of extended attribute names (and leave list unchanged).
Tested by: zirias
MFC after: 1 week
(cherry picked from commit 18d1c86788f66f42c4e096142f4f8d168f68732c)
FreeBSD does not permits manipulating extended attributes in the system
namespace by unprivileged accounts, even if account has appropriate
privileges to access filesystem object.
In Linux the system namespace is used to preserve posix acls. Some Gnu
coreutils binaries uses posix acls, eg, install, ls. And fails if we
unexpectedly return EPERM error from xattr system calls.
In the other hands, in Linux read and write access to the system
namespace depend on the policy implemented for each filesystem, so we'll
mimics we're a filesystem that prohibits this for unpriveleged accounts.
Reported by: zirias
Tested by: zirias
MFC after: 1 week
(cherry picked from commit 1bfc4574f78653e4b64ac9dd31518c96a17fe52b)
On Linux ENODATA mean the named attribute does not exist, or the
process has no access to this attribute.
Reported by: zirias
PR: 273517
Tested by: zirias
MFC after: 1 week
(cherry picked from commit 4d59b790553ef75b9a4b6a673eab3354f3d012b3)
Move the timerfd impelemntation from linux compat code to sys/kern. Use
it to implement the new system calls for timerfd. Add a hook to kern_tc
to allow timerfd to know when the system time has stepped. Add kqueue
support to timerfd. Adjust a few names to be less Linux centric.
RelNotes: YES
Reviewed by: markj (on irc), imp, kib (with reservations), jhb (slack)
Differential Revision: https://reviews.freebsd.org/D38459
Adding a writev syscall wrapper is needed due to Linux family of write
syscalls doesn't distinguish between in kernel blocking operations
and always returns EAGAIN while FreeBSD can return ENOBUFS.
MFC after: 1 month
Adding a write syscall wrapper is needed due to Linux family of write
syscalls doesn't distinguish between in kernel blocking operations
and always returns EAGAIN while FreeBSD can return ENOBUFS.
MFC after: 1 month
Before Linux 2.6.33, out_fd must refer to a socket. Since Linux 2.6.33
it can be any file.
The patch was originally provided by James McLaughlin and adapted by me
for copy_file_range.
PR: 262535
Differential revision: https://reviews.freebsd.org/D34555
MFC after: 1 month