summaryrefslogtreecommitdiffstats
path: root/sys/compat/linux/linux_misc.c
Commit message (Collapse)AuthorAgeFilesLines
...
* Merge posix4/* into normal kernel hierarchy.trhodes2006-11-111-2/+1
| | | | | Reviewed by: glanced at by jhb Approved by: silence on -arch@ and -standards@
* Sweep kernel replacing suser(9) calls with priv(9) calls, assigningrwatson2006-11-061-2/+4
| | | | | | | | | | | | | specific privilege names to a broad range of privileges. These may require some future tweaking. Sponsored by: nCircle Network Security, Inc. Obtained from: TrustedBSD Project Discussed on: arch@ Reviewed (at least in part) by: mlaier, jmg, pjd, bde, ceri, Alex Lyashkov <umka at sevcity dot net>, Skip Ford <skip dot ford at verizon dot net>, Antoine Brodin <antoine dot brodin at laposte dot net>
* Fix style(9).netchild2006-10-281-29/+29
| | | | Noticed by: rwatson
* MFP4:netchild2006-10-281-0/+51
| | | | | | | Implement prctl(). Submitted by: rdivacky Tested with: LTP
* Complete break-out of sys/sys/mac.h into sys/security/mac/mac_framework.hrwatson2006-10-221-1/+2
| | | | | | | | | | | | | begun with a repo-copy of mac.h to mac_framework.h. sys/mac.h now contains the userspace and user<->kernel API and definitions, with all in-kernel interfaces moved to mac_framework.h, which is now included across most of the kernel instead. This change is the first step in a larger cleanup and sweep of MAC Framework interfaces in the kernel, and will not be MFC'd. Obtained from: TrustedBSD Project Sponsored by: SPARTA
* - Replace homegrown check for FIFO with S_ISFIFO. [1]netchild2006-10-081-1/+7
| | | | | | | | - Check the status of the options before messing with it. Inspired by: NetBSD [1] Submitted by: rdivacky Tested with: LTP
* - don't reboot() when feed with wrong parameters (and enough permissions) [1]netchild2006-09-161-4/+38
| | | | | | | | | | | - add support to power off the system [2] - check the linux magic values [3] Submitted by: Marcin Cieslak <saper@SYSTEM.PL> [1,2] Modelled after: linux man page of the reboot() syscall [3] Found by: LTP testcase "reboot02" [1] Tested with: LTP testcase "reboot02" [1,3] MFC after: 1 week
* Don't call suser_cred() directly from linux_sethostname(), as it justrwatson2006-08-251-3/+0
| | | | | | | wraps userland_sysctl(), which performs necessary privilege checks as part of its normal operation. MFC after: 1 week
* Sync the MI parts for amd64 with i386 and remove the corresponding specialnetchild2006-08-201-13/+1
| | | | | | | | | handling for amd64 in the common code. The MD parts for amd64 are still outstanding, but at least this fixes some panics on amd64. Sponsored by: Google SoC 2006 Submitted by: rdivacky Tested by: bsam
* - disable some more code when osrelease=2.4.2netchild2006-08-171-22/+46
| | | | | | | | | - protect td->td_proc->p_pid with the proc lock in linux_getpid in the amd64 (= non i386) case [1] Sponsored by: Google SoC 2006 Submitted by: rdivacky Noticed by: netchild [1]
* Move some stuff into headers where they belong.netchild2006-08-171-3/+0
| | | | | | Sponsored by: Google SoC 2006 Submitted by: rdivacky Noticed by: jhb, ssouhlal
* Disable some parts of the code on amd64 for now to prevent a panic. A betternetchild2006-08-151-1/+8
| | | | | | | fix will come later. Sponsored by: Google SoC 2006 Submitted by: rdivacky
* Add the linux 2.6.x stuff (not used by default!):netchild2006-08-151-0/+98
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - TLS - complete - pid/tid mangling - complete - thread area - complete - futexes - complete with issues - clone() extension - complete with some possible minor issues - mq*/timer*/clock* stuff - complete but untested and the mq* stuff is disabled when not build as part of the kernel with native FreeBSD mq* support (module support for this will come later) Tested with: - linux-firefox - works, tested - linux-opera - works, tested - linux-realplay - doesnt work, issue with futexes - linux-skype - doesnt work, issue with futexes - linux-rt2-demo - works, tested - linux-acroread - doesnt work, unknown reason (coredump) and sometimes issue with futexes - various unix utilities in linux-base-gentoo3 and linux-base-fc4: everything tried worked On amd64 not everything is supported like on i386, the catchup is planned for later when the remaining bugs in the new functions are fixed. To test this new stuff, you have to run sysctl compat.linux.osrelease=2.6.16 to switch back use sysctl compat.linux.osrelease=2.4.2 Don't switch while running a linux program, strange things may or may not happen. Sponsored by: Google SoC 2006 Submitted by: rdivacky Some suggestions/help by: jhb, kib, manu@NetBSD.org, netchild
* - Pass the MPSAFE flag to namei() in linux_uselib() and handle conditionaljhb2006-07-211-24/+25
| | | | | | | | | | | | | Giant VFS locking in that function. - Remove bogus code to handle the case where namei() returns success but a NULL vnode pointer. - Note that this code duplicates exec_check_permissions() and annotate where it differs. - Hold the vnode lock longer to protect the write to set VV_TEXT in v_vflag. - Mark linux_uselib() MPSAFE. Reviewed by: rwatson
* The linux times syscall can be called with a NULL pointer, so keep coolnetchild2006-06-231-11/+13
| | | | | | | | | | | | | and don't panic. This fix is different from the patch submitted as it not only prevents a NULL-pointer dereference, but also skips some work in this case. Noticed by: Dmitry Ganenko <dima@apk-inform.com> Reviewed by: rdivacky (the original version as in emulation@) MFC after: 1 week Security: This is a RELENG_x_y candidate (local DoS). Go ahead by: secteam (cperciva)
* Now that we don't have a linuxolator on alpha anymore:netchild2006-05-101-29/+4
| | | | | - unifdef __alpha__ - revert rev. 1.66 of linux_socket.c
* Unbreaking build by removing a now unused variable.avatar2006-03-271-1/+0
|
* Use td_ucred rather than p_ucred to avoid panics and general unhappiness.jhb2006-03-271-1/+1
| | | | Pointy hat to: netchild
* Unbreak COMPAT_LINUX32 option support on amd64.ru2006-03-191-0/+1
| | | | Broken by: netchild
* Fixup some problems in my previous commit (COMPAT_43).netchild2006-03-181-1/+0
| | | | Pointyhat to: netchild
* Get rid of the need of COMPAT_43 in the linuxolator.netchild2006-03-181-2/+17
| | | | | Submitted by: Divacky Roman <xdivac02@stud.fit.vutbr.cz> Obtained from: DragonFly (some parts)
* Cast tv_sec to intmax_t and print with %jd in some ifdef'ed code.trhodes2005-12-281-8/+8
|
* 1. Change prototype of trapsignal and sendsig to use ksiginfo_t *, mostdavidxu2005-10-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | changes in MD code are trivial, before this change, trapsignal and sendsig use discrete parameters, now they uses member fields of ksiginfo_t structure. For sendsig, this change allows us to pass POSIX realtime signal value to user code. 2. Remove cpu_thread_siginfo, it is no longer needed because we now always generate ksiginfo_t data and feed it to libpthread. 3. Add p_sigqueue to proc structure to hold shared signals which were blocked by all threads in the proc. 4. Add td_sigqueue to thread structure to hold all signals delivered to thread. 5. i386 and amd64 now return POSIX standard si_code, other arches will be fixed. 6. In this sigqueue implementation, pending signal set is kept as before, an extra siginfo list holds additional siginfo_t data for signals. kernel code uses psignal() still behavior as before, it won't be failed even under memory pressure, only exception is when deleting a signal, we should call sigqueue_delete to remove signal from sigqueue but not SIGDELSET. Current there is no kernel code will deliver a signal with additional data, so kernel should be as stable as before, a ksiginfo can carry more information, for example, allow signal to be delivered but throw away siginfo data if memory is not enough. SIGKILL and SIGSTOP have fast path in sigqueue_add, because they can not be caught or masked. The sigqueue() syscall allows user code to queue a signal to target process, if resource is unavailable, EAGAIN will be returned as specification said. Just before thread exits, signal queue memory will be freed by sigqueue_flush. Current, all signals are allowed to be queued, not only realtime signals. Earlier patch reviewed by: jhb, deischen Tested on: i386, amd64
* Fix the computation of uptime for linux_sysinfo(). Before it was returningjhb2005-07-071-15/+3
| | | | | | the uptime in seconds mod 60 which wasn't very useful. Approved by: re (scottl)
* Properly convert FreeBSD priority values into Linux values in thesobomax2005-06-081-0/+13
| | | | | | | getpriority(2) syscall. PR: kern/81951 Submitted by: Andriy Gapon <avg@icyb.net.ua>
* - Pass the ISOPEN flag to namei so filesystems will know we're about tojeff2005-04-271-1/+1
| | | | open them or otherwise access the data.
* - Change the vm_mmap() function to accept an objtype_t parameter specifyingjhb2005-04-011-3/+3
| | | | | | | | | | | | the type of object represented by the handle argument. - Allow vm_mmap() to map device memory via cdev objects in addition to vnodes and anonymous memory. Note that mmaping a cdev directly does not currently perform any MAC checks like mapping a vnode does. - Unbreak the DRM getbufs ioctl by having it call vm_mmap() directly on the cdev the ioctl is acting on rather than trying to find a suitable vnode to map from. Reviewed by: alc, arch@
* Handle unimplemented syscall by instantly returning ENOSYS instead of sendingsobomax2005-03-071-0/+9
| | | | | | | signal first and only then returning ENOSYS to match what real linux does. PR: kern/74302 Submitted by: Travis Poppe <tlp@LiquidX.org>
* Use kern_setitimer() to implement linux_alarm() instead of fondling thejhb2005-02-071-19/+7
| | | | real interval timer directly.
* Split out kernel side of {get,set}itimer(2) into two parts: the first thatsobomax2005-01-251-64/+33
| | | | | | | | pops data from the userland and pushes results back and the second which does actual processing. Use the latter to eliminate stackgap in the linux wrappers of those syscalls. MFC after: 2 weeks
* Match the LINUX32's style with existing styleobrien2005-01-141-13/+13
| | | | | | Submitted by: Jung-uk Kim <jkim@niksun.com> Use positive, not negative logic.
* Fix Linux compat 'uname -m' on AMD64.obrien2005-01-141-1/+7
| | | | | Submitted by: Jung-uk Kim <jkim@niksun.com> (patch reworked by me)
* Rework how we store process times in the kernel such that we always storejhb2004-10-051-11/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | the raw values including for child process statistics and only compute the system and user timevals on demand. - Fix the various kern_wait() syscall wrappers to only pass in a rusage pointer if they are going to use the result. - Add a kern_getrusage() function for the ABI syscalls to use so that they don't have to play stackgap games to call getrusage(). - Fix the svr4_sys_times() syscall to just call calcru() to calculate the times it needs rather than calling getrusage() twice with associated stackgap, etc. - Add a new rusage_ext structure to store raw time stats such as tick counts for user, system, and interrupt time as well as a bintime of the total runtime. A new p_rux field in struct proc replaces the same inline fields from struct proc (i.e. p_[isu]ticks, p_[isu]u, and p_runtime). A new p_crux field in struct proc contains the "raw" child time usage statistics. ruadd() has been changed to handle adding the associated rusage_ext structures as well as the values in rusage. Effectively, the values in rusage_ext replace the ru_utime and ru_stime values in struct rusage. These two fields in struct rusage are no longer used in the kernel. - calcru() has been split into a static worker function calcru1() that calculates appropriate timevals for user and system time as well as updating the rux_[isu]u fields of a passed in rusage_ext structure. calcru() uses a copy of the process' p_rux structure to compute the timevals after updating the runtime appropriately if any of the threads in that process are currently executing. It also now only locks sched_lock internally while doing the rux_runtime fixup. calcru() now only requires the caller to hold the proc lock and calcru1() only requires the proc lock internally. calcru() also no longer allows callers to ask for an interrupt timeval since none of them actually did. - calcru() now correctly handles threads executing on other CPUs. - A new calccru() function computes the child system and user timevals by calling calcru1() on p_crux. Note that this means that any code that wants child times must now call this function rather than reading from p_cru directly. This function also requires the proc lock. - This finishes the locking for rusage and friends so some of the Giant locks in exit1() and kern_wait() are now gone. - The locking in ttyinfo() has been tweaked so that a shared lock of the proctree lock is used to protect the process group rather than the process group lock. By holding this lock until the end of the function we now ensure that the process/thread that we pick to dump info about will no longer vanish while we are trying to output its info to the console. Submitted by: bde (mostly) MFC after: 1 month
* Fix the 'DEBUG' argument code to unbreak the amd64 LINT build.obrien2004-08-161-2/+2
|
* Fix the 'DEBUG' argument code to unbreak the LINT build.obrien2004-08-161-2/+2
|
* Changes to MI Linux emulation code necessary to run 32-bit Linux binariestjr2004-08-161-6/+29
| | | | | | | | | | | | | | | on AMD64, and the general case where the emulated platform has different size pointers than we use natively: - declare certain structure members as l_uintptr_t and use the new PTRIN and PTROUT macros to convert to and from native pointers. - declare some structures __packed on amd64 when the layout would differ from that used on i386. - include <machine/../linux32/linux.h> instead of <machine/../linux/linux.h> if compiling with COMPAT_LINUX32. This will need to be revisited before 32-bit and 64-bit Linux emulation support can coexist in the same kernel. - other small scattered changes. This should be a no-op on i386 and Alpha.
* Replace linux_getitimer() and linux_setitimer() with implementationstjr2004-08-151-24/+77
| | | | | based on those in freebsd32_misc.c, removing the assumption that Linux uses the same layout for struct itimerval as we use natively.
* Avoid assuming that l_timeval is the same as the native struct timevaltjr2004-08-151-2/+7
| | | | in linux_select().
* Rename suser_cred()'s PRISON_ROOT flag to SUSER_ALLOWJAIL. This iscperciva2004-07-261-1/+1
| | | | | | | | | | | somewhat clearer, but more importantly allows for a consistent naming scheme for suser_cred flags. The old name is still defined, but will be removed in a few days (unless I hear any complaints...) Discussed with: rwatson, scottl Requested by: jhb
* Deorbit COMPAT_SUNOS.phk2004-06-111-1/+1
| | | | | We inherited this from the sparc32 port of BSD4.4-Lite1. We have neither a sparc32 port nor a SunOS4.x compatibility desire these days.
* - Replace wait1() with a kern_wait() function that accepts the pid,jhb2004-03-171-32/+15
| | | | | | | | | | | | | | | options, status pointer and rusage pointer as arguments. It is up to the caller to copyout the status and rusage to userland if needed. This lets us axe the 'compat' argument and hide all that functionality in owait(), by the way. This also cleans up some locking in kern_wait() since it no longer has to drop locks around copyout() since all the copyout()'s are deferred. - Convert owait(), wait4(), and the various ABI compat wait() syscalls to use kern_wait() rather than wait1() or wait4(). This removes a bit more stackgap usage. Tested on: i386 Compiled on: i386, alpha, amd64
* Locking for the per-process resource limits structure.jhb2004-02-041-14/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - struct plimit includes a mutex to protect a reference count. The plimit structure is treated similarly to struct ucred in that is is always copy on write, so having a reference to a structure is sufficient to read from it without needing a further lock. - The proc lock protects the p_limit pointer and must be held while reading limits from a process to keep the limit structure from changing out from under you while reading from it. - Various global limits that are ints are not protected by a lock since int writes are atomic on all the archs we support and thus a lock wouldn't buy us anything. - All accesses to individual resource limits from a process are abstracted behind a simple lim_rlimit(), lim_max(), and lim_cur() API that return either an rlimit, or the current or max individual limit of the specified resource from a process. - dosetrlimit() was renamed to kern_setrlimit() to match existing style of other similar syscall helper functions. - The alpha OSF/1 compat layer no longer calls getrlimit() and setrlimit() (it didn't used the stackgap when it should have) but uses lim_rlimit() and kern_setrlimit() instead. - The svr4 compat no longer uses the stackgap for resource limits calls, but uses lim_rlimit() and kern_setrlimit() instead. - The ibcs2 compat no longer uses the stackgap for resource limits. It also no longer uses the stackgap for accessing sysctl's for the ibcs2_sysconf() syscall but uses kernel_sysctl() instead. As a result, ibcs2_sysconf() no longer needs Giant. - The p_rlimit macro no longer exists. Submitted by: mtm (mostly, I only did a few cleanups and catchups) Tested on: i386 Compiled on: alpha, amd64
* Lock the traversal of the vm object list. Use TAILQ_FOREACH consistently.alc2004-01-021-2/+3
|
* Pull latest changes from OpenBSD:sobomax2003-11-161-3/+13
| | | | | | | | | | | - improve sysinfo(2) syscall; - add dummy fadvise64(2) syscall; - add dummy *xattr(2) family of syscalls; - add protos for the syscalls 222-225, 238-249 and 253-267; - add exit_group(2) syscall, which is currently just wired to exit(2). Obtained from: OpenBSD MFC after: 2 weeks
* Reject negative ngrp arguments in linux_setgroups() and linux_setgroups16();tjr2003-10-211-1/+1
| | | | | stops users being able to cause setgroups to clobber the kernel stack by copying in data past the end of the linux_gidset array.
* Restored a non-egregious cast so that this file compiles on i386'sbde2003-09-071-1/+1
| | | | | | | | | | | | | with 64-bit longs again. This was fixed in rev.1.42 but the fix rotted non-fatally in rev.1.105 and fatally in rev.1.137. Many more non-egregrious casts are strictly required for conversions from semi-opaque types to pointers, but we avoid most of them by using types that are almost certain to be compatible with uintptr_t for representing pointers (e.g., vm_offset_t). Here we don't really want the u_longs, but we have them because a.out.h and its support code doesn't use typedefs (it uses unsigned in V7 and unsigned long in FreeBSD) and is too obsolete to fix now.
* Try to make 'uname -a' look more like it does on Linux:des2003-07-291-0/+30
| | | | | | | | | | - cut the version string at the newline, suppressing information about who built the kernel and in what directory. Most of this information was already lost to truncation. - on i386, return the precise CPU class (if known) rather than just "i386". Linux software which uses this information to select which binary to run often does not know what to make of "i386".
* Add a "int fd" argument to VOP_OPEN() which in the future willphk2003-07-261-1/+1
| | | | | | | | | contain the filedescriptor number on opens from userland. The index is used rather than a "struct file *" since it conveys a bit more information, which may be useful to in particular fdescfs and /dev/fd/* For now pass -1 all over the place.
* Add a new function swap_pager_status() which reports the total size of thephk2003-07-181-8/+4
| | | | | | | paging space and how much of it is in use (in pages). Use this interface from the Linuxolator instead of groping around in the internals of the swap_pager.
* Use __FBSDID().obrien2003-06-101-2/+3
|
OpenPOWER on IntegriCloud