aboutsummaryrefslogtreecommitdiff
path: root/sys/compat/freebsd32
Commit message (Collapse)AuthorAgeFilesLines
* regenKonstantin Belousov2024-02-114-1/+52
|
* Add kcmp(2) kernel bitsKonstantin Belousov2024-02-111-0/+8
| | | | (cherry picked from commit d8decc9ae31af7ffc77276c89639fb13eb1020cc)
* sendfile: Explicitly ignore errors from copyout()Mark Johnston2024-01-021-1/+1
| | | | | | | | | | | | | There is a documented bug in sendfile.2 which notes that sendfile(2) does not raise an error if it fails to copy out the number of bytes written. Explicitly ignore the error from copyout() calls in preparation for annotating copyout() with __result_use_check. Reviewed by: glebius, kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D43129 (cherry picked from commit d0adc2f283ad5db6b568ca533a056c9f635551cd)
* freebsd32: Report errors when copying out oldlenp in __sysctlMark Johnston2024-01-021-3/+3
| | | | | | | | | | This matches the native implementation's behaviour. Reviewed by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D43101 (cherry picked from commit 81eb7baa69e983fe159d254a4ed47d9c00396801)
* freebsd32: Fix error handling for suword32() callsMark Johnston2023-12-282-5/+5
| | | | | | | | suword32() returns -1 upon an error, not an errno value. MFC after: 1 week (cherry picked from commit bd1654ce92569bbfbe513749db08cdd781b3a036)
* sysvipc: Fix 32-bit compat on !i386Brooks Davis2023-12-141-16/+16
| | | | | | | | | | | | | | The various time fields are time_t's which are only 32-bit on i386. Fixing the old versions is probably of little use, but it's more correct and in theory there could be powerpc binaries from 6.x. PR: 240035 Fixes: fbb273bc05bef Properly support for FreeBSD 4 32bit System V shared memory. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D42870 (cherry picked from commit 957f014dc076a7f74ed0c8c8699e6f39b55785e7)
* linuxolator: implement Linux' PROT_GROWSDOWNKonstantin Belousov2023-08-251-1/+1
| | | | (cherry picked from commit 9b65fa69407808e710748875b0af98902110f128)
* sys: Remove $FreeBSD$: one-line bare tagWarner Losh2023-08-231-1/+0
| | | | | | | Remove /^\s*\$FreeBSD\$$\n/ Similar commit in current: (cherry picked from commit 78d146160dc5)
* sys: Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-232-2/+0
| | | | | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/ Similar commit in current: (cherry picked from commit 031beb4e239b)
* sys: Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-233-6/+0
| | | | | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/ Similar commit in current: (cherry picked from commit 685dc743dc3b)
* sys: Remove $FreeBSD$: one-line .h patternWarner Losh2023-08-235-5/+0
| | | | | | | Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/ Similar commit in current: (cherry picked from commit 2ff63af9b88c)
* sys: Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-236-12/+0
| | | | | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/ Similar commit in current: (cherry picked from commit 95ee2897e98f)
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-07-256-6/+6
| | | | | | | | | | | The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix (cherry picked from commit 4d846d260e2b9a3d4d0a701462568268cbfe7a5b)
* linux(4): Add a dedicated statat() implementationDmitry Chagin2023-06-291-7/+6
| | | | | | | | | | Get rid of calling Linux stat translation hook and specific to Linux handling of non-vnode dirfd from kern_statat(), Reviewed by: kib, mjg Differential revision: https://reviews.freebsd.org/D35474 (cherry picked from commit cb858340dcbf214cc4c4d78dbb741620d7b3a252)
* RegenKonstantin Belousov2023-04-161-1/+1
|
* freebsd32: Make sendmsg match native ABI for unpadded final control messageJessica Clarke2023-01-301-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | The API says that CMSG_SPACE should be used for msg_controllen, but in practice the native ABI allows you to only use CMSG_LEN for the final (typically only) control message, and real-world software does this, including Wayland. For freebsd32, this is in practice mostly harmless, since control messages are generally used to carry file descriptors, which are already 4 bytes in size and thus no padding is needed, but they can carry other quantities that may not result in an aligned length. This was discovered after CheriBSD's freebsd64 equivalent was updated to match the freebsd32 implementation, as that uses 8 byte alignment which does break the file descriptor use case, and thus Wayland. This used to be addressed by aligning buflen before the first iteration, but that allowed unwanted invalid inputs and was lost in 1b1428dcc82b, with no safer equivalent put in its place. Reviewed by: brooks, kib, markj Obtained from: CheriBSD Fixes: 1b1428dcc82b ("Fix a TOCTOU vulnerability in freebsd32_copyin_control().") Differential Revision: https://reviews.freebsd.org/D36554 (cherry picked from commit 7b673a2c73d0577e2c006aeb110295a522b98135)
* freebsd32_sendmsg: fix control message ABIBrooks Davis2023-01-301-10/+11
| | | | | | | | | | | | | | | | | | | | When a freebsd32 caller uses all or most allowed space for control messages (MCLBYTES == 2K) then the message may no longer fit when the messages are padded for 64-bit alignment. Historically we've just shrugged and said there is no ABI guarantee. We ran into this on CheriBSD where a capsicumized 64-bit nm would fail when called with more than 64 files. Fix this by not gratutiously capping size of mbuf data we'll allocate to MCLBYTES and let m_get2 allocate up to MJUMPAGESIZE (4K or larger). Instead of hard-coding a length check, let m_get2 do it and check for a NULL return. Reviewed by: markj, jhb, emaste Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D36322 (cherry picked from commit c46697b9cb97a14f61ac0a58758aab081b9e48c5)
* ptrace(2): add PT_SC_REMOTE remote syscall requestKonstantin Belousov2023-01-202-0/+38
| | | | | | Tested by: pho (cherry picked from commit 140ceb5d956bb8795a77c23d3fd5ef047b0f3c68)
* compat32: move struct ptrace_sc_ret32 definition from .c to .hKonstantin Belousov2023-01-202-5/+5
| | | | | | Tested by: pho (cherry picked from commit f081a291a17de0e28e5b7f5adba312f0dcb59b0f)
* sysent: regen after ee9bc5818356, posix_fadvise in capmodeEd Maste2022-10-201-1/+1
| | | | (cherry picked from commit f99cc5a38947e80c41bfa28855291ac5a2e41fea)
* Finish cpuset_getaffinity() after f35093f8Dmitry Chagin2022-06-171-1/+1
| | | | | | | | | | | | | | | Split cpuset_getaffinity() into a two counterparts, where the user_cpuset_getaffinity() is intended to operate on the cpuset_t from user va, while kern_cpuset_getaffinity() expects the cpuset from kernel va. Accordingly, the code that clears the high bits is moved to the user_cpuset_getaffinity(). Linux sched_getaffinity() syscall returns the size of set copied to the user-space and then glibc wrapper clears the high bits. MFC after: 2 weeks (cherry picked from commit d46174cd8838b86b9fe956b80c82bd238c302b2e)
* sysent: Get rid of bogus sys/sysent.h include.Dmitry Chagin2022-06-171-1/+0
| | | | | | | | Where appropriate hide sysent.h under proper condition. MFC after: 2 weeks (cherry picked from commit 31d1b816fe139f46083f8609c34b7d129a6e2ee0)
* cpuset: Byte swap cpuset for compat32 on big endian architecturesDmitry Chagin2022-06-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 47a57144af25a7bd768b29272d50a36fdf2874ba) Fix the build after 47a57144 (cherry picked from commit 89737eb8290a10d96b77afac1b68e4740b43353b) 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: 47a57144af25 ("cpuset: Byte swap cpuset for compat32 on big endian architectures") Sponsored by: The FreeBSD Foundation (cherry picked from commit 4a3e51335e86cee02569c04b9f1e95ca9abcb170) 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 f35093f8d6d8155ab2e56c11ee03d474688b16a2)
* freebsd32: Remove the unnecessary spaces.Dmitry Chagin2022-06-171-1/+1
| | | | | | | | Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D31247 MFC after: 2 weeks (cherry picked from commit 7cf06e075d1c28ad444e6b6beaf783210123c9d7)
* freebsd32: Remove unused umtx.h include.Dmitry Chagin2022-06-171-1/+0
| | | | | | | Differential Revision: https://reviews.freebsd.org/D31246 MFC after: 2 weeks (cherry picked from commit 3c886cb6917f1ff89e5756916cc0ff011e22c74d)
* freebsd32: Eliminate spaces at end of line.Dmitry Chagin2022-06-171-4/+4
| | | | | | | | Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D31245 MFC after: 2 weeks (cherry picked from commit 32a18e9abd3809cf265e0e2969cd942fa84ae32b)
* cpuset: Fix the KASAN and KMSAN buildsMark Johnston2022-05-231-2/+2
| | | | | | | | | | | | 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: 47a57144af25 ("cpuset: Byte swap cpuset for compat32 on big endian architectures") Sponsored by: The FreeBSD Foundation (cherry picked from commit 4a3e51335e86cee02569c04b9f1e95ca9abcb170)
* cpuset: Byte swap cpuset for compat32 on big endian architecturesJustin Hibbits2022-05-231-4/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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 47a57144af25a7bd768b29272d50a36fdf2874ba)
* Trim duplicate code for copying in iovecs for PT_[GS]ETREGSET.John Baldwin2022-05-121-8/+1
| | | | | | | Reviewed by: andrew, emaste Differential Revision: https://reviews.freebsd.org/D34177 (cherry picked from commit 949e3959669f0ca6697ab0d5e8e0b8194de23f81)
* Add PT_GETREGSETAndrew Turner2022-05-121-0/+22
| | | | | | | | | | | | | | | | | | | | | This adds the PT_GETREGSET and PT_SETREGSET ptrace types. These can be used to access all the registers from a specified core dump note type. The NT_PRSTATUS and NT_FPREGSET notes are initially supported. Other machine-dependant types are expected to be added in the future. The ptrace addr points to a struct iovec pointing at memory to hold the registers along with its length. On success the length in the iovec is updated to tell userspace the actual length the kernel wrote or, if the base address is NULL, the length the kernel would have written. Because the data field is an int the arguments are backwards when compared to the Linux PTRACE_GETREGSET call. Reviewed by: kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D19831 (cherry picked from commit 548a2ec49bd4ebf9ab00d362257c6bb4d2d7edbc)
* freebsd32: Fix layout of struct shmid_kernel32.John Baldwin2022-04-291-4/+4
| | | | | | | | | | | The kernel pointers in this structure need to be 32-bit pointers, not native pointers to 32-bit integers. Reviewed by: kib Sponsored by: The University of Cambridge, Google Inc. Differential Revision: https://reviews.freebsd.org/D33905 (cherry picked from commit da7fc5c33f9a4c906068a9a43f43f8d295100418)
* Clear non-x86 compat stat syscall kernel stack memory disclosureEd Maste2022-03-301-0/+23
| | | | | | | | | | | | | | | | | | | | | | 32-bit architectures other than i386 have 64-bit time_t which results in a struct timespec with 12 bytes for tv_sec and tv_nsec, and 4 bytes of padding. Zero the padding holes in struct stat32 and struct freebsd11_stat32. i386 has 32-bit time_t; struct timespec is 8 bytes and has no padding. Found by inspection, prompted by a report by Reno Robert of Trend Micro Zero Day Initiative. The originally reported issue (ZDI-CAN-14538) is already fixed in all supported FreeBSD versions (it was addressed incidentally as part of the 64-bit inode project). Reviewed by: markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D34709 (cherry picked from commit f90cd1ae30b5f49e9f6ea58a0628ce1c8d8822bc) Approved by: re (gjb, early MFC)
* Remove PT_GET_SC_ARGS_ALLKonstantin Belousov2022-02-211-3/+0
| | | | | | | | | | | | | | | | Reimplement bdf0f24bb16d556a5b by checking for the caller' ABI in the implementation of PT_GET_SC_ARGS, and copying out everything if it is Linuxolator. Also fix a minor information leak: if PT_GET_SC_ARGS_ALL is done on the thread reused after other process, it allows to read some number of that thread last syscall arguments. Clear td_sa.args in thread_alloc(). Reviewed by: jhb Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D31968 (cherry picked from commit f575573ca57716395ad88b962388a55d755cf6a7)
* linux: implement PTRACE_GET_SYSCALL_INFOEdward Tomasz Napierala2022-02-211-0/+3
| | | | | | | | | | | This is one of the pieces required to make modern (ie Focal) strace(1) work. Reviewed By: jhb (earlier version) Sponsored by: EPSRC Differential Revision: https://reviews.freebsd.org/D28212 (cherry picked from commit bdf0f24bb16d556a5b1e01cdfc087d08e91ac572)
* Remove "All Rights Reserved" from FreeBSD Foundation sys/ copyrightsEd Maste2022-02-082-2/+0
| | | | | | | | | These ones were unambiguous cases where the Foundation was the only listed copyright holder (in the associated license block). Sponsored by: The FreeBSD Foundation (cherry picked from commit 9feff969a01044c3083b552f06f7eb6416bc0524)
* exec: Remove the stack gap implementationMark Johnston2022-01-311-2/+0
| | | | | | | | | | | | | | | ASLR stack randomization will reappear in a forthcoming commit. Rather than inserting a random gap into the stack mapping, the entire stack mapping itself will be randomized in the same way that other mappings are when ASLR is enabled. No functional change intended, as the stack gap implementation is currently disabled by default. Reviewed by: kib Sponsored by: The FreeBSD Foundation (cherry picked from commit 758d98debec43ff83b8a1ed9a3d3a8441b83b3cc)
* exec: Introduce the PROC_PS_STRINGS() macroMark Johnston2022-01-311-1/+1
| | | | | | | | | | | Rather than fetching the ps_strings address directly from a process' sysentvec, use this macro. With stack address randomization the ps_strings address is no longer fixed. Reviewed by: kib Sponsored by: The FreeBSD Foundation (cherry picked from commit 706f4a81a81250a326ea25914e7effe1768f1a37)
* Add security.bsd.allow_ptrace sysctlKonstantin Belousov2022-01-291-1/+5
| | | | (cherry picked from commit fe6db727081936c43250f97a4ff4b9de20eb0091)
* RegenKonstantin Belousov2022-01-144-2/+13
|
* Add sched_getcpu()Konstantin Belousov2022-01-141-1/+1
| | | | (cherry picked from commit 77b2c2f81451db8119e4ea6398fe76813db790de)
* exec: Simplify sv_copyout_strings implementations a bitMark Johnston2022-01-141-18/+10
| | | | | | | | | | | | Simplify control flow around handling of the execpath length and signal trampoline. Cache the sysentvec pointer in a local variable. No functional change intended. Reviewed by: kib Sponsored by: The FreeBSD Foundation (cherry picked from commit f04a096049382637178b54ffb45089f5f9fb3db9)
* RegenKonstantin Belousov2021-12-203-3/+9
|
* swapoff: add one more variant of the syscallKonstantin Belousov2021-12-201-2/+4
| | | | | | For MFC, COMPAT_FREEBSD13 braces were removed. (cherry picked from commit 5346570276a5ddfd5f530201fcbf24ddcc53033d)
* fcntl(2): add F_KINFO operationKonstantin Belousov2021-12-131-0/+1
| | | | (cherry picked from commit 794d3e8e63f4a6ebc8926030b6c937109ddc5485)
* freebsd32: Fix a double copyin in sendmsg() and recvmsg()Mark Johnston2021-09-261-11/+3
| | | | | | | | | | | | | | | | | | freebsd32_sendmsg() and freebsd32_recvmsg() both copyin the message header twice, once directly and once in freebsd32_copyinmsghdr(). The iovec length from the former is used when copying in msg_iov, but the rest of the kernel uses the iovec length from the latter. When kern_sendit() and kern_recvit() iterate over the iovec to compute the residual for I/O, they can therefore end up walking past the end of the copied in iovec, either resulting in a system call error, userspace memory corruption from uiomove() with invalid iovecs, or a kernel page fault if the copied-in iovec is followed by an unmapped KVA region. Reported by: syzbot+7cc64cd0c49605acd421@syzkaller.appspotmail.com Reviewed by: kib, emaste Sponsored by: The FreeBSD Foundation (cherry picked from commit fea1a98ead918b39280b586773a923e76194400b)
* freebsd32: Provide an ANSI definition for freebsd32_recvmsg()Mark Johnston2021-09-261-9/+2
| | | | | | | | Fix style in the freebsd32_sendmsg() definition. Sponsored by: The FreeBSD Foundation (cherry picked from commit 4bda16ff184bfca5ee4bf9709a06323d9cf5945b)
* procctl(2): Add PROC_WXMAP_CTL/STATUSKonstantin Belousov2021-09-241-0/+3
| | | | (cherry picked from commit 796a8e1ad1ae3f7b8e4c9f97bebbef5d7d5a2c16)
* procctl(2): add PROC_NO_NEW_PRIVS_CTL, PROC_NO_NEW_PRIVS_STATUSEdward Tomasz Napierala2021-09-241-0/+3
| | | | (cherry picked from commit db8d680ebe9b12c7d9e0eb8bf9940fcef709f5ec)
* RegenKonstantin Belousov2021-08-034-4/+16
|
* Revert most of ce42e793100b460f597e4c85ec0da12e274f9394Konstantin Belousov2021-08-031-2/+4
| | | | | | | | | | | | | | | | to restore ABI compatibility for pre-10.x binaries. It restores _umtx_lock() and _umtx_unlock() syscalls, and UMTX_OP_LOCK/ UMTX_OP_UNLOCK umtx_op(2) operations. UMUTEX_ERROR_CHECK flag is left out for now, I do not think it makes a difference. PR: 218571 Reviewed by: brooks (previous version) Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D31220 (cherry picked from commit 9b6b793bd79521edc082a89b264a30881cb65e22)