summaryrefslogtreecommitdiff
path: root/sys/compat/linux
Commit message (Collapse)AuthorAgeFilesLines
* MFC r302517:Dmitry Chagin2016-07-182-0/+306
| | | | | | | | | | | | | | Fix a copy/paste bug introduced during X86_64 Linuxulator work. FreeBSD support NX bit on X86_64 processors out of the box, for i386 emulation use READ_IMPLIES_EXEC flag, introduced in r302515. While here move common part of mmap() and mprotect() code to the files in compat/linux to reduce code dupcliation between Linuxulator's Approved by: re (gjb) Notes: svn path=/stable/11/; revision=303007
* MFC r302515:Dmitry Chagin2016-07-184-6/+86
| | | | | | | | | | | | | Implement Linux personality() system call mainly due to READ_IMPLIES_EXEC flag. In Linux if this flag is set, PROT_READ implies PROT_EXEC for mmap(). Linux/i386 set this flag automatically if the binary requires executable stack. READ_IMPLIES_EXEC flag will be used in the next Linux mmap() commit. Approved by: re (gjb) Notes: svn path=/stable/11/; revision=303005
* Fix a bug introduced in r283433.Dmitry Chagin2016-06-261-8/+6
| | | | | | | | | | | | | | | | | | [1] Remove unneeded sockaddr conversion before kern_recvit() call as the from argument is used to record result (the source address of the received message) only. [2] In Linux the type of msg_namelen member of struct msghdr is signed but native msg_namelen has a unsigned type (socklen_t). So use the proper storage to fetch fromlen from userspace and than check the user supplied value and return EINVAL if it is less than 0 as a Linux do. Reported by: Thomas Mueller <tmueller at sysgo dot com> [1] Reviewed by: kib@ Approved by: re (gjb, kib) MFC after: 3 days Notes: svn path=/head/; revision=302213
* Update comments for the MD functions managing contexts for newKonstantin Belousov2016-06-161-2/+2
| | | | | | | | | | | | | | | | | | | threads, to make it less confusing and using modern kernel terms. Rename the functions to reflect current use of the functions, instead of the historic KSE conventions: cpu_set_fork_handler -> cpu_fork_kthread_handler (for kthreads) cpu_set_upcall -> cpu_copy_thread (for forks) cpu_set_upcall_kse -> cpu_set_upcall (for new threads creation) Reviewed by: jhb (previous version) Sponsored by: The FreeBSD Foundation MFC after: 1 week Approved by: re (hrs) Differential revision: https://reviews.freebsd.org/D6731 Notes: svn path=/head/; revision=301961
* Fix kernel stack disclosures in the Linux and 4.3BSD compat layers.Gleb Smirnoff2016-05-312-0/+3
| | | | | | | | | Submitted by: CTurt Security: SA-16:20 Security: SA-16:21 Notes: svn path=/head/; revision=301053
* Don't leak fp in case where fo_ioctl() returns an error.Dmitry Chagin2016-05-241-1/+1
| | | | | | | | Reported by: C Turt <ecturt@gmail.com> MFC after: 1 week Notes: svn path=/head/; revision=300569
* Convert proto family in both directions. The linux and native values forDmitry Chagin2016-05-221-4/+12
| | | | | | | | | | | local and inet are identical, but for inet6 values differ. PR: 155040 Reported by: Simon Walton MFC after: 2 week Notes: svn path=/head/; revision=300431
* Add a missing errno translation for SO_ERROR optname.Dmitry Chagin2016-05-221-2/+11
| | | | | | | | | PR: 135458 Reported by: Stefan Schmidt @ stadtbuch.de MFC after: 1 week Notes: svn path=/head/; revision=300416
* For future use move futex timeout code to the separate function andDmitry Chagin2016-05-221-41/+68
| | | | | | | | | switch to the high resolution sbintime_t. MFC after: 1 week Notes: svn path=/head/; revision=300414
* Due to lack the priority propagation feature replace sx by mutex. WIth thisDmitry Chagin2016-05-221-44/+77
| | | | | | | | | commit NPTL tests are ends in 1 minute faster. MFC after: 1 week Notes: svn path=/head/; revision=300413
* Add my copyright as I rewrote most of the futex code. Minor style(9) cleanupDmitry Chagin2016-05-221-3/+4
| | | | | | | | | while here. MFC after: 1 week Notes: svn path=/head/; revision=300412
* Minor style(9) cleanup, no functional changes.Dmitry Chagin2016-05-221-114/+106
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=300411
* Add implementation of robust mutexes, hopefully close enough to theKonstantin Belousov2016-05-171-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | intention of the POSIX IEEE Std 1003.1TM-2008/Cor 1-2013. A robust mutex is guaranteed to be cleared by the system upon either thread or process owner termination while the mutex is held. The next mutex locker is then notified about inconsistent mutex state and can execute (or abandon) corrective actions. The patch mostly consists of small changes here and there, adding neccessary checks for the inconsistent and abandoned conditions into existing paths. Additionally, the thread exit handler was extended to iterate over the userspace-maintained list of owned robust mutexes, unlocking and marking as terminated each of them. The list of owned robust mutexes cannot be maintained atomically synchronous with the mutex lock state (it is possible in kernel, but is too expensive). Instead, for the duration of lock or unlock operation, the current mutex is remembered in a special slot that is also checked by the kernel at thread termination. Kernel must be aware about the per-thread location of the heads of robust mutex lists and the current active mutex slot. When a thread touches a robust mutex for the first time, a new umtx op syscall is issued which informs about location of lists heads. The umtx sleep queues for PP and PI mutexes are split between non-robust and robust. Somewhat unrelated changes in the patch: 1. Style. 2. The fix for proper tdfind() call use in umtxq_sleep_pi() for shared pi mutexes. 3. Removal of the userspace struct pthread_mutex m_owner field. 4. The sysctl kern.ipc.umtx_vnode_persistent is added, which controls the lifetime of the shared mutex associated with a vnode' page. Reviewed by: jilles (previous version, supposedly the objection was fixed) Discussed with: brooks, Martin Simmons <martin@lispworks.com> (some aspects) Tested by: pho Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=300043
* sys/compat/linux*: spelling fixes.Pedro F. Giffuni2016-04-305-5/+5
| | | | | | | | | Mostly on comments but there are some user-visible messages as well. MFC after: 2 weeks Notes: svn path=/head/; revision=298829
* osd(9): Change array pointer to array pointer type from void*Conrad Meyer2016-04-261-1/+1
| | | | | | | | | | | | | | | | This is a minor follow-up to r297422, prompted by a Coverity warning. (It's not a real defect, just a code smell.) OSD slot array reservations are an array of pointers (void **) but were cast to void* and back unnecessarily. Keep the correct type from reservation to use. osd.9 is updated to match, along with a few trivial igor fixes. Reported by: Coverity CID: 1353811 Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=298661
* linux_map_osrel doesn't need to be checked in linux_prison_set,Jamie Gritton2016-04-251-8/+5
| | | | | | | since it already was in linux_prison_check. Notes: svn path=/head/; revision=298573
* Cleanup redundant parenthesis from existing howmany()/roundup() macro uses.Pedro F. Giffuni2016-04-221-3/+2
| | | | Notes: svn path=/head/; revision=298482
* kernel: use our nitems() macro when it is available through param.h.Pedro F. Giffuni2016-04-191-1/+1
| | | | | | | | | No functional change, only trivial cases are done in this sweep, Discussed in: freebsd-current Notes: svn path=/head/; revision=298310
* compat/linux: for pointers replace 0 with NULL.Pedro F. Giffuni2016-04-151-1/+1
| | | | | | | | | plvc is a pointer, no functional change. Found with devel/coccinelle. Notes: svn path=/head/; revision=298071
* More complete implementation of /proc/self/limits.Dmitry Chagin2016-04-101-0/+7
| | | | | | | | | | | Fix the way the code accesses process limits struct - pointed out by mjg@. PR: 207386 Reviewed by: no objection form des@ MFC after: 3 weeks Notes: svn path=/head/; revision=297781
* Fix indentation oops.Pedro F. Giffuni2016-04-031-3/+3
| | | | Notes: svn path=/head/; revision=297525
* Move Linux specific times tests up to guarantee the values are defined.Dmitry Chagin2016-04-031-2/+3
| | | | | | | | | CID: 1305178 Submitted by: pfg@ MFC after: 1 week Notes: svn path=/head/; revision=297519
* Use osd_reserve / osd_jail_set_reserved, which is known to succeed.Jamie Gritton2016-03-301-31/+16
| | | | | | | Also don't work around nonexistent osd_register failure. Notes: svn path=/head/; revision=297424
* Revert r297310 as the SOL_XXX are equal to the IPPROTO_XX except SOL_SOCKET.Dmitry Chagin2016-03-271-2/+0
| | | | | | | Pointed out by: ae@ Notes: svn path=/head/; revision=297313
* iConvert Linux SOL_IPV6 level.Dmitry Chagin2016-03-271-0/+2
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=297310
* Whitespaces and style(9) fix. No functional changes.Dmitry Chagin2016-03-271-29/+11
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=297309
* When write(2) on eventfd object fails with the error EAGAIN do not returnDmitry Chagin2016-03-261-0/+2
| | | | | | | | | the number of bytes written. MFC after: 1 week Notes: svn path=/head/; revision=297297
* Implement O_NONBLOCK flag via fcntl(F_SETFL) for eventfd object.Dmitry Chagin2016-03-261-1/+18
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=297296
* Check bsd_to_linux_statfs() return value. Forgotten in r297070.Dmitry Chagin2016-03-201-3/+7
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=297072
* Return EOVERFLOW in case when actual statfs values are large enough andDmitry Chagin2016-03-201-1/+15
| | | | | | | | | | not fit into 32 bit fileds of a Linux struct statfs. PR: 181012 MFC after: 1 week Notes: svn path=/head/; revision=297070
* Whitespaces, style(9) fixes. No functional changes.Dmitry Chagin2016-03-201-6/+6
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=297063
* Implement fstatfs64 system call.Dmitry Chagin2016-03-201-0/+21
| | | | | | | | | PR: 181012 Submitted by: John Wehle MFC after: 1 week Notes: svn path=/head/; revision=297061
* Rework r296543:Dmitry Chagin2016-03-201-18/+19
| | | | | | | | | | | | | | | | 1. Limit secs to INT32_MAX / 2 to avoid errors from kern_setitimer(). Assert that kern_setitimer() returns 0. Remove bogus cast of secs. Fix style(9) issues. 2. Increment the return value if the remaining tv_usec value more than 500000 as a Linux does. Pointed out by: [1] Bruce Evans MFC after: 1 week Notes: svn path=/head/; revision=297060
* Add support for IPPROTO_IPV6 socket layer for getsockopt/setsockopt calls.Andrey V. Elsukov2016-03-092-0/+88
| | | | | | | | | | | Also add mapping for several options from RFC 3493 and 3542. Reviewed by: dchagin Tested by: Joe Love <joe at getsomwhere dot net> MFC after: 2 weeks Notes: svn path=/head/; revision=296557
* Better english.Dmitry Chagin2016-03-081-1/+1
| | | | | | | | Submitted by: Kevin P. Neal MFC after: 1 week Notes: svn path=/head/; revision=296546
* Put a commit message from r296502 about Linux alarm() system callDmitry Chagin2016-03-081-0/+5
| | | | | | | | | | | behaviour to the source. Suggested by: emaste@ MFC after: 1 week Notes: svn path=/head/; revision=296543
* Does not leak fp. While here remove bogus cast of fp->f_data.Dmitry Chagin2016-03-081-2/+5
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=296504
* Linux accept() system call return EOPNOTSUPP errno instead of EINVALDmitry Chagin2016-03-081-1/+12
| | | | | | | | | for UDP sockets. MFC after: 1 week Notes: svn path=/head/; revision=296503
* According to POSIX and Linux implementation the alarm() system callDmitry Chagin2016-03-081-4/+1
| | | | | | | | | | | | | is always successfull. So, ignore any errors and return 0 as a Linux do. XXX. Unlike POSIX, Linux in case when the invalid seconds value specified always return 0, so in that case Linux does not return proper remining time. MFC after: 1 week Notes: svn path=/head/; revision=296502
* Link the newly created process to the corresponding parent asDmitry Chagin2016-03-081-0/+12
| | | | | | | | | | if CLONE_PARENT is set, then the parent of the new process will be the same as that of the calling process. MFC after: 1 week Notes: svn path=/head/; revision=296501
* As <machine/vmparam.h> is included from <vm/vm_param.h>, there is noSvatopluk Kraus2016-02-221-1/+0
| | | | | | | | | | | need to include it explicitly when <vm/vm_param.h> is already included. Suggested by: alc Reviewed by: alc Differential Revision: https://reviews.freebsd.org/D5379 Notes: svn path=/head/; revision=295882
* fork: pass arguments to fork1 in a dedicated structureMateusz Guzik2016-02-041-5/+15
| | | | | | | Suggested by: kib Notes: svn path=/head/; revision=295232
* Prevent double free of control in common sendmsg path as sosendDmitry Chagin2016-01-171-0/+1
| | | | | | | already freeing it. Notes: svn path=/head/; revision=294233
* Call crextend() before copying old credentials to the new credentialsGleb Smirnoff2016-01-141-1/+3
| | | | | | | | | | | | | | | | and replace crcopysafe by crcopy as crcopysafe is is not intended to be safe in a threaded environment, it drops PROC_LOCK() in while() that can lead to unexpected results, such as overwrite kernel memory. In my POV crcopysafe() needs special attention. For now I do not see any problems with this function, but who knows. Submitted by: dchagin Found by: trinity Security: SA-16:04.linux Notes: svn path=/head/; revision=293909
* Change linux get_robust_list system call to match actual linux one.Gleb Smirnoff2016-01-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | The set_robust_list system call request the kernel to record the head of the list of robust futexes owned by the calling thread. The head argument is the list head to record. The get_robust_list system call should return the head of the robust list of the thread whose thread id is specified in pid argument. The list head should be stored in the location pointed to by head argument. In contrast, our implemenattion of get_robust_list system call copies the known portion of memory pointed by recorded in set_robust_list system call pointer to the head of the robust list to the location pointed by head argument. So, it is possible for a local attacker to read portions of kernel memory, which may result in a privilege escalation. Submitted by: mjg Security: SA-16:03.linux Notes: svn path=/head/; revision=293907
* Unlock process lock when return error from getrobustlist call and addDmitry Chagin2016-01-101-1/+5
| | | | | | | | | | an forgotten dtrace probe when return the same error. MFC after: 3 days XMFC with: r292743 Notes: svn path=/head/; revision=293627
* Return EINVAL in case of incorrect sigev_signo value specified instead of ↵Dmitry Chagin2015-12-261-0/+4
| | | | | | | panicing. Notes: svn path=/head/; revision=292744
* Do not allow access to emuldata for non Linux processes.Dmitry Chagin2015-12-261-0/+2
| | | | | | | | Pointed out by: mjg@ Security: https://admbugs.freebsd.org/show_bug.cgi?id=679 Notes: svn path=/head/; revision=292743
* Fix style issues around existing SDT probes.Mark Johnston2015-12-161-2/+2
| | | | | | | | | | | | - Use SDT_PROBE<N>() instead of SDT_PROBE(). This has no functional effect at the moment, but will be needed for some future changes. - Don't hardcode the module component of the probe identifier. This is set automatically by the SDT framework. MFC after: 1 week Notes: svn path=/head/; revision=292384
* Fix build for the KTR-enabled kernels.Konstantin Belousov2015-10-231-2/+9
| | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=289822