opnsense-src/sys/compat/linux
Dmitry Chagin 72bc1e6806 cpuset: Byte swap cpuset for compat32 on big endian architectures
Summary:
BITSET uses long as its basic underlying type, which is dependent on the
compile type, meaning on 32-bit builds the basic type is 32 bits, but on
64-bit builds it's 64 bits.  On little endian architectures this doesn't
matter, because the LSB is always at the low bit, so the words get
effectively concatenated moving between 32-bit and 64-bit, but on
big-endian architectures it throws a wrench in, as setting bit 0 in
32-bit mode is equivalent to setting bit 32 in 64-bit mode.  To
demonstrate:

32-bit mode:

BIT_SET(foo, 0):        0x00000001

64-bit sees: 0x0000000100000000

cpuset is the only system interface that uses bitsets, so solve this
by swapping the integer sub-components at the copyin/copyout points.

Reviewed by:    kib
Sponsored by:   Juniper Networks, Inc.
Differential Revision:  https://reviews.freebsd.org/D35225

(cherry picked from commit 47a57144af)

Fix the build after 47a57144

(cherry picked from commit 89737eb829)

cpuset: Fix the KASAN and KMSAN builds

Rename the "copyin" and "copyout" fields of struct cpuset_copy_cb to
something less generic, since sanitizers define interceptors for
copyin() and copyout() using #define.

Reported by:    syzbot+2db5d644097fc698fb6f@syzkaller.appspotmail.com
Fixes:  47a57144af ("cpuset: Byte swap cpuset for compat32 on big endian architectures")
Sponsored by:   The FreeBSD Foundation

(cherry picked from commit 4a3e51335e)

Use Linux semantics for the thread affinity syscalls.

Linux has more tolerant checks of the user supplied cpuset_t's.

Minimum cpuset_t size that the Linux kernel permits in case of
getaffinity() is the maximum CPU id, present in the system / NBBY,
the maximum size is not limited.
For setaffinity(), Linux does not limit the size of the user-provided
cpuset_t, internally using only the meaningful part of the set, where
the upper bound is the maximum CPU id, present in the system, no larger
than the size of the kernel cpuset_t.
Unlike FreeBSD, Linux ignores high bits if set in the setaffinity(),
so clear it in the sched_setaffinity() and Linuxulator itself.

Reviewed by:            Pau Amma (man pages)
In collaboration with:  jhb
Differential revision:  https://reviews.freebsd.org/D34849
MFC after:              2 weeks

