summaryrefslogtreecommitdiffstats
path: root/sys/compat/linux/linux_misc.c
Commit message (Collapse)AuthorAgeFilesLines
* Since all other comparisons involving ngroups_max usebrooks2010-01-151-1/+1
| | | | | "ngroups_max + 1", use ">= ngroups_max+1" instead of the equivalent "> ngroups_max" to reduce confusion.
* Replace the static NGROUPS=NGROUPS_MAX+1=1024 with a dynamicbrooks2010-01-121-1/+1
| | | | | | | | kern.ngroups+1. kern.ngroups can range from NGROUPS_MAX=1023 to INT_MAX-1. Given that the Windows group limit is 1024, this range should be sufficient for most applications. MFC after: 1 month
* kern_select(9) copies fd_set in and out of userspace in quantities ofkib2009-09-091-1/+1
| | | | | | | | | | | | 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
* Rework the credential code to support larger values of NGROUPS andbrooks2009-06-191-9/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | NGROUPS_MAX, eliminate ABI dependencies on them, and raise the to 1024 and 1023 respectively. (Previously they were equal, but under a close reading of POSIX, NGROUPS_MAX was defined to be too large by 1 since it is the number of supplemental groups, not total number of groups.) The bulk of the change consists of converting the struct ucred member cr_groups from a static array to a pointer. Do the equivalent in kinfo_proc. Introduce new interfaces crcopysafe() and crsetgroups() for duplicating a process credential before modifying it and for setting group lists respectively. Both interfaces take care for the details of allocating groups array. crsetgroups() takes care of truncating the group list to the current maximum (NGROUPS) if necessary. In the future, crsetgroups() may be responsible for insuring invariants such as sorting the supplemental groups to allow groupmember() to be implemented as a binary search. Because we can not change struct xucred without breaking application ABIs, we leave it alone and introduce a new XU_NGROUPS value which is always 16 and is to be used or NGRPS as appropriate for things such as NFS which need to use no more than 16 groups. When feasible, truncate the group list rather than generating an error. Minor changes: - Reduce the number of hand rolled versions of groupmember(). - Do not assign to both cr_gid and cr_groups[0]. - Modify ipfw to cache ucreds instead of part of their contents since they are immutable once referenced by more than one entity. Submitted by: Isilon Systems (initial implementation) X-MFC after: never PR: bin/113398 kern/133867
* Add counterparts to getcredhostname:jamie2009-06-131-6/+1
| | | | | | | getcreddomainname, getcredhostuuid, getcredhostid Suggested by: rmacklem Approved by: bz
* Move "options MAC" from opt_mac.h to opt_global.h, as it's now in GENERICrwatson2009-06-051-1/+0
| | | | | | | | and used in a large number of files, but also because an increasing number of incorrect uses of MAC calls were sneaking in due to copy-and-paste of MAC-aware code without the associated opt_mac.h include. Discussed with: pjd
* Place hostnames and similar information fully under the prison system.jamie2009-05-291-5/+5
| | | | | | | | | | | | | | | | | The system hostname is now stored in prison0, and the global variable "hostname" has been removed, as has the hostname_mtx mutex. Jails may have their own host information, or they may inherit it from the parent/system. The proper way to read the hostname is via getcredhostname(), which will copy either the hostname associated with the passed cred, or the system hostname if you pass NULL. The system hostname can still be accessed directly (and without locking) at prison0.pr_host, but that should be avoided where possible. The "similar information" referred to is domainname, hostid, and hostuuid, which have also become prison parameters and had their associated global variables removed. Approved by: bz (mentor)
* Do not export AT_CLKTCK when emulating Linux kernel priordchagin2009-05-101-1/+13
| | | | | | | | | | | | | | to 2.4.0, as it has appeared in the 2.4.0-rc7 first time. Being exported, AT_CLKTCK is returned by sysconf(_SC_CLK_TCK), glibc falls back to the hard-coded CLK_TCK value when aux entry is not present. Glibc versions prior to 2.2.1 always use hard-coded CLK_TCK value. For older applications/libc's which depends on hard-coded CLK_TCK value user should set compat.linux.osrelease less than 2.4.0. Approved by: kib (mentor)
* Rework r189362, r191883.dchagin2009-05-101-1/+3
| | | | | | | | | The frequency of the statistics clock is given by stathz. Use stathz if it is available, otherwise use hz. Pointed out by: bde Approved by: kib (mentor)
* Linux exports HZ value to user space via AT_CLKTCK auxiliary vector entry,dchagin2009-05-071-3/+1
| | | | | | | | | | | | | which is available for Glibc as sysconf(_SC_CLK_TCK). If AT_CLKTCK entry is not exported, Glibc uses 100. linux_times() shall use the value that is exported to user space. Pointyhat to: dchagin PR: kern/134251 Approved by: kib (mentor) MFC after: 2 weeks
* Change linux struct tms definition to match actual linux one.dchagin2009-05-071-4/+4
| | | | | Approved by: kib (mentor) MFC after: 2 weeks
* Add AT_PLATFORM, AT_HWCAP and AT_CLKTCK auxiliary vector entries whichdchagin2009-03-041-31/+1
| | | | | | | | | | | | | | are used by glibc. This silents the message "2.4+ kernel w/o ELF notes?" from some programs at start, among them are top and pkill. Do the assignment of the vector entries in elf_linux_fixup() as it is done in glibc. Fix some minor style issues. Submitted by: Marcin Cieslak <saper at SYSTEM PL> Approved by: kib (mentor) MFC after: 1 week
* Push down Giant inside sysctl. Also add some more assertions to the code.ed2008-12-291-12/+4
| | | | | | | | | | | | | | 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>
* Mark uname(), getdomainname() and setdomainname() with COMPAT_FREEBSD4.ed2008-11-091-2/+26
| | | | | | | | | | | | | | | | | | | | | Looking at our source code history, it seems the uname(), getdomainname() and setdomainname() system calls got deprecated somewhere after FreeBSD 1.1, but they have never been phased out properly. Because we don't have a COMPAT_FREEBSD1, just use COMPAT_FREEBSD4. Also fix the Linuxolator to build without the setdomainname() routine by just making it call userland_sysctl on kern.domainname. Also replace the setdomainname()'s implementation to use this approach, because we're duplicating code with sysctl_domainname(). I wasn't able to keep these three routines working in our COMPAT_FREEBSD32, because that would require yet another keyword for syscalls.master (COMPAT4+NOPROTO). Because this routine is probably unused already, this won't be a problem in practice. If it turns out to be a problem, we'll just restore this functionality. Reviewed by: rdivacky, kib
* Current linux_fooaffinity() emulation fails, as the FreeBSD affinitykib2008-10-041-4/+9
| | | | | | | | | | | | | | syscalls expect the bitmap size in the range from 32 to 128. Old glibc always assumed size 1024, while newer glibc searches for approriate size, starting from 1024 and going up. For now, use FreeBSD size of cpuset_t for bitmap size parameter and return EINVAL if length of user space bitmap less than our size of cpuset_t. Submitted by: dchagin MFC after: 1 week [This requires MFC of the actual linux affinity syscalls]
* Step 1.5 of importing the network stack virtualization infrastructurezec2008-10-021-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | from the vimage project, as per plan established at devsummit 08/08: http://wiki.freebsd.org/Image/Notes200808DevSummit Introduce INIT_VNET_*() initializer macros, VNET_FOREACH() iterator macros, and CURVNET_SET() context setting macros, all currently resolving to NOPs. Prepare for virtualization of selected SYSCTL objects by introducing a family of SYSCTL_V_*() macros, currently resolving to their global counterparts, i.e. SYSCTL_V_INT() == SYSCTL_INT(). Move selected #defines from sys/sys/vimage.h to newly introduced header files specific to virtualized subsystems (sys/net/vnet.h, sys/netinet/vinet.h etc.). All the changes are verified to have zero functional impact at this point in time by doing MD5 comparision between pre- and post-change object files(*). (*) netipsec/keysock.c did not validate depending on compile time options. Implemented by: julian, bz, brooks, zec Reviewed by: julian, bz, brooks, kris, rwatson, ... Approved by: julian (mentor) Obtained from: //depot/projects/vimage-commit2/... X-MFC after: never Sponsored by: NLnet Foundation, The FreeBSD Foundation
* Fix usage of mac_vnode_check_open() in linuxulator - last argumenttrasz2008-09-221-1/+1
| | | | | | should be VREAD, not FREAD. Approved by: rwatson (mentor)
* The ERESTART to EINTR conversion is already done inrdivacky2008-09-111-8/+1
| | | | | | | | | kern_select so there is no need to repeat it in linux_select(). Submitted by: Dmitry Chagin <dchagin@> MFC after: 1 week Approved by: kib (mentor)
* Decontextualize the couplet VOP_GETATTR / VOP_SETATTR as the passed threadattilio2008-08-281-1/+1
| | | | | | was always curthread and totally unuseful. Tested by: Giovanni Trematerra <giovanni dot trematerra at gmail dot com>
* Commit step 1 of the vimage project, (network stack)bz2008-08-171-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | virtualization work done by Marko Zec (zec@). This is the first in a series of commits over the course of the next few weeks. Mark all uses of global variables to be virtualized with a V_ prefix. Use macros to map them back to their global names for now, so this is a NOP change only. We hope to have caught at least 85-90% of what is needed so we do not invalidate a lot of outstanding patches again. Obtained from: //depot/projects/vimage-commit2/... Reviewed by: brooks, des, ed, mav, julian, jamie, kris, rwatson, zec, ... (various people I forgot, different versions) md5 (with a bit of help) Sponsored by: NLnet Foundation, The FreeBSD Foundation X-MFC after: never V_Commit_Message_Reviewed_By: more people than the patch
* Fix linux_alarm, the linux behaviour is to limit therdivacky2008-07-231-3/+6
| | | | | | | | secs to INT_MAX when the passed in parameter is bigger than INT_MAX. Submitted by: Dmitry Chagin <chagin.dmitry gmail com> Approved by: kib (mentor)
* Introduce a new lock, hostname_mtx, and use it to synchronize accessrwatson2008-07-051-0/+2
| | | | | | | | | | | | to global hostname and domainname variables. Where necessary, copy to or from a stack-local buffer before performing copyin() or copyout(). A few uses, such as in cd9660 and daemon_saver, remain under-synchronized and will require further updates. Correct a bug in which a failed copyin() of domainname would leave domainname potentially corrupted. MFC after: 3 weeks
* Implement robust futexes. Most of the code is modelled afterrdivacky2008-05-131-4/+3
| | | | | | | | | | | what Linux does. This is because robust futexes are mostly userspace thing which we cannot alter. Two syscalls maintain pointer to userspace list and when process exits a routine walks this list waking up processes sleeping on futexes from that list. Reviewed by: kib (mentor) MFC after: 1 month
* Implement the linux syscallskib2008-04-081-0/+84
| | | | | | | | | openat, mkdirat, mknodat, fchownat, futimesat, fstatat, unlinkat, renameat, linkat, symlinkat, readlinkat, fchmodat, faccessat. Submitted by: rdivacky Sponsored by: Google Summer of Code 2007 Tested by: pho
* Fix build.ru2008-03-251-2/+2
| | | | Reported by: ache, tinderbox
* Implement sched_setaffinity and get_setaffinity usingrdivacky2008-03-161-9/+40
| | | | | | | real cpu affinity setting primitives. Reviewed by: jeff Approved by: kib (mentor)
* Sanitize arguments to linux_mremap().kib2008-02-221-0/+15
| | | | | | | | Check that only MREMAP_FIXED and MREMAP_MAYMOVE flags are specified. Check for the page alignment of the addr argument. Submitted by: rdivacky MFC after: 1 week
* VOP_LOCK1() (and so VOP_LOCK()) and VOP_UNLOCK() are only used inattilio2008-01-131-2/+2
| | | | | | | | | | | conjuction with 'thread' argument passing which is always curthread. Remove the unuseful extra-argument and pass explicitly curthread to lower layer functions, when necessary. KPI results broken by this change, which should affect several ports, so version bumping and manpage update will be further committed. Tested by: kris, pho, Diego Sardina <siarodx at gmail dot com>
* Merge first in a series of TrustedBSD MAC Framework KPI changesrwatson2007-10-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | from Mac OS X Leopard--rationalize naming for entry points to the following general forms: mac_<object>_<method/action> mac_<object>_check_<method/action> The previous naming scheme was inconsistent and mostly reversed from the new scheme. Also, make object types more consistent and remove spaces from object types that contain multiple parts ("posix_sem" -> "posixsem") to make mechanical parsing easier. Introduce a new "netinet" object type for certain IPv4/IPv6-related methods. Also simplify, slightly, some entry point names. All MAC policy modules will need to be recompiled, and modules not updates as part of this commit will need to be modified to conform to the new KPI. Sponsored by: SPARTA (original patches against Mac OS X) Obtained from: TrustedBSD Project, Apple Computer
* Implement fake linux sched_getaffinity() syscall to enable java to workkib2007-08-281-0/+21
| | | | | | | | | | with Linux 2.6 emulation. This shall be reimplemented once FreeBSD gets native scheduler affinity syscalls. Submitted by: rdivacky Reviewed by: jkim Sponsored by: Google Summer of Code 2007 Approved by: re (kensmith)
* Eliminate now-unused SUSER_ALLOWJAIL arguments to priv_check_cred(); inrwatson2007-06-121-2/+1
| | | | | | | | | | | | | | | some cases, move to priv_check() if it was an operation on a thread and no other flags were present. Eliminate caller-side jail exception checking (also now-unused); jail privilege exception code now goes solely in kern_jail.c. We can't yet eliminate suser() due to some cases in the KAME code where a privilege check is performed and then used in many different deferred paths. Do, however, move those prototypes to priv.h. Reviewed by: csjp Obtained from: TrustedBSD Project
* rufetch and calcru sometimes should be called atomically together.attilio2007-06-091-0/+2
| | | | | | | | | | This patch fixes places where they should be called atomically changing their locking requirements (both assume per-proc spinlock held) and introducing rufetchcalc which wrappers both calls to be performed in atomic way. Reviewed by: jeff Approved by: jeff (mentor)
* Revert VMCNT_* operations introduction.attilio2007-05-311-1/+1
| | | | | | | | Probabilly, a general approach is not the better solution here, so we should solve the sched_lock protection problems separately. Requested by: alc Approved by: jeff (mentor)
* Revert UF_OPENING workaround for CURRENT.kib2007-05-311-1/+2
| | | | | | | | | Change the VOP_OPEN(), vn_open() vnode operation and d_fdopen() cdev operation argument from being file descriptor index into the pointer to struct file. Proposed and reviewed by: jhb Reviewed by: daichi (unionfs) Approved by: re (kensmith)
* - define and use VMCNT_{GET,SET,ADD,SUB,PTR} macros for manipulatingjeff2007-05-181-1/+1
| | | | | | | | vmcnts. This can be used to abstract away pcpu details but also changes to use atomics for all counters now. This means sched lock is no longer responsible for protecting counts in the switch routines. Contributed by: Attilio Rao <attilio@FreeBSD.org>
* Partial MFp4 of 114977:netchild2007-02-241-5/+4
| | | | | | Whitespace commit: Fix grammar, spelling and punctuation. Submitted by: "Scot Hetzel" <swhetzel@gmail.com>
* MFp4 (114193 (i386 part), 114194, 114195, 114200):netchild2007-02-231-3/+5
| | | | | | | | | | | | | - Dont "return" in linux_clone() after we forked the new process in a case of problems. - Move the copyout of p2->p_pid outside the emul_lock coverage in linux_clone(). - Cache the em->pdeath_signal in a local variable and move the copyout out of the emul_lock coverage. - Move the free() out of the emul_shared_lock coverage in a preparation to switch emul_lock to non-sleepable lock (mutex). Submitted by: rdivacky
* No need to lock emul_lock in exit_group() because em->sharedkib2007-02-011-3/+2
| | | | | | | | | cannot change (because its referenced by curthread). This fixes a LOR caused by acquiring emul_shared_lock while holding emul_lock. Fix typo in comment. Submitted by: rdivacky
* MFp4 (112646):netchild2007-01-071-1/+1
| | | | | | | | | Now (ok it's been a while...) that FreeBSD has RLIMIT_AS too, we can use it in the linuxolator instead of ignoring it. This fixes a LTP test. Submitted by: rdivacky
* MFp4 (112534):netchild2007-01-071-4/+2
| | | | | | | | | Dont lock em in a case of just using em->shared->group_pid because the group_pid never changes. Submitted by: rdivacky Reviewed by: kib Glanced at by: jhb
* MFp4 (112498):netchild2007-01-071-6/+6
| | | | | | Rename the locking flags to EMUL_DOLOCK and EMUL_DONTLOCK to prevent confusion. Submitted by: rdivacky
* MFp4 (111746, 108671, 108945, 112352):netchild2006-12-311-0/+32
| | | | | | | | | - add linux utimes syscall [1] - add linux rt_sigtimedwait syscall [2] Submitted by: "Scot Hetzel" <swhetzel@gmail.com> [1] Submitted by: Bruce Becker <hostmaster@whois.gts.net> [2] PR: 93199 [2]
* MFp4 (111746+):netchild2006-12-311-9/+3
| | | | | | | | | | | | | | Redo the checking for 2.6 emulation. We now cache the value of use26 and replace calls to linux_get_osrelease() + parsing with a call to linux_use26(). Typical path is lockless now. Pointed out by: kib This allows to ship RELENG_7_0 with a default osrelease of 2.4.2 and the possibility to enable 2.6.x emulation without the possible performance impact of the previous version of the check. Submitted by: rdivacky
* MFp4:netchild2006-12-311-59/+65
| | | | | | - semi-automatic style fixes - spelling fixes in comments - add some comments
* MFP4: 109653jkim2006-12-041-2/+25
| | | | | Linux mknod(2) can open any files, not just char/block or fifo files. This fixes Linux Test Project test cases mknod01, mknod07 and mknod09.
* MFP4 (108673, 110519, 110874):netchild2006-12-021-5/+30
| | | | | | | | | | | | | | - Currently LINUX_MAX_COMM_LEN is smaller than MAXCOMLEN, but in case this will change we have a buffer overflow. Apply some defensive programming to DTRT when this should happen. - Use copyinstr() instead of copyin where appropriate. * Fallback to copyin() in case of ENAMETOOLONG. [1] * Use the right source and destination (it was wrong before). - Use strlcpy instead of strcpy. - Properly lock the read case (PR_GET_NAME) like the write case. Reviewed by: rwatson (except [1]) Suggested by: rwatson [1]
* Sync struct sysinfo with real one from linux.kib2006-11-181-1/+2
| | | | Submitted by: rdivacky
* Add debuging printfs to syscalls that do not contain it yet. Inkib2006-11-181-0/+36
| | | | | | | sethostname do not print the hostname because it would require to copyin the string. Sethostname is not very frequently used. Submitted by: rdivacky
* Remove unecessary locking of process in linux_getpid.kib2006-11-181-2/+0
| | | | | Suggested by: jhb Submitted by: rdivacky
* In rev 1.188 of linux_misc.c the added check for valid options ommitedkib2006-11-151-1/+1
| | | | | | | | __WCLONE. This fixes it thus fixing skype/teamspeak to not keep zombies after exit. Submitted by: rdivacky Reported by: Bakul Shah (bakul at bitblocks com)
OpenPOWER on IntegriCloud