opnsense-src/lib/libc
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
..
aarch64 Add an implementation of .mcount on arm64 2022-04-19 10:18:02 +01:00
amd64 amd64: bring back asm bcmp, shared with memcmp 2022-03-29 10:25:17 +00:00
arm Add sched_getcpu() 2022-01-14 18:17:29 +02:00
capability Fix a few mandoc issues 2020-10-09 19:12:44 +00:00
compat-43 libc: Add HISTORY sections to the manual pages 2022-06-04 07:59:43 +02:00
db libc: Add HISTORY sections to the manual pages 2022-06-04 07:59:43 +02:00
gdtoa Remove sparc64 specific parts of libc. 2020-02-26 18:55:09 +00:00
gen cpuset: Byte swap cpuset for compat32 on big endian architectures 2022-06-17 22:35:14 +03:00
gmon
i386 libc: add _get_tp() private function 2021-04-23 14:14:07 +03:00
iconv libc: Fix "harmless" iconv one-byte overread 2022-01-24 23:59:47 +00:00
include Add sched_getcpu() 2022-01-14 18:17:29 +02:00
inet
isc
locale libc: Add HISTORY sections to the manual pages 2022-06-04 07:59:43 +02:00
md
mips mips _libc_get_static_tls_base: Narrow scope of #ifdef. 2022-04-29 13:50:05 -07:00
nameser
net if_indextoname(3): Correct the RFC in a comment 2022-04-10 07:52:14 +02:00
nls Implement strerror_l(). 2020-12-16 09:02:09 +00:00
posix1e acl_delete_entry(): remove write-only variable 2021-12-06 02:23:45 +02:00
powerpc Add sched_getcpu() 2022-01-14 18:17:29 +02:00
powerpc64 Add sched_getcpu() 2022-01-14 18:17:29 +02:00
powerpcspe [PowerPC] [PowerPCSPE] Fix multiple issues in fpsetmask(). 2021-03-08 12:39:33 -06:00
quad Add casts and L suffixes to libc quad support, to work around various 2020-02-17 20:14:59 +00:00
regex libc: regex: rework unsafe pointer arithmetic 2021-01-08 13:58:35 -06:00
resolv resolver(3): Fix a typo in a source code comment 2022-04-14 08:10:32 +02:00
riscv Add sched_getcpu() 2022-01-14 18:17:29 +02:00
rpc rpc(3): Fix two typos in source code comments 2022-04-09 08:17:17 +02:00
secure libc: ssp: sprinkle around some __dead2 2021-10-06 02:14:42 -05:00
softfloat libc: use standard LF line endings, not CRLF 2022-02-08 15:52:23 -05:00
stdio libc: Add HISTORY sections to the manual pages 2022-06-04 07:59:43 +02:00
stdlib libc: Add HISTORY sections to the manual pages 2022-06-04 07:59:43 +02:00
stdtime strftime.3: Fix a typo and use St for standards 2022-02-14 18:05:07 +01:00
string libc: Add HISTORY sections to the manual pages 2022-06-04 07:59:43 +02:00
sys cpuset: Byte swap cpuset for compat32 on big endian architectures 2022-06-17 22:35:14 +03:00
tests Have stpncpy tests ask the kernel for the page size 2022-05-03 15:04:04 +01:00
uuid uuid(3): Document return values 2021-11-21 19:43:31 -05:00
x86 Make CPU_SET macros compliant with other implementations 2022-01-14 18:17:30 +02:00
xdr typo: s/impelmentation/implementation/. 2020-02-07 15:14:29 +00:00
yp
libc.ldscript
libc_nossp.ldscript
Makefile powerpc: enable initial-exec TLS 2022-03-08 01:28:33 +01:00
Makefile.depend Update Makefile.depend files 2019-12-11 17:37:53 +00:00
Makefile.depend.options Update libssp paths in various Makefile.depend* files 2020-01-06 18:15:55 +00:00
Versions.def Create namespace for the symbols added during 14-CURRENT cycle. 2021-07-22 13:33:10 +03:00