opnsense-src/sys
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
..
amd64 linux(4): Regen for prctl fix. 2022-06-17 22:35:11 +03:00
arm linux(4): Regen for clone syscall. 2022-06-17 22:33:29 +03:00
arm64 linux(4): Implement semtimedop syscalls. 2022-06-17 22:34:53 +03:00
bsm
cam sg: get rid of unused include. 2022-06-17 22:30:19 +03:00
cddl boot/zfs: Extend zfsimpl.h and make it easier to use 2022-06-05 11:15:04 -04:00
compat cpuset: Byte swap cpuset for compat32 on big endian architectures 2022-06-17 22:35:14 +03:00
conf linux(4): Get rid of Linuxulator kernel build options. 2022-06-17 22:30:22 +03:00
contrib rtw88: plug various skb leaks in error cases 2022-06-08 16:11:19 +00:00
crypto crypto: Validate AES-GCM IV length in check_csp(). 2022-04-29 13:50:04 -07:00
ddb Create sys/reg.h for the common code previously in machine/reg.h 2022-05-12 15:12:59 -07:00
dev urtw(4): Adjust all pause calls to use milliseconds instead of ticks. 2022-06-16 04:55:52 +02:00
dts add overlay for enabling i2c1 on allwinner h3 2022-02-09 11:35:59 +02:00
fs pseudofs: Destroy vncache hashtbl on pseudofs module unload. 2022-06-17 22:33:41 +03:00
gdb gdb(4): Do not use run length encoding for 3-symbol repetitions 2022-02-04 20:58:34 -05:00
geom geom(4): Fix a common typo in a source code comment 2022-06-10 14:25:26 +02:00
gnu bwn: eliminate dead writes in BWN_GPL_PHY 2022-05-12 08:56:04 -04:00
i386 linux(4): Regen for prctl fix. 2022-06-17 22:35:11 +03:00
isa
kern cpuset: Byte swap cpuset for compat32 on big endian architectures 2022-06-17 22:35:14 +03:00
kgssapi
libkern libkern: Fix a typo in a source code comment 2022-06-10 14:24:24 +02:00
mips mips: Remove EXT_RESOURCES from kernel configs. 2022-05-17 14:15:45 -07:00
modules linux(4): Implement vdso getcpu for x86. 2022-06-17 22:35:00 +03:00
net if_bridge(4): Fix a typo in a source code comment 2022-06-10 14:28:01 +02:00
net80211 net80211: remove (optional) RSN from preobereq 2022-06-03 16:56:13 +00:00
netgraph ng_ubt(4): Probe USB Bluetooth per USB interface and not per USB device. 2022-06-14 11:39:23 +02:00
netinet rack: Fix a common typo in comments and a sysctl description 2022-06-10 14:32:35 +02:00
netinet6 mld6: Ensure that mld_domifattach() always succeeds 2022-04-27 20:34:17 -04:00
netipsec IPsec: Use protocol-specific malloc types instead of M_XDATA. 2022-05-10 16:33:00 -07:00
netpfil pf: fix more syncookie memory leaks 2022-06-06 09:01:34 +02:00
netsmb
nfs nfs: do not panic on bootpc_init when no interfaces are found 2022-05-06 09:14:28 -03:00
nfsclient
nfsserver
nlm
ofed ibcore: Fix missing ib_cm_destroy_id() in ib_cm_insert_listen() 2022-06-07 08:44:29 +02:00
opencrypto KTLS: Free the MAC session when destroying AES-CBC software sessions. 2022-05-13 16:48:48 -07:00
powerpc Remove dead code. 2022-06-17 22:34:10 +03:00
riscv aw_wdog: support Allwinner D1 watchdog 2022-05-16 10:34:04 -03:00
rpc krpc: Fix NFS-over-TLS for KTLS1.3 2022-05-30 17:38:43 -07:00
security audit: Initialize vattr fields before calling VOP_GETATTR 2022-04-11 09:43:27 -04:00
sys cpuset: Byte swap cpuset for compat32 on big endian architectures 2022-06-17 22:35:14 +03:00
teken teken: color #3 is yellow not brown - use TC_YELLOW as the name 2022-05-03 14:20:44 -04:00
tests routing: add IPv6 fib validation procedure. 2021-09-07 21:02:58 +00:00
tools Remove "All Rights Reserved" from FreeBSD Foundation sys/ copyrights 2022-02-08 15:00:55 -05:00
ufs ufs: Fix a typo a source code comment 2022-06-10 14:32:08 +02:00
vm vm_page: Fix a typo in a source code comment 2022-06-10 14:30:17 +02:00
x86 linux(4): Implement vdso getcpu for x86. 2022-06-17 22:35:00 +03:00
xdr
xen xen(3): Fix a typo in a source code comment 2022-04-02 15:32:40 +02:00
Makefile