opnsense-src/lib
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
..
atf Do not build libatf-c++ when WITHOUT_CXX 2021-11-29 10:10:53 -05:00
clang Merge llvm-project release/14.x llvmorg-14.0.5-0-gc12386ae247c 2022-06-15 22:45:08 +02:00
csu csu: define STRIP_FBSDID 2022-02-08 15:53:31 -05:00
flua jail(3lua): add jail.attach()/jail.remove() methods 2021-10-06 02:13:27 -05:00
geom GEOM: Introduce partial confxml API 2022-05-10 21:20:25 -04:00
googletest googletest: Silence warnings about deprecated implicit copy constructors 2021-08-29 12:29:21 +02:00
lib9p lib9p: fix building on systems without capser 2021-01-04 20:48:48 +01:00
lib80211 lib80211: Start adding 11ac ETSI bits to regdomain.xml 2021-07-18 00:34:57 +00:00
libalias Rename NO_WERROR -> MK_WERROR=no 2021-01-07 09:31:03 +00:00
libarchive libarchive: fix zstd compression support 2022-04-11 00:35:29 +02:00
libauditd libauditd: make it a PRIVATELIB 2020-04-19 02:20:39 +00:00
libbe bectl: push space-in-name check down into libbe 2022-04-05 22:37:07 -05:00
libbearssl Revert that! 2020-07-19 23:56:19 +00:00
libbegemot Update Makefile.depend files 2019-12-11 17:37:53 +00:00
libblacklist Update Makefile.depend files 2019-12-11 17:37:53 +00:00
libblocksruntime Move all sources from the llvm project into contrib/llvm-project. 2019-12-20 19:53:05 +00:00
libbluetooth Update Makefile.depend files 2019-12-11 17:37:53 +00:00
libbsdstat Update Makefile.depend files 2019-12-11 17:37:53 +00:00
libbsm libbsm: fix some MLINKS 2020-04-19 02:18:40 +00:00
libbsnmp pkgbase: Put the mibs and defs in the bnsmp package 2021-06-30 09:24:33 +02:00
libbz2 Update Makefile.depend files 2019-12-11 17:37:53 +00:00
libc cpuset: Byte swap cpuset for compat32 on big endian architectures 2022-06-17 22:35:14 +03:00
libc++ Apply libc++ fix for <ranges> not compiling at all 2022-06-04 14:00:04 +02:00
libc++experimental Merge llvm-project release/13.x llvmorg-13.0.0-rc1-97-g23ba3732246a 2021-12-06 17:30:03 +01:00
libc_nonshared lib: further adoption of SPDX licensing ID tags. 2017-11-26 02:00:33 +00:00
libcalendar Update Makefile.depend files 2019-12-11 17:37:53 +00:00
libcam cam_get_device: resolve path links before parsing device name 2022-02-16 09:52:53 +02:00
libcapsicum Add missing FreeBSD functions to -legacy when building on macOS/Linux 2020-08-25 13:23:31 +00:00
libcasper cap_fileargs: silence warnings of unused variable 2022-03-23 16:45:06 +01:00
libcbor Add libcbor to the build 2022-02-09 16:24:32 -05:00
libclang_rt Merge llvm-project release/14.x llvmorg-14.0.5-0-gc12386ae247c 2022-06-15 22:45:08 +02:00
libcom_err pkgbase: Create a FreeBSD-kerberos package 2022-01-05 18:23:50 +01:00
libcompat ftime appeared in 7th Edition Unix to replace gtime. 2018-10-28 02:58:15 +00:00
libcompiler_rt Build compiler-rt against libunwind, not libcxxrt 2022-03-12 19:21:02 +01:00
libcrypt libcrypt: Drop inclusion of libutil.h 2022-01-24 23:59:19 +00:00
libcuse Update Makefile.depend files 2019-12-11 17:37:53 +00:00
libcxxrt Sort SRCS in libcxxrt's Makefile, and use += to list sources 2022-01-27 19:58:33 +01:00
libdevctl Update Makefile.depend files 2019-12-11 17:37:53 +00:00
libdevdctl Fix race in case of device destruction. 2021-04-27 08:47:39 -04:00
libdevinfo devinfo: add man page links 2020-08-04 21:09:36 +00:00
libdevstat Update Makefile.depend files 2019-12-11 17:37:53 +00:00
libdl libc: include rtld.h into static implementations of rtld interface 2021-04-23 14:14:07 +03:00
libdpv Bump shared library versions after ncurses bump in 13. 2021-02-04 17:51:45 -08:00
libdwarf Apply only the libadd/libnames part of dbf05458e3 2021-12-13 22:23:44 +01:00
libedit sh(1): autocomplete commands 2021-05-05 13:04:57 +02:00
libefivar libefivar(3): Fix a typo in a source code comment 2022-04-02 15:35:15 +02:00
libelf libelf: Link gelf_getchdr.3 to the build 2021-12-06 09:04:03 -05:00
libelftc Update ELF Tool Chain to upstream r3769 2019-12-05 13:20:15 +00:00
libevent1 rename in-tree libevent v1 to libevent1 2020-05-28 22:05:50 +00:00
libexecinfo Move all sources from the llvm project into contrib/llvm-project. 2019-12-20 19:53:05 +00:00
libexpat MFC cc68614, ac69e5d, 7ed8e14: Update contrib/expat to 2.4.7. 2022-03-31 21:38:29 -07:00
libfetch libfetch: remove a set-but-not-used variable 2022-04-30 09:55:31 +02:00
libfido2 Add libfido2 to the build 2022-02-09 16:24:54 -05:00
libfigpar Update Makefile.depend files 2019-12-11 17:37:53 +00:00
libgcc_eh Merge llvm-project release/14.x llvmorg-14-init-18315-g190be5457c90 2022-06-04 13:59:32 +02:00
libgcc_s Export _Unwind_Complete and _Unwind_VRS_Pop from arm's libgcc_s 2022-05-30 13:11:24 +02:00
libgeom GEOM: Fix regression after 7f16b501e2. 2022-05-10 21:20:25 -04:00
libgpio Update Makefile.depend files 2019-12-11 17:37:53 +00:00
libgssapi libgssapi: Fix a common typo in a source code comment 2022-06-10 14:23:10 +02:00
libiconv_modules Do a sweep and remove most WARNS=6 settings 2020-10-01 01:10:51 +00:00
libifconfig libifconfig: Overhaul ifconfig_media_* interfaces 2021-03-19 09:00:19 -04:00
libipsec ipsec(4): Fix a typo in a source code comment 2022-06-10 14:33:00 +02:00
libipt Update Intel Processor Trace decoder library. 2019-10-10 12:46:34 +00:00
libiscsiutil iscsi: Handle large Text responses. 2022-04-29 14:17:43 -07:00
libjail libjail: Handle an error from reallocarray() when trimming the buffer. 2020-01-07 21:44:27 +00:00
libkiconv libkiconv: address memory leak in not-found cases 2021-04-27 20:10:12 -04:00
libkvm libkvm: fix kvm_walk_pages 2022-02-16 20:18:32 -05:00
libldns Update Makefile.depend files 2019-12-11 17:37:53 +00:00
liblua contrib/lua: update to 5.4.2 2021-01-13 23:56:18 -06:00
liblutok Add liblutok a lightweight C++ API for lua. 2020-03-23 18:26:23 +00:00
liblzma Convert libs with pc files to use PCFILES 2021-06-30 09:24:30 +02:00
libmagic file: Fix cross-compilation on Darwin/macOS 2022-01-25 00:05:17 +00:00
libmd libmd: Fix a common typo in the license header 2022-03-30 18:36:55 +02:00
libmemstat sys/bitset.h: reduce visibility of BIT_* macros 2022-01-14 18:17:30 +02:00
libmilter Update Makefile.depend files 2019-12-11 17:37:53 +00:00
libmp Update Makefile.depend files 2019-12-11 17:37:53 +00:00
libmt mt(3): Fix a typo in the manual page 2022-04-09 07:48:20 +02:00
libnetbsd libnetbsd: Fix a typo in a source code comment 2022-04-09 08:15:54 +02:00
libnetgraph Fix SYNPOSIS section to point to the proper include directive. 2020-05-15 12:04:39 +00:00
libnetmap libnetmap: reset errno in nmreq_register_decode() 2021-09-26 14:11:59 +00:00
libngatm Update Makefile.depend files 2019-12-11 17:37:53 +00:00
libnv libpfct: Fix PIC flag 2021-05-07 10:15:43 +02:00
libomp Merge llvm-project release/14.x llvmorg-14-init-18315-g190be5457c90 2022-06-04 13:59:32 +02:00
libopenbsd Only set WARNS if not defined 2020-09-11 13:28:37 +00:00
libopencsd Update opencsd to 0.14.2 2020-06-17 10:42:20 +00:00
libopie Update Makefile.depend files 2019-12-11 17:37:53 +00:00
libpam openssh: update to OpenSSH v8.7p1 2022-02-09 14:53:11 -05:00
libpathconv Fix a few mandoc issues 2020-10-09 19:12:44 +00:00
libpcap MFV r353141 (by phillip): 2019-12-21 21:01:03 +00:00
libpe
libpfctl libpfctl: grow request buffer on ENOSPC 2022-05-04 08:22:37 +02:00
libpjdlog pkgbase: Create a FreeBSD-utilities package and make it the default one 2019-09-05 14:15:47 +00:00
libpmc pmc(3): Fix a common typo in json descriptions 2022-04-02 15:30:28 +02:00
libpmcstat libpmcstat: Fix a few ARM-specific issues with function symbols. 2022-05-11 11:57:17 -07:00
libproc Do a sweep and remove most WARNS=6 settings 2020-10-01 01:10:51 +00:00
libprocstat libprocstat: document procstat_getadvlock(3) 2022-04-16 05:18:18 +03:00
libradius libradius: fix no SSL build 2021-12-12 17:17:00 -05:00
libregex pkgbase: Put more binaries/lib in runtime 2022-01-05 18:23:51 +01:00
librpcsec_gss Fix a few mandoc issues 2020-10-09 19:12:44 +00:00
librpcsvc pkgbase: Put more binaries/lib in runtime 2022-01-05 18:23:51 +01:00
librss Update Makefile.depend files 2019-12-11 17:37:53 +00:00
librt pkgbase: Move librt to clibs 2021-06-30 09:24:31 +02:00
librtld_db librtld_db: Handle shlibs with discontiguous mappings. 2022-01-05 12:23:04 -05:00
libsbuf Do a sweep and remove most WARNS=6 settings 2020-10-01 01:10:51 +00:00
libsdp Update Makefile.depend files 2019-12-11 17:37:53 +00:00
libsecureboot libsecureboot: define SOPEN_MAX 2021-09-03 23:45:16 +03:00
libsm Merge sendmail 8.16.1 to HEAD: See contrib/sendmail/RELEASE_NOTES for details 2020-07-15 18:28:54 +00:00
libsmb Move nsmb.conf to lib/libsmb/ 2018-09-20 09:31:27 +00:00
libsmdb Merge sendmail 8.16.1 to HEAD: See contrib/sendmail/RELEASE_NOTES for details 2020-07-15 18:28:54 +00:00
libsmutil
libsqlite3 [PowerPC64LE] Pass our byte order to the sqlite3 build. 2020-09-23 02:17:44 +00:00
libssp libssp: don't compile with -fstack-protector* 2020-03-14 15:15:27 +00:00
libssp_nonshared Provide libssp based on libc 2020-01-04 20:19:25 +00:00
libstats Make use of the stats(3) framework in the TCP stack. 2019-12-02 20:58:04 +00:00
libstdbuf lib: further adoption of SPDX licensing ID tags. 2017-11-26 02:00:33 +00:00
libstdthreads Update Makefile.depend files 2019-12-11 17:37:53 +00:00
libsysdecode libsysdecode: Add regression tests for sysdecode_cap_rights(3) 2022-04-22 10:36:37 -04:00
libtacplus libtacplus: Remove bogus srandomdev+random 2019-12-13 05:11:34 +00:00
libtelnet Remove redundant include directories which expand to a noop, 2017-07-31 19:07:45 +00:00
libthr Also define THR_PAGE_SIZE_MIN for mips 2022-06-13 20:55:23 +02:00
libthread_db Remove libthr, csu, libthread_db and testfloat sparc64 specific directories. 2020-02-27 04:44:58 +00:00
libucl Only set WARNS if not defined 2020-09-11 13:28:37 +00:00
libufs Update the libufs cgget() and cgput() interfaces to have a similar 2020-09-19 22:48:30 +00:00
libugidfw Deduplicate fsid comparisons 2020-05-21 01:55:35 +00:00
libulog Update Makefile.depend files 2019-12-11 17:37:53 +00:00
libunbound MFV r361322: 2020-05-21 21:00:46 +00:00
libusb libusb(3): Ignore SIGPIPE when initializing the LibUSB v1.0 API. 2022-03-05 15:40:08 +01:00
libusbhid usbhid(3): Fix a typo in the manual page 2022-06-10 14:30:31 +02:00
libutil libutil: eliminate one syscall from kinfo_getproc 2022-05-16 08:28:24 -04:00
libveriexec Do not claim libbearssl et al are INTERNALLIB 2020-04-01 05:45:12 +00:00
libvgl Update Makefile.depend files 2019-12-11 17:37:53 +00:00
libvmmapi bhyve: add ROM emulation 2022-05-16 14:41:14 +02:00
libwrap pkgbase: Put more binaries/lib in runtime 2022-01-05 18:23:51 +01:00
libxo pkgbase: Install libxo test files in the tests package 2021-01-04 16:20:26 +01:00
liby liby: rewrite yyerror.h 2018-06-17 18:05:27 +00:00
libypclnt pkgbase: Put more binaries/lib in runtime 2022-01-05 18:23:51 +01:00
libz lib/libz: remove ZLIBprivate_1.0 namespace. 2022-04-04 15:30:18 -04:00
libzstd Disable clang 14 warning about bitwise operators in zstd 2022-02-11 17:42:30 +01:00
msun libc: Add HISTORY sections to the manual pages 2022-06-04 07:59:43 +02:00
ncurses Bump shared library versions after ncurses bump in 13. 2021-02-04 17:51:45 -08:00
ofed Remove remaining uses of ${COMPILER_FEATURES:Mc++11} 2021-01-19 21:37:36 +00:00
tests
Makefile Add an internal libiscsiutil library. 2022-04-29 14:13:00 -07:00
Makefile.inc build: provide a default WARNS for all in-tree builds 2020-09-18 17:17:46 +00:00