summaryrefslogtreecommitdiffstats
path: root/sys/compat/freebsd32/freebsd32_misc.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Make freebsd32_copyiniov() available outside of freebsd32_misc.kib2010-03-191-1/+1
| | | | MFC after: 2 weeks
* Provide groundwork for 32-bit binary compatibility on non-x86 platforms,nwhitehorn2010-03-111-27/+158
| | | | | | | | | for upcoming 64-bit PowerPC and MIPS support. This renames the COMPAT_IA32 option to COMPAT_FREEBSD32, removes some IA32-specific code from MI parts of the kernel and enhances the freebsd32 compatibility code to support big-endian platforms. Reviewed by: kib, jhb
* Current pselect(3) is implemented in usermode and thus vulnerable tokib2009-10-271-0/+35
| | | | | | | | | | | | | | | | | well-known race condition, which elimination was the reason for the function appearance in first place. If sigmask supplied as argument to pselect() enables a signal, the signal might be delivered before thread called select(2), causing lost wakeup. Reimplement pselect() in kernel, making change of sigmask and sleep atomic. Since signal shall be delivered to the usermode, but sigmask restored, set TDP_OLDMASK and save old mask in td_oldsigmask. The TDP_OLDMASK should be cleared by ast() in case signal was not gelivered during syscall execution. Reviewed by: davidxu Tested by: pho MFC after: 1 month
* In r197963, a race with thread being selected for signal deliverykib2009-10-271-16/+7
| | | | | | | | | | | | | while in kernel mode, and later changing signal mask to block the signal, was fixed for sigprocmask(2) and ptread_exit(3). The same race exists for sigreturn(2), setcontext(2) and swapcontext(2) syscalls. Use kern_sigprocmask() instead of direct manipulation of td_sigmask to reschedule newly blocked signals, closing the race. Reviewed by: davidxu Tested by: pho MFC after: 1 month
* In kern_sigsuspend(), better manipulate thread signal mask usingkib2009-10-271-12/+1
| | | | | | | | | | | | | | | | | | | | | | kern_sigprocmask() to properly notify other possible candidate threads for signal delivery. Since sigsuspend() shall only return to usermode after a signal was delivered, do cursig/postsig loop immediately after waiting for signal, repeating the wait if wakeup was spurious due to race with other thread fetching signal from the process queue before us. Add thread_suspend_check() call to allow the thread to be stopped or killed while in loop. Modify last argument of kern_sigprocmask() from boolean to flags, allowing the function to be called with locked proc. Convertion of the callers that supplied 1 to the old argument will be done in the next commit, and due to SIGPROCMASK_OLD value equial to 1, code is formally correct in between. Reviewed by: davidxu Tested by: pho MFC after: 1 month
* kern_select(9) copies fd_set in and out of userspace in quantities ofkib2009-09-091-1/+2
| | | | | | | | | | | | longs. Since 32bit processes longs are 4 bytes, 64bit kernel may copy in or out 4 bytes more then the process expected. Calculate the amount of bytes to copy taking into account size of fd_set for the current process ABI. Diagnosed and tested by: Peter Jeremy <peterjeremy acm org> Reviewed by: jhb MFC after: 1 week
* Fix the freebsd32 versions of semsys(), shmsys(), and msgsys() to use thejhb2009-07-271-6/+6
| | | | | | | old ABI versions of the relevant control system call (e.g. freebsd7_freebsd32_msgctl() instead of freebsd32_msgctl() for msgsys()). Approved by: re (kib)
* Replace AUDIT_ARG() with variable argument macros with a set more morerwatson2009-06-271-1/+1
| | | | | | | | | | | | | | specific macros for each audit argument type. This makes it easier to follow call-graphs, especially for automated analysis tools (such as fxr). In MFC, we should leave the existing AUDIT_ARG() macros as they may be used by third-party kernel modules. Suggested by: brooks Approved by: re (kib) Obtained from: TrustedBSD Project MFC after: 1 week
* Change the ABI of some of the structures used by the SYSV IPC API:jhb2009-06-241-29/+260
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - The uid/cuid members of struct ipc_perm are now uid_t instead of unsigned short. - The gid/cgid members of struct ipc_perm are now gid_t instead of unsigned short. - The mode member of struct ipc_perm is now mode_t instead of unsigned short (this is merely a style bug). - The rather dubious padding fields for ABI compat with SV/I386 have been removed from struct msqid_ds and struct semid_ds. - The shm_segsz member of struct shmid_ds is now a size_t instead of an int. This removes the need for the shm_bsegsz member in struct shmid_kernel and should allow for complete support of SYSV SHM regions >= 2GB. - The shm_nattch member of struct shmid_ds is now an int instead of a short. - The shm_internal member of struct shmid_ds is now gone. The internal VM object pointer for SHM regions has been moved into struct shmid_kernel. - The existing __semctl(), msgctl(), and shmctl() system call entries are now marked COMPAT7 and new versions of those system calls which support the new ABI are now present. - The new system calls are assigned to the FBSD-1.1 version in libc. The FBSD-1.0 symbols in libc now refer to the old COMPAT7 system calls. - A simplistic framework for tagging system calls with compatibility symbol versions has been added to libc. Version tags are added to system calls by adding an appropriate __sym_compat() entry to src/lib/libc/incldue/compat.h. [1] PR: kern/16195 kern/113218 bin/129855 Reviewed by: arch@, rwatson Discussed with: kan, kib [1]
* Add hierarchical jails. A jail may further virtualize its environmentjamie2009-05-271-149/+15
| | | | | | | | | | | | | | | | | | | | | | by creating a child jail, which is visible to that jail and to any parent jails. Child jails may be restricted more than their parents, but never less. Jail names reflect this hierarchy, being MIB-style dot-separated strings. Every thread now points to a jail, the default being prison0, which contains information about the physical system. Prison0's root directory is the same as rootvnode; its hostname is the same as the global hostname, and its securelevel replaces the global securelevel. Note that the variable "securelevel" has actually gone away, which should not cause any problems for code that properly uses securelevel_gt() and securelevel_ge(). Some jail-related permissions that were kept in global variables and set via sysctls are now per-jail settings. The sysctls still exist for backward compatibility, used only by the now-deprecated jail(2) system call. Approved by: bz (mentor)
* Introduce the extensible jail framework, using the same "name=value"jamie2009-04-291-15/+200
| | | | | | | | | | | | | | interface as nmount(2). Three new system calls are added: * jail_set, to create jails and change the parameters of existing jails. This replaces jail(2). * jail_get, to read the parameters of existing jails. This replaces the security.jail.list sysctl. * jail_remove to kill off a jail's processes and remove the jail. Most jail parameters may now be changed after creation, and jails may be set to exist without any attached processes. The current jail(2) system call still exists, though it is now a stub to jail_set(2). Approved by: bz (mentor)
* Whitespace/spelling fixes in advance of upcoming functional changes.jamie2009-03-271-1/+2
| | | | Approved by: bz (mentor)
* Extend the "vfsopt" mount options for more general use. Make structjamie2009-03-021-9/+2
| | | | | | | | | | | | | | | | vfsopt and the vfs_buildopts function public, and add some new fields to struct vfsopt (pos and seen), and new functions vfs_getopt_pos and vfs_opterror. Further extend the interface to allow reading options from the kernel in addition to sending them to the kernel, with vfs_setopt and related functions. While this allows the "name=value" option interface to be used for more than just FS mounts (planned use is for jails), it retains the current "vfsopt" name and <sys/mount.h> requirement. Approved by: bz (mentor)
* Push down Giant inside sysctl. Also add some more assertions to the code.ed2008-12-291-5/+2
| | | | | | | | | | | | | | In the existing code we didn't really enforce that callers hold Giant before calling userland_sysctl(), even though there is no guarantee it is safe. Fix this by just placing Giant locks around the call to the oid handler. This also means we only pick up Giant for a very short period of time. Maybe we should add MPSAFE flags to sysctl or phase it out all together. I've also added SYSCTL_LOCK_ASSERT(). We have to make sure sysctl_root() and name2oid() are called with the sysctl lock held. Reviewed by: Jille Timmermans <jille quis cx>
* When unloading a 32-bit system call module, restore the sysent vector injhb2008-12-031-1/+1
| | | | the 32-bit system call table instead of the main system call table.
* MFp4:bz2008-11-291-0/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Bring in updated jail support from bz_jail branch. This enhances the current jail implementation to permit multiple addresses per jail. In addtion to IPv4, IPv6 is supported as well. Due to updated checks it is even possible to have jails without an IP address at all, which basically gives one a chroot with restricted process view, no networking,.. SCTP support was updated and supports IPv6 in jails as well. Cpuset support permits jails to be bound to specific processor sets after creation. Jails can have an unrestricted (no duplicate protection, etc.) name in addition to the hostname. The jail name cannot be changed from within a jail and is considered to be used for management purposes or as audit-token in the future. DDB 'show jails' command was added to aid debugging. Proper compat support permits 32bit jail binaries to be used on 64bit systems to manage jails. Also backward compatibility was preserved where possible: for jail v1 syscalls, as well as with user space management utilities. Both jail as well as prison version were updated for the new features. A gap was intentionally left as the intermediate versions had been used by various patches floating around the last years. Bump __FreeBSD_version for the afore mentioned and in kernel changes. Special thanks to: - Pawel Jakub Dawidek (pjd) for his multi-IPv4 patches and Olivier Houchard (cognet) for initial single-IPv6 patches. - Jeff Roberson (jeff) and Randall Stewart (rrs) for their help, ideas and review on cpuset and SCTP support. - Robert Watson (rwatson) for lots and lots of help, discussions, suggestions and review of most of the patch at various stages. - John Baldwin (jhb) for his help. - Simon L. Nielsen (simon) as early adopter testing changes on cluster machines as well as all the testers and people who provided feedback the last months on freebsd-jail and other channels. - My employer, CK Software GmbH, for the support so I could work on this. Reviewed by: (see above) MFC after: 3 months (this is just so that I get the mail) X-MFC Before: 7.2-RELEASE if possible
* Sigh. Fix a pointer/int compile error.peter2008-11-101-1/+1
|
* Fix a signal emulation bug introduced in r163018 (and present in 7.x).peter2008-11-101-1/+1
| | | | | This prevents 32 bit signal handlers from finding out what the faulting address is. Both the secret 4th argument and siginfo->si_addr are zero.
* Split the copyout of *base at the end of getdirentries() out leaving thejhb2008-10-221-0/+18
| | | | | | | | | | rest in kern_getdirentries(). Use kern_getdirentries() to implement freebsd32_getdirentries(). This fixes a bug where calls to getdirentries() in 32-bit binaries would trash the 4 bytes after the 'long base' in userland. Submitted by: ups MFC after: 1 week
* Add support for installing 32-bit system calls from kernel modules. Thisjhb2008-09-251-0/+80
| | | | | | | | includes syscall32_{de,}register() routines as well as a module handler and wrapper macros similar to the support for native syscalls in <sys/sysent.h>. MFC after: 1 month
* Add freebsd32 compat shim for nmount(2).obrien2008-09-191-2/+46
| | | | (and quiet some compiler warnings for vfs_donmount)
* style(9)obrien2008-09-151-3/+4
|
* style(9): put parentheses around return values.brooks2008-07-101-4/+4
|
* id_t is a 64-bit integer and thus is passed as two arguments like off_t is.brooks2008-07-101-0/+57
| | | | | | | As a result, those arguments must be recombined before calling the real syscal implementation. This change fixes 32-bit compatibility for cpuset_getid(), cpuset_setid(), cpuset_getaffinity(), and cpuset_setaffinity().
* Add the freebsd32 compatibility shims for the *at() syscalls.kib2008-03-311-7/+60
| | | | | Reviewed by: rwatson, rdivacky Tested by: pho
* Bah, remove last vestiges of some statfs conversion fixes that aren't quitejhb2007-12-101-22/+10
| | | | | | ready for CVS yet that snuck into 1.68. Pointy hat to: jhb
* Grrr, remove an unused variable missed in the last commit.scottl2007-12-081-1/+0
|
* Don't expect a return value from statfs_scale_blocks().scottl2007-12-071-3/+1
|
* Add freebsd32 compat wrappers for msgctl() and _semctl() usingjhb2007-12-061-25/+184
| | | | | | kern_msgctl() and kern_semctl(). MFC after: 1 week
* Move 32-bit SYSV IPC structure definitions into freebsd32_ipc.h.jhb2007-12-061-36/+1
| | | | MFC after: 1 week
* Move several data structure definitions out of freebsd32_misc.c and intojhb2007-12-061-83/+36
| | | | | | freebsd32.h instead. MFC after: 1 week
* Remove redundant checks for msgsnd(3) and msgrcv(3).jkim2007-12-041-6/+0
| | | | | | COMPAT_IA32 (implicitly) requires SYSVSEM, SYSVSHM and SYSVMSG in kernel. Pointed out by: jhb
* Rework the routines to convert a 5.x+ statfs structure (with fixed-sizejhb2007-08-281-9/+9
| | | | | | | | | | | | | | | 64-bit counters) to a 4.x statfs structure (with long-sized counters). - For block counters, we scale up the block size sufficiently large so that the resulting block counts fit into a the long-sized (long for the ABI, so 32-bit in freebsd32) counters. In 4.x the NFS client's statfs VOP did this already. This can lie about the block size to 4.x binaries, but it presents a more accurate picture of the ratios of free and available space. - For non-block counters, fix the freebsd32 stats converter to cap the values at INT32_MAX rather than losing the upper 32-bits to match the behavior of the 4.x statfs conversion routine in vfs_syscalls.c Approved by: re (kensmith)
* Add compat6 wrapper code for mmap/lseek/pread/pwrite/truncate/ftruncate.peter2007-07-041-0/+83
| | | | Approved by: re (kensmith)
* Try a cheap way to get around gcc4.2 believing that user argumentsmjacob2007-06-171-3/+6
| | | | to system calls can change across intervening functions.
* Remove duplicate includes.cognet2007-05-231-3/+0
| | | | Submitted by: Cyril Nguyen Huu <cyril ci0 org>
* Eliminate the use of Giant from ia64-specific code in freebsd32_mmap().alc2007-05-011-6/+1
|
* MFP4: (part of) 110058jkim2006-12-201-4/+56
| | | | Fix 32-bit msgsnd(3) and msgrcv(3) emulations for amd64.
* Move some declaration of 32-bit signal structures into filedavidxu2006-10-051-6/+84
| | | | freebsd32-signal.h, implement sigtimedwait and sigwaitinfo system calls.
* First part of a little cleanup in the calendar/timezone/RTC handling.phk2006-10-021-0/+1
| | | | | | Move relevant variables to <sys/clock.h> and fix #includes as necessary. Use libkern's much more time- & spamce-efficient BCD routines.
* Add compatible code to let 32bit libthr work on 64bit kernel.davidxu2006-09-221-0/+56
|
* Include sys/limits.h for INT_MAX. freebsd32_proto.h 1.58 does not includejkim2006-08-161-0/+1
| | | | sys/umtx.h any more and previously it was included from there.
* - Split out kern_accept(), kern_getpeername(), and kern_getsockname() forjhb2006-07-101-3/+5
| | | | | | | | | | | | | | | | | | | | use by ABI emulators. - Alter the interface of kern_recvit() somewhat. Specifically, go ahead and hard code UIO_USERSPACE in the uio as that's what all the callers specify. In place, add a new uioseg to indicate what type of pointer is in mp->msg_name. Previously it was always a userland address, but ABI emulators may pass in kernel-side sockaddrs. Also, remove the namelenp field and instead require the two places that used it to explicitly copy mp->msg_namelen out to userland. - Use the patched kern_recvit() to replace svr4_recvit() and the stock kern_sendit() to replace svr4_sendit(). - Use kern_bind() instead of stackgap use in ti_bind(). - Use kern_getpeername() and kern_getsockname() instead of stackgap in svr4_stream_ti_ioctl(). - Use kern_connect() instead of stackgap in svr4_do_putmsg(). - Use kern_getpeername() and kern_accept() instead of stackgap in svr4_do_getmsg(). - Retire the stackgap from SVR4 compat as it is no longer used.
* Unexpand PTRIN() in several places and fix one instance where 0 was beingjhb2006-07-101-13/+13
| | | | used instead of NULL.
* Do not copy out the iovec in the 32bit recvmsg call since soreceiveps2006-06-081-24/+0
| | | | | | | calls uiomove directly. Reviewed by: ups MFC after: 1 week
* Properly support for FreeBSD 4 32bit System V shared memory.ps2006-03-301-4/+166
| | | | | | Submitted by: peter Obtained from: Yahoo! MFC after: 3 weeks
* Fix exec_map resource leaks.ups2006-03-081-9/+13
| | | | Tested by: kris@
* use strlcpy in cvtstatfs and copy_statfs instead of bcopy to ensureps2006-03-041-6/+8
| | | | | | the copied strings are properly terminated. bzero the statfs32 struct in copy_statfs.
* Fix 32bit sendfile by implementing kern_sendfile so that it takesps2006-02-281-18/+64
| | | | | | | | the header and trailers as iovec arguments instead of copying them in inside of sendfile. Reviewed by: jhb MFC after: 3 weeks
* - Always call exec_free_args() in kern_execve() instead of doing it in alljhb2006-02-061-1/+0
| | | | | | the callers if the exec either succeeds or fails early. - Move the code to call exit1() if the exec fails after the vmspace is gone to the bottom of kern_execve() to cut down on some code duplication.
OpenPOWER on IntegriCloud