(cherry picked from commit f35093f8d6)
2022-06-17 22:35:14 +03:00
..
check_error.d linux(4): Eliminating remnants of futex sdt. 2022-06-17 22:33:22 +03:00
check_internal_locks.d
linux.c linux(4): Microoptimize bsd_to_linux_sockaddr(). 2022-06-17 22:33:54 +03:00
linux.h linux(4): Add struct clone_args for future clone3 system call. 2022-06-17 22:33:30 +03:00
linux_common.c linux(4): Reimplement futexes using umtx. 2022-06-17 22:33:17 +03:00
linux_common.h linux(4): Cleanup empty lines. 2022-06-17 22:33:48 +03:00
linux_dtrace.h
linux_dummy.c linux(4): Add epoll_pwai2 syscall. 2022-06-17 22:34:10 +03:00
linux_elf.c linux: Drop some unnecessary includes 2022-06-17 22:33:38 +03:00
linux_elf.h linux(4): implement coredump support 2022-06-17 22:33:02 +03:00
linux_elf32.c linux(4): implement coredump support 2022-06-17 22:33:02 +03:00
linux_elf64.c linux(4): implement coredump support 2022-06-17 22:33:02 +03:00
linux_emul.c linux(4): Cleanup empty lines. 2022-06-17 22:33:48 +03:00
linux_emul.h linprocfs: Add /proc/self/oom_score_adj. 2022-06-17 22:33:47 +03:00
linux_errno.c Add linux_to_bsd_errtbl[], mapping Linux errnos to their BSD counterparts. 2020-11-04 19:54:18 +00:00
linux_errno.h linux: Fix ptrace panic with ERESTART 2022-02-21 13:36:11 +00:00
linux_errno.inc Add linux_to_bsd_errtbl[], mapping Linux errnos to their BSD counterparts. 2020-11-04 19:54:18 +00:00
linux_event.c linux(4): Add a helper intended for copying timespec's from the userspace. 2022-06-17 22:34:59 +03:00
linux_event.h Drop rdivacky@ "All rights reserved" from linux_event. 2022-06-17 22:33:09 +03:00
linux_file.c linux(4): Fixed offset miscalculation in the preadv/pwritev syscalls. 2022-06-17 22:35:06 +03:00
linux_file.h linux(4): Add AT_NO_AUTOMOUNT to statx. 2022-06-17 22:33:43 +03:00
linux_fork.c linux(4): Fix "set but not used" warnings 2022-06-17 22:33:38 +03:00
linux_fork.h linux(4): Add CLONE_PIDFD option bit. 2022-06-17 22:33:31 +03:00
linux_futex.c linux(4); Style. 2022-06-17 22:35:07 +03:00
linux_futex.h linux(4): Handle FUTEX_LOCK_PI2 oeration. 2022-06-17 22:33:24 +03:00
linux_getcwd.c linux(4): make getcwd(2) return ERANGE instead of ENOMEM 2021-03-15 13:00:17 +00:00
linux_ioctl.c linux: add sysctl to pass untranslated interface names 2022-03-28 08:49:23 +00:00
linux_ioctl.h linux: Improve debugging by recognizing TIOCGPTPEER 2022-02-13 22:26:01 +00:00
linux_ipc.c linux(4): Add a helper intended for copying timespec's from the userspace. 2022-06-17 22:34:59 +03:00
linux_ipc.h linux(4): Implement semtimedop syscalls. 2022-06-17 22:34:53 +03:00
linux_ipc64.h
linux_mib.c linux: Make compat.linux.preserve_vstatus default to 1 2022-02-14 19:35:25 +00:00
linux_mib.h linux(4): Rid unused defines from linux_mib. 2022-06-17 22:33:46 +03:00
linux_misc.c cpuset: Byte swap cpuset for compat32 on big endian architectures 2022-06-17 22:35:14 +03:00
linux_misc.h linprocfs: Add /proc/self/oom_score_adj. 2022-06-17 22:33:47 +03:00
linux_mmap.c linux: plug set-but-not-unused vars 2022-06-17 22:33:43 +03:00
linux_mmap.h Add linux_madvise(2) instead of having Linux apps call the native 2020-06-20 18:29:22 +00:00
linux_persona.h
linux_ptrace.c linux: Drop some unnecessary includes 2022-06-17 22:33:38 +03:00
linux_rseq.c linux(4): Add a simple rseq syscall implementation. 2022-06-17 22:34:03 +03:00
linux_signal.c linux(4): Add a helper intended for copying timespec's from the userspace. 2022-06-17 22:34:59 +03:00
linux_signal.h linux(4): Add copyin_sigset() helper. 2022-06-17 22:34:04 +03:00
linux_socket.c linux(4): Add a helper intended for copying timespec's from the userspace. 2022-06-17 22:34:59 +03:00
linux_socket.h linux(4): Handle SO_DOMAIN in getsockopt syscall. 2022-06-17 22:33:51 +03:00
linux_stats.c linux(4): Cleanup empty lines. 2022-06-17 22:33:48 +03:00
linux_sysctl.c linux: remove redundant SDT tracepoints 2022-06-17 22:22:15 +03:00
linux_sysproto.h
linux_time.c linux(4): Add a helper intended for copying timespec's from the userspace. 2022-06-17 22:34:59 +03:00
linux_timer.c linux(4): Implement timer_settime64 syscall. 2022-06-17 22:34:26 +03:00
linux_timer.h linux(4): Add a helper intended for copying timespec's from the userspace. 2022-06-17 22:34:59 +03:00
linux_uid16.c linux: remove the always curthread argument from lconvpath 2022-06-17 22:33:39 +03:00
linux_util.c linux: remove the always curthread argument from lconvpath 2022-06-17 22:33:39 +03:00
linux_util.h linux: remove the always curthread argument from lconvpath 2022-06-17 22:33:39 +03:00
linux_vdso.c Drop "All rights reserved" from my copyright statements. 2022-06-17 22:33:09 +03:00
linux_vdso.h Drop "All rights reserved" from my copyright statements. 2022-06-17 22:33:09 +03:00
linux_vdso_gtod.inc linux(4): Use the right function to get the bit index in vdso binuptime. 2022-06-17 22:35:00 +03:00
linux_videodev2_compat.h
linux_videodev_compat.h
stats_timing.d
trace_futexes.d